Skip to content

Commit

Permalink
add NOTIONAL filter support
Browse files Browse the repository at this point in the history
  • Loading branch information
mm2175 committed Apr 25, 2023
1 parent 9f9dbd7 commit 13b4400
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 14 deletions.
7 changes: 4 additions & 3 deletions v2/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@ import (
"os"
"time"

"github.com/bitly/go-simplejson"
jsoniter "github.com/json-iterator/go"

"github.com/adshao/go-binance/v2/common"
"github.com/adshao/go-binance/v2/delivery"
"github.com/adshao/go-binance/v2/futures"
"github.com/bitly/go-simplejson"
jsoniter "github.com/json-iterator/go"
)

// SideType define side type of order
Expand Down Expand Up @@ -155,7 +156,7 @@ const (
SymbolFilterTypePriceFilter SymbolFilterType = "PRICE_FILTER"
SymbolFilterTypePercentPrice SymbolFilterType = "PERCENT_PRICE"
// Deprecated: use SymbolFilterTypePercentPrice instead
SymbolFilterTypeMinNotional SymbolFilterType = "NOTIONAL"
SymbolFilterTypeMinNotional SymbolFilterType = "MIN_NOTIONAL"
SymbolFilterTypeNotional SymbolFilterType = "NOTIONAL"
SymbolFilterTypeIcebergParts SymbolFilterType = "ICEBERG_PARTS"
SymbolFilterTypeMarketLotSize SymbolFilterType = "MARKET_LOT_SIZE"
Expand Down
30 changes: 19 additions & 11 deletions v2/exchange_info_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,13 @@ type MinNotionalFilter struct {
ApplyToMarket bool `json:"applyToMarket"`
}

// NotionalFilter define min notional filter of symbol
// NotionalFilter define notional filter of symbol
type NotionalFilter struct {
MinNotional string `json:"minNotional"`
AveragePriceMins int `json:"avgPriceMins"`
ApplyToMarket bool `json:"applyToMarket"`
ApplyMinToMarket bool `json:"applyMinToMarket"`
MaxNotional string `json:"maxNotional"`
ApplyMaxToMarket bool `json:"applyMaxToMarket"`
AvgPriceMins int `json:"avgPriceMins"`
}

// IcebergPartsFilter define iceberg part filter of symbol
Expand Down Expand Up @@ -217,10 +219,10 @@ func (s *Symbol) PercentPriceFilter() *PercentPriceFilter {

// MinNotionalFilter return min notional filter of symbol
// Deprecated: use NotionalFilter instead
func (s *Symbol) MinNotionalFilter() *NotionalFilter {
func (s *Symbol) MinNotionalFilter() *MinNotionalFilter {
for _, filter := range s.Filters {
if filter["filterType"].(string) == string(SymbolFilterTypeNotional) {
f := &NotionalFilter{}
if filter["filterType"].(string) == string(SymbolFilterTypeMinNotional) {
f := &MinNotionalFilter{}
if i, ok := filter["minNotional"]; ok {
f.MinNotional = i.(string)
}
Expand All @@ -236,19 +238,25 @@ func (s *Symbol) MinNotionalFilter() *NotionalFilter {
return nil
}

// NotionalFilter return min notional filter of symbol
// NotionalFilter return notional filter of symbol
func (s *Symbol) NotionalFilter() *NotionalFilter {
for _, filter := range s.Filters {
if filter["filterType"].(string) == string(SymbolFilterTypeNotional) {
f := &NotionalFilter{}
if i, ok := filter["minNotional"]; ok {
f.MinNotional = i.(string)
}
if i, ok := filter["avgPriceMins"]; ok {
f.AveragePriceMins = int(i.(float64))
if i, ok := filter["applyMinToMarket"]; ok {
f.ApplyMinToMarket = i.(bool)
}
if i, ok := filter["applyToMarket"]; ok {
f.ApplyToMarket = i.(bool)
if i, ok := filter["maxNotional"]; ok {
f.MaxNotional = i.(string)
}
if i, ok := filter["applyMaxToMarket"]; ok {
f.ApplyMaxToMarket = i.(bool)
}
if i, ok := filter["avgPriceMins"]; ok {
f.AvgPriceMins = int(i.(float64))
}
return f
}
Expand Down

0 comments on commit 13b4400

Please sign in to comment.