forked from binance/binance-connector-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrest_api_other.go
78 lines (68 loc) · 1.71 KB
/
rest_api_other.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package binance_connector
import (
"context"
"encoding/json"
"net/http"
)
func (c *Client) NewGetCurrentPositionMode() *GetGetCurrentPositionMode {
return &GetGetCurrentPositionMode{c: c}
}
const (
getCurrentPositionMode = "/fapi/v1/positionSide/dual"
changeCurrentPositionMode = "/fapi/v1/positionSide/dual"
)
type GetGetCurrentPositionMode struct {
c *Client
}
type GetGetCurrentPositionModeResp struct {
DualSidePosition bool `json:"dualSidePosition"`
}
func (s *GetGetCurrentPositionMode) Do(ctx context.Context, opts ...RequestOption) (res *GetGetCurrentPositionModeResp, err error) {
r := &request{
method: http.MethodGet,
endpoint: getCurrentPositionMode,
secType: secTypeSigned,
}
data, err := s.c.callAPI(ctx, r, opts...)
if err != nil {
return nil, err
}
res = new(GetGetCurrentPositionModeResp)
err = json.Unmarshal(data, res)
if err != nil {
return nil, err
}
return res, nil
}
type ChangePositionMode struct {
c *Client
}
func (c *Client) NewChangePositionMode() *ChangePositionMode {
return &ChangePositionMode{c: c}
}
type ChangePositionModeResp struct {
Code int `json:"code"`
Msg string `json:"msg"`
}
func (s *ChangePositionMode) Do(ctx context.Context, dualSidePosition bool, opts ...RequestOption) (res *ChangePositionModeResp, err error) {
r := &request{
method: http.MethodPost,
endpoint: changeCurrentPositionMode,
secType: secTypeSigned,
}
if dualSidePosition {
r.setParam("dualSidePosition", "true")
} else {
r.setParam("dualSidePosition", "false")
}
data, err := s.c.callAPI(ctx, r, opts...)
if err != nil {
return nil, err
}
res = new(ChangePositionModeResp)
err = json.Unmarshal(data, res)
if err != nil {
return nil, err
}
return res, nil
}