Skip to content

Commit

Permalink
Add isolatedSymbol parameter to GetMaxBorrowableService (#231)
Browse files Browse the repository at this point in the history
* Add isolatedSymbol parameter to GetMaxBorrowableService

The isolatedSymbol parameter is required to get max borrow amount
of an isolated margin account.

* Check if isolatedSymbol is set before adding to request param.

Co-authored-by: Jérémy Pansier <jeremypansier@gmail.com>

Co-authored-by: Jérémy Pansier <jeremypansier@gmail.com>
  • Loading branch information
beansgum and JeremyPansier committed Dec 16, 2021
1 parent db2e228 commit a6d7dc3
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions v2/margin_service.go
Expand Up @@ -729,8 +729,9 @@ func (s *ListMarginTradesService) Do(ctx context.Context, opts ...RequestOption)

// GetMaxBorrowableService get max borrowable of asset
type GetMaxBorrowableService struct {
c *Client
asset string
c *Client
asset string
isolatedSymbol string
}

// Asset set asset
Expand All @@ -739,6 +740,12 @@ func (s *GetMaxBorrowableService) Asset(asset string) *GetMaxBorrowableService {
return s
}

// IsolatedSymbol set isolatedSymbol
func (s *GetMaxBorrowableService) IsolatedSymbol(isolatedSymbol string) *GetMaxBorrowableService {
s.isolatedSymbol = isolatedSymbol
return s
}

// Do send request
func (s *GetMaxBorrowableService) Do(ctx context.Context, opts ...RequestOption) (res *MaxBorrowable, err error) {
r := &request{
Expand All @@ -747,6 +754,9 @@ func (s *GetMaxBorrowableService) Do(ctx context.Context, opts ...RequestOption)
secType: secTypeSigned,
}
r.setParam("asset", s.asset)
if s.isolatedSymbol != "" {
r.setParam("isolatedSymbol", s.isolatedSymbol)
}
data, err := s.c.callAPI(ctx, r, opts...)
if err != nil {
return nil, err
Expand Down

0 comments on commit a6d7dc3

Please sign in to comment.