diff --git a/binance/symbol.go b/binance/symbol.go index 0ca324d..24fadd2 100644 --- a/binance/symbol.go +++ b/binance/symbol.go @@ -4,6 +4,8 @@ import ( "fmt" "math" "strconv" + + "github.com/adshao/go-binance/v2" ) // SymbolBalance get available amount in user wallet. @@ -42,3 +44,13 @@ func (me *Binance) SymbolPrice(symbol, buyWith, interval string) (float64, error return symbolPrice, nil } + +// SymbolExchangeInfo get the last symbol price. +func (me *Binance) SymbolExchangeInfo(symbol string) (*binance.ExchangeInfo, error) { + res, err := me.Binance.NewExchangeInfoService().Symbol(symbol).Do(*me.Context) + if err != nil { + return nil, err + } + + return res, nil +} diff --git a/bot/bot.go b/bot/bot.go index 1b03745..9a49e44 100644 --- a/bot/bot.go +++ b/bot/bot.go @@ -168,6 +168,21 @@ func (me *Bot) sell(trade config.Trade, price float64) error { return nil } +// check rules before buy. +func (me *Bot) rules(trade *config.Trade) error { + exchange, err := me.Binance.SymbolExchangeInfo(trade.Symbol) + if err != nil { + return err + } + + minNotional := exchange.Symbols[0].MinNotionalFilter().MinNotional + minQuantity := exchange.Symbols[0].LotSizeFilter().MinQuantity + me.Log.Debug().Msgf("[%s] minNotional=%.2f minQuantity=%.2f", + trade.Symbol, minNotional, minQuantity) + + return nil +} + // format welcome message notification. func (me *Bot) welcomeMessage(config config.Config) string { msg := fmt.Sprintf("%s started! :money_mouth_face:\n\n", config.Name)