Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mm: sus out min trade size from binance xcinfo filters #2960

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 44 additions & 6 deletions client/mm/libxc/binance_live_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ package libxc
import (
"context"
"encoding/json"
"flag"
"fmt"
"os"
"os/user"
"strings"
"sync"
"testing"
Expand All @@ -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
}
Expand All @@ -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)
}

Expand Down Expand Up @@ -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")
}
64 changes: 63 additions & 1 deletion client/mm/libxc/bntypes/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
Loading