diff --git a/v2/account_service.go b/v2/account_service.go index f97ff71b..daa1acd7 100644 --- a/v2/account_service.go +++ b/v2/account_service.go @@ -2,6 +2,7 @@ package binance import ( "context" + "encoding/json" "net/http" ) diff --git a/v2/asset_detail_service.go b/v2/asset_detail_service.go index 452a0dcb..613e87ea 100644 --- a/v2/asset_detail_service.go +++ b/v2/asset_detail_service.go @@ -2,6 +2,7 @@ package binance import ( "context" + "encoding/json" "net/http" ) diff --git a/v2/asset_dividend_service.go b/v2/asset_dividend_service.go index 702cfa92..c0958e08 100644 --- a/v2/asset_dividend_service.go +++ b/v2/asset_dividend_service.go @@ -2,6 +2,7 @@ package binance import ( "context" + "encoding/json" "net/http" ) diff --git a/v2/bnb_burn_service.go b/v2/bnb_burn_service.go index 3af88d47..e8374c95 100644 --- a/v2/bnb_burn_service.go +++ b/v2/bnb_burn_service.go @@ -2,6 +2,7 @@ package binance import ( "context" + "encoding/json" "net/http" ) diff --git a/v2/c2c_service.go b/v2/c2c_service.go index 40206faa..28018161 100644 --- a/v2/c2c_service.go +++ b/v2/c2c_service.go @@ -2,6 +2,7 @@ package binance import ( "context" + "encoding/json" "net/http" ) diff --git a/v2/client.go b/v2/client.go index 9df334ec..c295e207 100644 --- a/v2/client.go +++ b/v2/client.go @@ -10,10 +10,12 @@ import ( "net/http" "net/url" "os" + "strings" "time" + "encoding/json" + "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" @@ -133,9 +135,6 @@ type SelfTradePreventionMode string // UseTestnet switch all the API endpoints from production to the testnet var UseTestnet = false -// Redefining the standard package -var json = jsoniter.ConfigCompatibleWithStandardLibrary - // Global enums const ( SideTypeBuy SideType = "BUY" @@ -443,8 +442,10 @@ func (c *Client) parseRequest(r *request, opts ...RequestOption) (err error) { r.setParam(timestampKey, currentTimestamp()-c.TimeOffset) } queryString := r.query.Encode() + queryString = strings.ReplaceAll(queryString, "%40", "@") body := &bytes.Buffer{} bodyString := r.form.Encode() + bodyString = strings.ReplaceAll(bodyString, "%40", "@") header := http.Header{} if r.header != nil { header = r.header.Clone() diff --git a/v2/common/helpers.go b/v2/common/helpers.go index 5a5df703..3d07be0b 100644 --- a/v2/common/helpers.go +++ b/v2/common/helpers.go @@ -11,6 +11,19 @@ func AmountToLotSize(lot float64, precision int, amount float64) float64 { return math.Trunc(math.Floor(amount/lot)*lot*math.Pow10(precision)) / math.Pow10(precision) } +func RoundPriceToTickSize(price, tickSize float64) float64 { + if tickSize == 0 { + return price // To avoid division by zero + } + // Calculate the factor by which to multiply and divide the price to conform to the tick size. + factor := 1 / tickSize + + // Round the price to the nearest tick size. + roundedPrice := math.Round(price*factor) / factor + + return roundedPrice +} + // ToJSONList convert v to json list if v is a map func ToJSONList(v []byte) []byte { if len(v) > 0 && v[0] == '{' { diff --git a/v2/convert_trade.go b/v2/convert_trade.go index f076236e..e7d3afe0 100644 --- a/v2/convert_trade.go +++ b/v2/convert_trade.go @@ -2,6 +2,7 @@ package binance import ( "context" + "encoding/json" "net/http" ) diff --git a/v2/delivery/websocket.go b/v2/delivery/websocket.go index a5e5857d..22e3204e 100644 --- a/v2/delivery/websocket.go +++ b/v2/delivery/websocket.go @@ -39,7 +39,7 @@ var wsServe = func(cfg *WsConfig, handler WsHandler, errHandler ErrHandler) (don Dialer := websocket.Dialer{ Proxy: proxy, HandshakeTimeout: 45 * time.Second, - EnableCompression: false, + EnableCompression: true, } c, _, err := Dialer.Dial(cfg.Endpoint, nil) diff --git a/v2/deposit_service.go b/v2/deposit_service.go index 09de6534..32055fdd 100644 --- a/v2/deposit_service.go +++ b/v2/deposit_service.go @@ -2,6 +2,7 @@ package binance import ( "context" + "encoding/json" "net/http" ) diff --git a/v2/dust_log_service.go b/v2/dust_log_service.go index 8051b472..fc897926 100644 --- a/v2/dust_log_service.go +++ b/v2/dust_log_service.go @@ -11,6 +11,7 @@ package binance import ( "context" + "encoding/json" "net/http" ) diff --git a/v2/exchange_info_service.go b/v2/exchange_info_service.go index de5b7bb3..ca524c92 100644 --- a/v2/exchange_info_service.go +++ b/v2/exchange_info_service.go @@ -2,6 +2,7 @@ package binance import ( "context" + "encoding/json" "net/http" "github.com/adshao/go-binance/v2/common" diff --git a/v2/fiat_service.go b/v2/fiat_service.go index 532fd427..572103a3 100644 --- a/v2/fiat_service.go +++ b/v2/fiat_service.go @@ -2,6 +2,7 @@ package binance import ( "context" + "encoding/json" "net/http" ) diff --git a/v2/futures/client.go b/v2/futures/client.go index ed4ae426..17c6f54a 100644 --- a/v2/futures/client.go +++ b/v2/futures/client.go @@ -525,7 +525,10 @@ func (c *Client) NewGetBalanceService() *GetBalanceService { return &GetBalanceService{c: c} } -// NewGetPositionRiskService init getting position risk service +func (c *Client) NewGetPositionRiskV2Service() *GetPositionRiskV2Service { + return &GetPositionRiskV2Service{c: c} +} + func (c *Client) NewGetPositionRiskService() *GetPositionRiskService { return &GetPositionRiskService{c: c} } diff --git a/v2/futures/order_service.go b/v2/futures/order_service.go index c4bd3e8e..e93578ee 100644 --- a/v2/futures/order_service.go +++ b/v2/futures/order_service.go @@ -664,6 +664,7 @@ func (s *CancelOrderService) Do(ctx context.Context, opts ...RequestOption) (res if s.origClientOrderID != nil { r.setFormParam("origClientOrderId", *s.origClientOrderID) } + data, _, err := s.c.callAPI(ctx, r, opts...) if err != nil { return nil, err diff --git a/v2/futures/position_risk.go b/v2/futures/position_risk.go index a22b9fa4..b9930c68 100644 --- a/v2/futures/position_risk.go +++ b/v2/futures/position_risk.go @@ -7,19 +7,19 @@ import ( ) // GetPositionRiskService get account balance -type GetPositionRiskService struct { +type GetPositionRiskV2Service struct { c *Client symbol string } // Symbol set symbol -func (s *GetPositionRiskService) Symbol(symbol string) *GetPositionRiskService { +func (s *GetPositionRiskV2Service) Symbol(symbol string) *GetPositionRiskV2Service { s.symbol = symbol return s } // Do send request -func (s *GetPositionRiskService) Do(ctx context.Context, opts ...RequestOption) (res []*PositionRisk, err error) { +func (s *GetPositionRiskV2Service) Do(ctx context.Context, opts ...RequestOption) (res []*PositionRiskV2, err error) { r := &request{ method: http.MethodGet, endpoint: "/fapi/v2/positionRisk", @@ -30,18 +30,18 @@ func (s *GetPositionRiskService) Do(ctx context.Context, opts ...RequestOption) } data, _, err := s.c.callAPI(ctx, r, opts...) if err != nil { - return []*PositionRisk{}, err + return []*PositionRiskV2{}, err } - res = make([]*PositionRisk, 0) + res = make([]*PositionRiskV2, 0) err = json.Unmarshal(data, &res) if err != nil { - return []*PositionRisk{}, err + return []*PositionRiskV2{}, err } return res, nil } // PositionRisk define position risk info -type PositionRisk struct { +type PositionRiskV2 struct { EntryPrice string `json:"entryPrice"` BreakEvenPrice string `json:"breakEvenPrice"` MarginType string `json:"marginType"` @@ -58,3 +58,70 @@ type PositionRisk struct { Notional string `json:"notional"` IsolatedWallet string `json:"isolatedWallet"` } + +type GetPositionRiskService struct { + c *Client + symbol string + recvWindow *int64 +} + +// Symbol set symbol +func (s *GetPositionRiskService) Symbol(symbol string) *GetPositionRiskService { + s.symbol = symbol + return s +} + +func (s *GetPositionRiskService) RecvWindow(rw int64) *GetPositionRiskService { + s.recvWindow = &rw + return s +} + +// Do send request +func (s *GetPositionRiskService) Do(ctx context.Context, opts ...RequestOption) (res []*PositionRisk, err error) { + r := &request{ + method: http.MethodGet, + endpoint: "/fapi/v3/positionRisk", + secType: secTypeSigned, + } + if s.symbol != "" { + r.setParam("symbol", s.symbol) + } + if s.recvWindow != nil { + r.recvWindow = *s.recvWindow + } + + data, _, err := s.c.callAPI(ctx, r, opts...) + if err != nil { + return []*PositionRisk{}, err + } + res = make([]*PositionRisk, 0) + err = json.Unmarshal(data, &res) + if err != nil { + return []*PositionRisk{}, err + } + return res, nil +} + +// PositionRisk define position risk info +type PositionRisk struct { + Symbol string `json:"symbol"` + PositionSide string `json:"positionSide"` + PositionAmt string `json:"positionAmt"` + EntryPrice string `json:"entryPrice"` + BreakEvenPrice string `json:"breakEvenPrice"` + MarkPrice string `json:"markPrice"` + UnRealizedProfit string `json:"unRealizedProfit"` + LiquidationPrice string `json:"liquidationPrice"` + IsolatedMargin string `json:"isolatedMargin"` + Notional string `json:"notional"` + MarginAsset string `json:"marginAsset"` + IsolatedWallet string `json:"isolatedWallet"` + InitialMargin string `json:"initialMargin"` + MaintMargin string `json:"maintMargin"` + PositionInitialMargin string `json:"positionInitialMargin"` + OpenOrderInitialMargin string `json:"openOrderInitialMargin"` + Adl int64 `json:"adl"` + BidNotional string `json:"bidNotional"` + AskNotional string `json:"askNotional"` + UpdateTime int64 `json:"updateTime"` +} diff --git a/v2/futures/position_risk_test.go b/v2/futures/position_risk_test.go index 0e3fb611..b607571e 100644 --- a/v2/futures/position_risk_test.go +++ b/v2/futures/position_risk_test.go @@ -14,7 +14,7 @@ func TestPositionRiskTestService(t *testing.T) { suite.Run(t, new(positionRiskServiceTestSuite)) } -func (s *positionRiskServiceTestSuite) TestGetPositionRisk() { +func (s *positionRiskServiceTestSuite) TestGetPositionRiskV2() { data := []byte(`[ { "entryPrice": "10359.38000", @@ -44,12 +44,12 @@ func (s *positionRiskServiceTestSuite) TestGetPositionRisk() { }) s.assertRequestEqual(e, r) }) - res, err := s.client.NewGetPositionRiskService().Symbol(symbol). + res, err := s.client.NewGetPositionRiskV2Service().Symbol(symbol). Do(newContext(), WithRecvWindow(recvWindow)) r := s.r() r.NoError(err) r.Len(res, 1) - e := &PositionRisk{ + e := &PositionRiskV2{ EntryPrice: "10359.38000", BreakEvenPrice: "10387.38000", MarginType: "isolated", @@ -64,10 +64,10 @@ func (s *positionRiskServiceTestSuite) TestGetPositionRisk() { UnRealizedProfit: "-0.03331353", PositionSide: "BOTH", } - s.assertPositionRiskEqual(e, res[0]) + s.assertPositionRiskV2Equal(e, res[0]) } -func (s *positionRiskServiceTestSuite) assertPositionRiskEqual(e, a *PositionRisk) { +func (s *positionRiskServiceTestSuite) assertPositionRiskV2Equal(e, a *PositionRiskV2) { r := s.r() r.Equal(e.EntryPrice, a.EntryPrice, "EntryPrice") r.Equal(e.BreakEvenPrice, a.BreakEvenPrice, "BreakEvenPrice") @@ -83,3 +83,93 @@ func (s *positionRiskServiceTestSuite) assertPositionRiskEqual(e, a *PositionRis r.Equal(e.UnRealizedProfit, a.UnRealizedProfit, "UnRealizedProfit") r.Equal(e.PositionSide, a.PositionSide, "PositionSide") } + +func (s *positionRiskServiceTestSuite) TestGetPositionRisk() { + data := []byte(`[ + { + "symbol": "BTCUSDT", + "positionSide": "BOTH", + "positionAmt": "0.000", + "entryPrice": "0.0", + "breakEvenPrice": "0.0", + "markPrice": "96658.09948227", + "unRealizedProfit": "0.00000000", + "liquidationPrice": "0", + "isolatedMargin": "0", + "notional": "0", + "marginAsset": "USDT", + "isolatedWallet": "0", + "initialMargin": "23.75000000", + "maintMargin": "0", + "positionInitialMargin": "0", + "openOrderInitialMargin": "23.75000000", + "adl": 0, + "bidNotional": "190", + "askNotional": "0", + "updateTime": 0 + } +]`) + s.mockDo(data, nil) + defer s.assertDo() + + symbol := "BTCUSDT" + recvWindow := int64(1000) + s.assertReq(func(r *request) { + e := newSignedRequest().setParams(params{ + "symbol": symbol, + "recvWindow": recvWindow, + }) + s.assertRequestEqual(e, r) + }) + res, err := s.client.NewGetPositionRiskService().Symbol(symbol). + Do(newContext(), WithRecvWindow(recvWindow)) + r := s.r() + r.NoError(err) + r.Len(res, 1) + e := &PositionRisk{ + Symbol: "BTCUSDT", + PositionSide: "BOTH", + PositionAmt: "0.000", + EntryPrice: "0.0", + BreakEvenPrice: "0.0", + MarkPrice: "96658.09948227", + UnRealizedProfit: "0.00000000", + LiquidationPrice: "0", + IsolatedMargin: "0", + Notional: "0", + MarginAsset: "USDT", + IsolatedWallet: "0", + InitialMargin: "23.75000000", + MaintMargin: "0", + PositionInitialMargin: "0", + OpenOrderInitialMargin: "23.75000000", + Adl: 0, + BidNotional: "190", + AskNotional: "0", + UpdateTime: 0, + } + s.assertPositionRiskEqual(e, res[0]) +} + +func (s *positionRiskServiceTestSuite) assertPositionRiskEqual(e, a *PositionRisk) { + r := s.r() + r.Equal(e.Symbol, a.Symbol, "Symbol") + r.Equal(e.PositionSide, a.PositionSide, "PositionSide") + r.Equal(e.PositionAmt, a.PositionAmt, "PositionAmt") + r.Equal(e.EntryPrice, a.EntryPrice, "EntryPrice") + r.Equal(e.BreakEvenPrice, a.BreakEvenPrice, "BreakEvenPrice") + r.Equal(e.MarkPrice, a.MarkPrice, "MarkPrice") + r.Equal(e.UnRealizedProfit, a.UnRealizedProfit, "UnRealizedProfit") + r.Equal(e.LiquidationPrice, a.LiquidationPrice, "LiquidationPrice") + r.Equal(e.IsolatedMargin, a.IsolatedMargin, "IsolatedMargin") + r.Equal(e.Notional, a.Notional, "Notional") + r.Equal(e.MarginAsset, a.MarginAsset, "MarginAsset") + r.Equal(e.IsolatedWallet, a.IsolatedWallet, "IsolatedWallet") + r.Equal(e.InitialMargin, a.InitialMargin, "InitialMargin") + r.Equal(e.MaintMargin, a.MaintMargin, "MaintMargin") + r.Equal(e.PositionInitialMargin, a.PositionInitialMargin, "PositionInitialMargin") + r.Equal(e.Adl, a.Adl, "Adl") + r.Equal(e.BidNotional, a.BidNotional, "BidNotional") + r.Equal(e.AskNotional, a.AskNotional, "AskNotional") + r.Equal(e.UpdateTime, a.UpdateTime, "UpdateTime") +} diff --git a/v2/futures/websocket.go b/v2/futures/websocket.go index b379380f..40dddd52 100644 --- a/v2/futures/websocket.go +++ b/v2/futures/websocket.go @@ -39,7 +39,7 @@ var wsServe = func(cfg *WsConfig, handler WsHandler, errHandler ErrHandler) (don Dialer := websocket.Dialer{ Proxy: proxy, HandshakeTimeout: 45 * time.Second, - EnableCompression: false, + EnableCompression: true, } c, _, err := Dialer.Dial(cfg.Endpoint, nil) diff --git a/v2/futures_algo_service.go b/v2/futures_algo_service.go index 6155f388..d06f0820 100644 --- a/v2/futures_algo_service.go +++ b/v2/futures_algo_service.go @@ -2,6 +2,7 @@ package binance import ( "context" + "encoding/json" "fmt" "net/http" diff --git a/v2/futures_service.go b/v2/futures_service.go index beafaa7b..bc8774cf 100644 --- a/v2/futures_service.go +++ b/v2/futures_service.go @@ -2,6 +2,7 @@ package binance import ( "context" + "encoding/json" "net/http" ) diff --git a/v2/interest_history_service.go b/v2/interest_history_service.go index eada80e5..2c5b49e0 100644 --- a/v2/interest_history_service.go +++ b/v2/interest_history_service.go @@ -2,6 +2,7 @@ package binance import ( "context" + "encoding/json" "net/http" ) diff --git a/v2/internal_universal_transfer_service.go b/v2/internal_universal_transfer_service.go index 9bf3fdf8..4d2f181d 100644 --- a/v2/internal_universal_transfer_service.go +++ b/v2/internal_universal_transfer_service.go @@ -1,6 +1,9 @@ package binance -import "context" +import ( + "context" + "encoding/json" +) // InternalUniversalTransferService Universal Transfer (For Master Account) // https://binance-docs.github.io/apidocs/spot/en/#universal-transfer-for-master-account diff --git a/v2/liquidity_pool_service.go b/v2/liquidity_pool_service.go index 7109c743..8d1d59cb 100644 --- a/v2/liquidity_pool_service.go +++ b/v2/liquidity_pool_service.go @@ -2,6 +2,7 @@ package binance import ( "context" + "encoding/json" "net/http" ) diff --git a/v2/margin_order_service.go b/v2/margin_order_service.go index 086ac9e7..ce36141b 100644 --- a/v2/margin_order_service.go +++ b/v2/margin_order_service.go @@ -2,6 +2,7 @@ package binance import ( "context" + "encoding/json" "net/http" ) diff --git a/v2/margin_service.go b/v2/margin_service.go index 4efa1799..fb36f1d5 100644 --- a/v2/margin_service.go +++ b/v2/margin_service.go @@ -2,6 +2,7 @@ package binance import ( "context" + "encoding/json" "net/http" "strings" ) diff --git a/v2/options/websocket.go b/v2/options/websocket.go index 3071a17b..efdc0309 100644 --- a/v2/options/websocket.go +++ b/v2/options/websocket.go @@ -40,7 +40,7 @@ var wsServe = func(cfg *WsConfig, handler WsHandler, errHandler ErrHandler) (don Dialer := websocket.Dialer{ Proxy: proxy, HandshakeTimeout: 45 * time.Second, - EnableCompression: false, + EnableCompression: true, } c, _, err := Dialer.Dial(cfg.Endpoint, nil) diff --git a/v2/order_service.go b/v2/order_service.go index 4d8a747e..de58e4a0 100644 --- a/v2/order_service.go +++ b/v2/order_service.go @@ -2,6 +2,7 @@ package binance import ( "context" + "encoding/json" stdjson "encoding/json" "net/http" ) diff --git a/v2/order_service_ws_create.go b/v2/order_service_ws_create.go index 30d93eb4..e1e64473 100644 --- a/v2/order_service_ws_create.go +++ b/v2/order_service_ws_create.go @@ -1,6 +1,7 @@ package binance import ( + "encoding/json" "time" "github.com/adshao/go-binance/v2/common" diff --git a/v2/order_service_ws_create_test.go b/v2/order_service_ws_create_test.go index 9a37fbef..b63bc747 100644 --- a/v2/order_service_ws_create_test.go +++ b/v2/order_service_ws_create_test.go @@ -1,6 +1,7 @@ package binance import ( + "encoding/json" "fmt" "testing" diff --git a/v2/pay_service.go b/v2/pay_service.go index dbf1f5a2..e9f832d6 100644 --- a/v2/pay_service.go +++ b/v2/pay_service.go @@ -2,6 +2,7 @@ package binance import ( "context" + "encoding/json" "net/http" ) diff --git a/v2/rate_limit_service.go b/v2/rate_limit_service.go index 9a04ddfd..6fdbf8fe 100644 --- a/v2/rate_limit_service.go +++ b/v2/rate_limit_service.go @@ -2,6 +2,7 @@ package binance import ( "context" + "encoding/json" "net/http" ) diff --git a/v2/rebate.go b/v2/rebate.go index bcb33985..bb0a7978 100644 --- a/v2/rebate.go +++ b/v2/rebate.go @@ -2,6 +2,7 @@ package binance import ( "context" + "encoding/json" "net/http" ) diff --git a/v2/request.go b/v2/request.go index d8b9c556..81580a29 100644 --- a/v2/request.go +++ b/v2/request.go @@ -1,6 +1,7 @@ package binance import ( + "encoding/json" "fmt" "io" "net/http" diff --git a/v2/savings_service.go b/v2/savings_service.go index 3dbe0126..b25da0a0 100644 --- a/v2/savings_service.go +++ b/v2/savings_service.go @@ -2,6 +2,7 @@ package binance import ( "context" + "encoding/json" "net/http" ) diff --git a/v2/simple_earn_service.go b/v2/simple_earn_service.go index 3c997249..c4296ebb 100644 --- a/v2/simple_earn_service.go +++ b/v2/simple_earn_service.go @@ -2,6 +2,7 @@ package binance import ( "context" + "encoding/json" "net/http" ) diff --git a/v2/staking_service.go b/v2/staking_service.go index c3e749e2..81d4bac0 100644 --- a/v2/staking_service.go +++ b/v2/staking_service.go @@ -2,6 +2,7 @@ package binance import ( "context" + "encoding/json" "net/http" ) diff --git a/v2/subaccount_service.go b/v2/subaccount_service.go index 0893fcb5..0300c099 100644 --- a/v2/subaccount_service.go +++ b/v2/subaccount_service.go @@ -2,6 +2,7 @@ package binance import ( "context" + "encoding/json" "net/http" ) diff --git a/v2/ticker_service.go b/v2/ticker_service.go index ba631d8d..bbc55b0e 100644 --- a/v2/ticker_service.go +++ b/v2/ticker_service.go @@ -2,6 +2,7 @@ package binance import ( "context" + "encoding/json" "net/http" "github.com/adshao/go-binance/v2/common" diff --git a/v2/trade_fee_service.go b/v2/trade_fee_service.go index b00ffdcd..9cad9fb0 100644 --- a/v2/trade_fee_service.go +++ b/v2/trade_fee_service.go @@ -2,6 +2,7 @@ package binance import ( "context" + "encoding/json" "net/http" ) diff --git a/v2/trade_service.go b/v2/trade_service.go index ec1381b0..0e975a75 100644 --- a/v2/trade_service.go +++ b/v2/trade_service.go @@ -2,6 +2,7 @@ package binance import ( "context" + "encoding/json" "net/http" ) diff --git a/v2/tradingDayTicker.go b/v2/tradingDayTicker.go index 85c1b5a8..1d7852b3 100644 --- a/v2/tradingDayTicker.go +++ b/v2/tradingDayTicker.go @@ -2,6 +2,7 @@ package binance import ( "context" + "encoding/json" "net/http" diff --git a/v2/user_universal_transfer.go b/v2/user_universal_transfer.go index 5a9cf348..52a3c434 100644 --- a/v2/user_universal_transfer.go +++ b/v2/user_universal_transfer.go @@ -11,6 +11,7 @@ package binance import ( "context" + "encoding/json" "net/http" ) diff --git a/v2/websocket.go b/v2/websocket.go index 26b68d40..96f5a776 100644 --- a/v2/websocket.go +++ b/v2/websocket.go @@ -39,7 +39,7 @@ var wsServe = func(cfg *WsConfig, handler WsHandler, errHandler ErrHandler) (don Dialer := websocket.Dialer{ Proxy: proxy, HandshakeTimeout: 45 * time.Second, - EnableCompression: false, + EnableCompression: true, } c, _, err := Dialer.Dial(cfg.Endpoint, nil) diff --git a/v2/websocket_service.go b/v2/websocket_service.go index 3b215a2e..8ad9e76b 100644 --- a/v2/websocket_service.go +++ b/v2/websocket_service.go @@ -1,6 +1,7 @@ package binance import ( + "encoding/json" stdjson "encoding/json" "fmt" "strings" diff --git a/v2/withdraw_service.go b/v2/withdraw_service.go index 222e9599..3cc79053 100644 --- a/v2/withdraw_service.go +++ b/v2/withdraw_service.go @@ -2,6 +2,7 @@ package binance import ( "context" + "encoding/json" "net/http" )