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

feat: Add permissionSets field to exchange info response #641

Merged
merged 3 commits into from
Dec 4, 2024
Merged
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
20 changes: 16 additions & 4 deletions v2/exchange_info_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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{
Expand All @@ -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 {
Expand Down Expand Up @@ -102,6 +113,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
Expand Down
53 changes: 53 additions & 0 deletions v2/exchange_info_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
Loading