Skip to content
This repository has been archived by the owner on Dec 11, 2024. It is now read-only.

Commit

Permalink
Merge pull request #115 from codewc/master
Browse files Browse the repository at this point in the history
add /api/v1/risk/limit/strategy endpoint
  • Loading branch information
codewc authored Feb 15, 2022
2 parents 3d9e646 + 172935a commit e73c914
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
21 changes: 21 additions & 0 deletions margin.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,3 +354,24 @@ func (as *ApiService) MarginTradeLast(currency string) (*ApiResponse, error) {
req := NewRequest(http.MethodGet, "/api/v1/margin/trade/last", params)
return as.Call(req)
}

// MarginRiskLimitItemModel is item of *MarginRiskLimitModel
type MarginRiskLimitItemModel struct {
Currency string `json:"currency"`
BorrowMaxAmount string `json:"borrowMaxAmount"`
BuyMaxAmount string `json:"buyMaxAmount"`
Precision json.Number `json:"precision"`
}

// MarginRiskLimitModel is a list of *MarginRiskLimitModel
type MarginRiskLimitModel []*MarginRiskLimitItemModel

func (as *ApiService) MarginRiskLimit(marginModel string) (*ApiResponse, error) {
params := map[string]string{}
if marginModel != "" {
params["marginModel"] = marginModel
}

req := NewRequest(http.MethodGet, "/api/v1/risk/limit/strategy", params)
return as.Call(req)
}
16 changes: 15 additions & 1 deletion margin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func TestApiService_CreateBorrowOrder(t *testing.T) {
params := map[string]string{"currency": "BTC", "type": "IOC", "size": "0.003"}
rsp, err := s.CreateBorrowOrder(params)

if err != err {
if err != nil {
t.Fatal(err)
}

Expand Down Expand Up @@ -590,3 +590,17 @@ func TestApiService_MarginTradeLast(t *testing.T) {
}
}
}

func TestApiService_MarginRiskLimit(t *testing.T) {
s := NewApiServiceFromEnv()
rsp, err := s.MarginRiskLimit("cross")
if err != nil {
t.Fatal(err)
}

os := &MarginRiskLimitModel{}
if err := rsp.ReadData(os); err != nil {
t.Fatal(err)
}
t.Log(ToJsonString(os))
}

0 comments on commit e73c914

Please sign in to comment.