forked from adshao/go-binance
/
position_risk.go
59 lines (54 loc) · 1.55 KB
/
position_risk.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package futures
import (
"context"
"encoding/json"
"net/http"
)
// GetPositionRiskService get account balance
type GetPositionRiskService struct {
c *Client
symbol string
}
// Symbol set symbol
func (s *GetPositionRiskService) Symbol(symbol string) *GetPositionRiskService {
s.symbol = symbol
return s
}
// Do send request
func (s *GetPositionRiskService) Do(ctx context.Context, opts ...RequestOption) (res []*PositionRisk, err error) {
r := &request{
method: http.MethodGet,
endpoint: "/fapi/v2/positionRisk",
secType: secTypeSigned,
}
if s.symbol != "" {
r.setParam("symbol", s.symbol)
}
data, _, err := s.c.callAPI(ctx, r, opts...)
if err != nil {
return []*PositionRisk{}, err
}
res = make([]*PositionRisk, 0)
err = json.Unmarshal(data, &res)
if err != nil {
return []*PositionRisk{}, err
}
return res, nil
}
// PositionRisk define position risk info
type PositionRisk struct {
EntryPrice string `json:"entryPrice"`
MarginType string `json:"marginType"`
IsAutoAddMargin string `json:"isAutoAddMargin"`
IsolatedMargin string `json:"isolatedMargin"`
Leverage string `json:"leverage"`
LiquidationPrice string `json:"liquidationPrice"`
MarkPrice string `json:"markPrice"`
MaxNotionalValue string `json:"maxNotionalValue"`
PositionAmt string `json:"positionAmt"`
Symbol string `json:"symbol"`
UnRealizedProfit string `json:"unRealizedProfit"`
PositionSide string `json:"positionSide"`
Notional string `json:"notional"`
IsolatedWallet string `json:"isolatedWallet"`
}