diff --git a/client/mm/libxc/binance_live_test.go b/client/mm/libxc/binance_live_test.go index 109d83c7c1..94638b02b3 100644 --- a/client/mm/libxc/binance_live_test.go +++ b/client/mm/libxc/binance_live_test.go @@ -5,9 +5,9 @@ package libxc import ( "context" "encoding/json" + "flag" "fmt" "os" - "os/user" "strings" "sync" "testing" @@ -20,13 +20,23 @@ import ( ) var ( - log = dex.StdOutLogger("T", dex.LevelTrace) - u, _ = user.Current() - apiKey = "" - apiSecret = "" + log = dex.StdOutLogger("T", dex.LevelTrace) + binanceUS = true + global bool + apiKey string + apiSecret string + minTradeSymbol string ) func TestMain(m *testing.M) { + flag.StringVar(&minTradeSymbol, "symbol", "", "Market slug") + flag.BoolVar(&global, "global", false, "Use Binance global") + flag.Parse() + + if global { + binanceUS = false + } + if s := os.Getenv("SECRET"); s != "" { apiSecret = s } @@ -47,7 +57,6 @@ func tNewBinance(t *testing.T, net dex.Network) *binance { log.Infof("Notification sent: %+v", n) }, } - const binanceUS = true return newBinance(cfg, binanceUS) } @@ -407,3 +416,32 @@ func TestMarkets(t *testing.T) { b, _ := json.MarshalIndent(mkts, "", " ") fmt.Println("##### Market Data:", string(b)) } + +func TestGetMinTrade(t *testing.T) { + // e.g. + // go test -tags bnclive -run TestGetMinTrade --symbol DCRBTC --global + + if minTradeSymbol == "" { + t.Fatal("No market symbol provided") + } + bnc := tNewBinance(t, dex.Testnet) + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + + var xcInfo bntypes.ExchangeInfo + if err := bnc.getAPI(ctx, "/api/v3/exchangeInfo", nil, false, false, &xcInfo); err != nil { + t.Fatal(err) + } + for _, mkt := range xcInfo.Symbols { + if mkt.Symbol != minTradeSymbol { + continue + } + for _, filt := range mkt.Filters { + if filt.FilterType == "LOT_SIZE" { + fmt.Printf("Market %s min trade = %f %s \n", mkt.Symbol, filt.MinQty, mkt.BaseAsset) + return + } + } + } + t.Fatal("Market not found") +} diff --git a/client/mm/libxc/bntypes/types.go b/client/mm/libxc/bntypes/types.go index 1f4515fde2..dc42a7c644 100644 --- a/client/mm/libxc/bntypes/types.go +++ b/client/mm/libxc/bntypes/types.go @@ -10,7 +10,69 @@ type Market struct { QuoteAsset string `json:"quoteAsset"` QuoteAssetPrecision int `json:"quoteAssetPrecision"` OrderTypes []string `json:"orderTypes"` -} + Filters []struct { + FilterType string `json:"filterType"` + MinQty float64 `json:"minQty,string"` + MaxQty float64 `json:"maxQty,string"` + StepSize float64 `json:"stepSize,string"` + } `json:"filters"` +} + +// "filters": [ +// { +// "filterType": "PRICE_FILTER", +// "minPrice": "0.00010000", +// "maxPrice": "1000.00000000", +// "tickSize": "0.00010000" +// }, +// { +// "filterType": "LOT_SIZE", +// "minQty": "0.10000000", +// "maxQty": "92141578.00000000", +// "stepSize": "0.10000000" +// }, +// { +// "filterType": "ICEBERG_PARTS", +// "limit": 10 +// }, +// { +// "filterType": "MARKET_LOT_SIZE", +// "minQty": "0.00000000", +// "maxQty": "14989.56610878", +// "stepSize": "0.00000000" +// }, +// { +// "filterType": "TRAILING_DELTA", +// "minTrailingAboveDelta": 10, +// "maxTrailingAboveDelta": 2000, +// "minTrailingBelowDelta": 10, +// "maxTrailingBelowDelta": 2000 +// }, +// { +// "filterType": "PERCENT_PRICE_BY_SIDE", +// "bidMultiplierUp": "5", +// "bidMultiplierDown": "0.2", +// "askMultiplierUp": "5", +// "askMultiplierDown": "0.2", +// "avgPriceMins": 5 +// }, +// { +// "filterType": "NOTIONAL", +// "minNotional": "10.00000000", +// "applyMinToMarket": true, +// "maxNotional": "9000000.00000000", +// "applyMaxToMarket": false, +// "avgPriceMins": 5 +// }, +// { +// "filterType": "MAX_NUM_ORDERS", +// "maxNumOrders": 200 +// }, +// { +// "filterType": "MAX_NUM_ALGO_ORDERS", +// "maxNumAlgoOrders": 5 +// } +// ], type Balance struct { Asset string `json:"asset"`