-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfunding_service.go
64 lines (55 loc) · 1.57 KB
/
funding_service.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
package binance
import (
"context"
"github.com/crypto-zero/go-binance/v2/common"
)
// GetFundingAssetService fetches all asset detail.
//
// See https://binance-docs.github.io/apidocs/spot/en/#user_data-16
type GetFundingAssetService struct {
c *Client
asset *string
needBtcValuation *bool
}
// Asset set the asset parameter.
func (s *GetFundingAssetService) Asset(asset string) *GetFundingAssetService {
s.asset = &asset
return s
}
// NeedBTCValuation set the needBtcValuation parameter.
func (s *GetFundingAssetService) NeedBTCValuation(needBtcValuation bool) *GetFundingAssetService {
s.needBtcValuation = &needBtcValuation
return s
}
// Do send the Request.
func (s *GetFundingAssetService) Do(ctx context.Context) (out map[string]FundingAsset, err error) {
r := common.NewPostRequestSigned("/sapi/v1/asset/get-funding-asset")
if s.asset != nil {
r.SetForm("asset", *s.asset)
}
if s.needBtcValuation != nil {
val := "true"
if !*s.needBtcValuation {
val = "false"
}
r.SetForm("needBtcValuation", val)
}
var rsp []FundingAsset
if err = s.c.CallAPI(ctx, r, &rsp); err != nil {
return
}
out = make(map[string]FundingAsset)
for _, x := range rsp {
out[x.Asset] = x
}
return out, nil
}
// FundingAsset represents the detail of an asset
type FundingAsset struct {
Asset string `json:"asset"`
Free float64 `json:"free,string"`
Locked float64 `json:"locked,string"`
Freeze float64 `json:"freeze,string"`
Withdrawing float64 `json:"withdrawing,string"`
BTCValuation float64 `json:"btcValuation,string"`
}