Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from codewc/main
Added interface of risk limit level
- Loading branch information
Showing
2 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package kumex | ||
|
||
import ( | ||
"net/http" | ||
) | ||
|
||
// RiskLimitLevelModel represents a Contract risk limit level info. | ||
type RiskLimitLevelModel struct { | ||
Symbol string `json:"symbol"` | ||
Level int64 `json:"level"` | ||
MaxRiskLimit int64 `json:"maxRiskLimit"` | ||
MinRiskLimit int64 `json:"minRiskLimit"` | ||
MaxLeverage int64 `json:"maxLeverage"` | ||
InitialMargin float64 `json:"initialMargin"` | ||
MaintainMargin float64 `json:"maintainMargin"` | ||
} | ||
|
||
// ContractRiskLimitLevelModel represents a Contract risk limit level info. | ||
type ContractsRiskLimitLevelModel []*RiskLimitLevelModel | ||
|
||
// ContractsRiskLimitLevel obtain information about risk limit level of a specific contract | ||
func (as *ApiService) ContractsRiskLimitLevel(symbol string) (*ApiResponse, error) { | ||
req := NewRequest(http.MethodGet, "/api/v1/contracts/risk-limit/"+symbol, nil) | ||
return as.Call(req) | ||
} | ||
|
||
// ContractsRiskLimit adjust contract risk limit level | ||
func (as *ApiService) ChangeRiskLimitLevel(params map[string]string) (*ApiResponse, error) { | ||
req := NewRequest(http.MethodPost, "/api/v1/position/risk-limit-level/change", params) | ||
return as.Call(req) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package kumex | ||
|
||
import "testing" | ||
|
||
func TestApiService_ContractsRiskLimitLevel(t *testing.T) { | ||
s := NewApiServiceFromEnv() | ||
rsp, err := s.ContractsRiskLimitLevel("ADAUSDTM") | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
o := &ContractsRiskLimitLevelModel{} | ||
if err := rsp.ReadData(o); err != nil { | ||
t.Fatal(err) | ||
} | ||
t.Log(ToJsonString(o)) | ||
|
||
} | ||
|
||
func TestApiService_ChangeRiskLimitLevel(t *testing.T) { | ||
s := NewApiServiceFromEnv() | ||
rsp, err := s.ChangeRiskLimitLevel(map[string]string{"symbol": "ADAUSDTM", "level": "2"}) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
var ret bool | ||
if err := rsp.ReadData(&ret); err != nil { | ||
t.Fatal(err) | ||
} | ||
t.Log(ret) | ||
} |