forked from stellar-deprecated/kelp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Mirror Strategy: track orders triggered on backingExchange by trades …
…on primaryExchange (closes stellar-deprecated#503) (stellar-deprecated#504) * 1 - create strategy_mirror_trade_triggers table * 2 - thread db instance through to mirror strategy * 3 - thread marketID and backingMarketID through to mirrorStrategy * 4 - insert trade trigger when offsetting trades in HandleFill * 5 - update TestTradeUpgradeScripts to validate upgrade script changes from (1) * 6 - register backingMarketID in the db * 7 - construct fill tracker for backing exchange and trigger in HandleFills to confirm taker orders consumed * 8 - trigger fill tracking on backing exchange at creation time * 9 - fixed bug, shadowing of backingFillTracker, causing a nil dereference everywhere! * 10 - update strategy_mirror_trade_triggers schema and PKEY to replace backing_txid with backing_order_id, and remove backing_market_id and backing_order_id from PKEY so we don't offset trades more than once * 11 - add order_id to trades table along with logic to update it * 12 - extract orderID from FetchMyTrades call of ccxtExchange for binance * 13 - query StrategyMirrorTradeTriggerExists to ensure we don't re-offset trades in error scenarios * 14 - fix bug in StrategyMirrorTradeTriggerExists, row.Scan needs inputs even if unused
- Loading branch information
1 parent
1f8b66b
commit b4c802d
Showing
18 changed files
with
482 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package plugins | ||
|
||
import ( | ||
"fmt" | ||
"strconv" | ||
|
||
"github.com/stellar/kelp/api" | ||
) | ||
|
||
type ccxtExchangeSpecificParamFactoryCoinbasepro struct{} | ||
|
||
func (f *ccxtExchangeSpecificParamFactoryCoinbasepro) getParamsForAddOrder(submitMode api.SubmitMode) interface{} { | ||
if submitMode == api.SubmitModeMakerOnly { | ||
return map[string]interface{}{ | ||
"post_only": true, | ||
} | ||
} | ||
return nil | ||
} | ||
|
||
func (f *ccxtExchangeSpecificParamFactoryCoinbasepro) getParamsForGetTradeHistory() interface{} { | ||
return nil | ||
} | ||
|
||
var _ ccxtExchangeSpecificParamFactory = &ccxtExchangeSpecificParamFactoryCoinbasepro{} | ||
|
||
type ccxtExchangeSpecificParamFactoryBinance struct{} | ||
|
||
func (f *ccxtExchangeSpecificParamFactoryBinance) getParamsForAddOrder(submitMode api.SubmitMode) interface{} { | ||
return nil | ||
} | ||
|
||
func (f *ccxtExchangeSpecificParamFactoryBinance) getParamsForGetTradeHistory() interface{} { | ||
return map[string]interface{}{ | ||
"order_id": func(info interface{}) (string, error) { | ||
rawInfo, ok := info.(map[string]interface{}) | ||
if !ok { | ||
return "", fmt.Errorf("unable to convert input 'info' to a map[string]interface{}: %+v (type=%T)", rawInfo, rawInfo) | ||
} | ||
|
||
orderIDFloat64, ok := rawInfo["orderId"].(float64) | ||
if !ok { | ||
return "", fmt.Errorf("unable to parse info[\"orderId\"] as a float64: %+v (type=%T)", rawInfo["orderId"], rawInfo["orderId"]) | ||
} | ||
|
||
orderIDInt64 := int64(orderIDFloat64) | ||
orderID := strconv.FormatInt(orderIDInt64, 10) | ||
return orderID, nil | ||
}, | ||
} | ||
} | ||
|
||
var _ ccxtExchangeSpecificParamFactory = &ccxtExchangeSpecificParamFactoryBinance{} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.