From eaa17caac32850ecc0fb8ca6e034c4e67f605551 Mon Sep 17 00:00:00 2001 From: Felipe Neuwald Date: Tue, 3 Dec 2024 18:54:37 +0000 Subject: [PATCH 1/3] add Symbol.PermissionSets --- v2/exchange_info_service.go | 1 + 1 file changed, 1 insertion(+) diff --git a/v2/exchange_info_service.go b/v2/exchange_info_service.go index 0956c48f..7e0144e2 100644 --- a/v2/exchange_info_service.go +++ b/v2/exchange_info_service.go @@ -102,6 +102,7 @@ type Symbol struct { IsMarginTradingAllowed bool `json:"isMarginTradingAllowed"` Filters []map[string]interface{} `json:"filters"` Permissions []string `json:"permissions"` + PermissionSets [][]string `json:"permissionSets"` } // LotSizeFilter define lot size filter of symbol From f7f01c29ab082b24d2dc9f0628204a16a6a8689a Mon Sep 17 00:00:00 2001 From: Felipe Neuwald Date: Tue, 3 Dec 2024 18:55:51 +0000 Subject: [PATCH 2/3] add ExchangeInfoService.showPermissionSets --- v2/exchange_info_service.go | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/v2/exchange_info_service.go b/v2/exchange_info_service.go index 7e0144e2..de5b7bb3 100644 --- a/v2/exchange_info_service.go +++ b/v2/exchange_info_service.go @@ -9,10 +9,11 @@ import ( // ExchangeInfoService exchange info service type ExchangeInfoService struct { - c *Client - symbol string - symbols []string - permissions []string + c *Client + symbol string + symbols []string + permissions []string + showPermissionSets *bool } // Symbol set symbol @@ -35,6 +36,13 @@ func (s *ExchangeInfoService) Permissions(permissions ...string) *ExchangeInfoSe return s } +// ShowPermissionSets set showPermissionSets +func (s *ExchangeInfoService) ShowPermissionSets(showPermissionSets *bool) *ExchangeInfoService { + s.showPermissionSets = showPermissionSets + + return s +} + // Do send request func (s *ExchangeInfoService) Do(ctx context.Context, opts ...RequestOption) (res *ExchangeInfo, err error) { r := &request{ @@ -52,6 +60,9 @@ func (s *ExchangeInfoService) Do(ctx context.Context, opts ...RequestOption) (re if len(s.permissions) != 0 { m["permissions"] = s.permissions } + if s.showPermissionSets != nil { + m["showPermissionSets"] = *s.showPermissionSets + } r.setParams(m) data, err := s.c.callAPI(ctx, r, opts...) if err != nil { From c1cf0f6bf826b0baa69e46920ea1c8b5b412412c Mon Sep 17 00:00:00 2001 From: Felipe Neuwald Date: Tue, 3 Dec 2024 19:02:39 +0000 Subject: [PATCH 3/3] add TestExchangeInfoWithPermissionSets --- v2/exchange_info_service_test.go | 53 ++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/v2/exchange_info_service_test.go b/v2/exchange_info_service_test.go index 1154a7af..088e7c85 100644 --- a/v2/exchange_info_service_test.go +++ b/v2/exchange_info_service_test.go @@ -218,6 +218,59 @@ func (s *exchangeInfoServiceTestSuite) TestExchangeInfo() { s.assertMaxNumAlgoOrdersFilterEqual(eMaxNumAlgoOrdersFilter, res.Symbols[0].MaxNumAlgoOrdersFilter()) } +func (s *exchangeInfoServiceTestSuite) TestExchangeInfoWithPermissionSets() { + data := []byte(`{ + "timezone":"UTC", + "serverTime":1733252001653, + "rateLimits":[ + { + "rateLimitType":"REQUEST_WEIGHT", + "interval":"MINUTE", + "intervalNum":1, + "limit":6000 + } + ], + "exchangeFilters":[], + "symbols":[ + { + "symbol":"BTCUSDT", + "status":"TRADING", + "baseAsset":"BTC", + "baseAssetPrecision":8, + "quoteAsset":"USDT", + "quotePrecision":8, + "quoteAssetPrecision":8, + "baseCommissionPrecision":8, + "quoteCommissionPrecision":8, + "orderTypes":["LIMIT","LIMIT_MAKER","MARKET","STOP_LOSS","STOP_LOSS_LIMIT","TAKE_PROFIT","TAKE_PROFIT_LIMIT"], + "icebergAllowed":true, + "ocoAllowed":true, + "otoAllowed":true, + "quoteOrderQtyMarketAllowed":true, + "allowTrailingStop":true, + "cancelReplaceAllowed":true, + "isSpotTradingAllowed":true, + "isMarginTradingAllowed":true, + "filters":[ + { + "filterType":"PRICE_FILTER", + "minPrice":"0.01000000", + "maxPrice":"1000000.00000000", + "tickSize":"0.01000000" + } + ], + "permissions":[], + "permissionSets":[["SPOT","MARGIN"]] + } + ] + }`) + s.mockDo(data, nil) + res, err := s.client.NewExchangeInfoService().Symbol("BTCUSDT").Do(newContext()) + s.r().NoError(err) + s.r().Len(res.Symbols[0].PermissionSets, 1) + s.r().Equal([]string{"SPOT", "MARGIN"}, res.Symbols[0].PermissionSets[0]) +} + func (s *exchangeInfoServiceTestSuite) assertExchangeInfoEqual(e, a *ExchangeInfo) { r := s.r()