forked from adshao/go-binance
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaccount_service.go
49 lines (44 loc) · 1.14 KB
/
account_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
package binance
import (
"context"
"encoding/json"
)
// GetAccountService get account info
type GetAccountService struct {
c *Client
}
// Do send request
func (s *GetAccountService) Do(ctx context.Context, opts ...RequestOption) (res *Account, err error) {
r := &request{
method: "GET",
endpoint: "/api/v3/account",
secType: secTypeSigned,
}
data, err := s.c.callAPI(ctx, r, opts...)
if err != nil {
return nil, err
}
res = new(Account)
err = json.Unmarshal(data, res)
if err != nil {
return nil, err
}
return res, nil
}
// Account define account info
type Account struct {
MakerCommission int64 `json:"makerCommission"`
TakerCommission int64 `json:"takerCommission"`
BuyerCommission int64 `json:"buyerCommission"`
SellerCommission int64 `json:"sellerCommission"`
CanTrade bool `json:"canTrade"`
CanWithdraw bool `json:"canWithdraw"`
CanDeposit bool `json:"canDeposit"`
Balances []Balance `json:"balances"`
}
// Balance define user balance of your account
type Balance struct {
Asset string `json:"asset"`
Free string `json:"free"`
Locked string `json:"locked"`
}