forked from bitfinexcom/bitfinex-api-go
/
account.go
95 lines (78 loc) · 1.84 KB
/
account.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
package bitfinex
type AccountService struct {
client *Client
}
type AccountPairFee struct {
Pair string
MakerFees float64 `json:"maker_fees,string"`
TakerFees float64 `json:"taker_fees,string"`
}
type AccountInfo struct {
MakerFees float64 `json:"maker_fees,string"`
TakerFees float64 `json:"taker_fees,string"`
Fees []AccountPairFee
}
// GET account_infos
func (a *AccountService) Info() (AccountInfo, error) {
req, err := a.client.newAuthenticatedRequest("GET", "account_infos", nil)
if err != nil {
return AccountInfo{}, err
}
var v []AccountInfo
_, err = a.client.do(req, &v)
if err != nil {
return AccountInfo{}, err
}
return v[0], nil
}
type KeyPerm struct {
Read bool
Write bool
}
type Permissions struct {
Account KeyPerm
History KeyPerm
Orders KeyPerm
Positions KeyPerm
Funding KeyPerm
Wallets KeyPerm
Withdraw KeyPerm
}
func (a *AccountService) KeyPermission() (Permissions, error) {
req, err := a.client.newAuthenticatedRequest("GET", "key_info", nil)
if err != nil {
return Permissions{}, err
}
var v Permissions
_, err = a.client.do(req, &v)
if err != nil {
return Permissions{}, err
}
return v, nil
}
type SummaryVolume struct {
Currency string `json:"curr"`
Volume string `json:"vol"`
}
type SummaryProfit struct {
Currency string `json:"curr"`
Volume string `json:"amount"`
}
type Summary struct {
TradeVolume SummaryVolume `json:"trade_vol_30d"`
FundingProfit SummaryProfit `json:"funding_profit_30d"`
MakerFee string `json:"maker_fee"`
TakerFee string `json:"taker_fee"`
}
func (a *AccountService) Summary() (Summary, error) {
req, err := a.client.newAuthenticatedRequest("GET", "summary", nil)
if err != nil {
return Summary{}, err
}
var v Summary
_, err = a.client.do(req, &v)
if err != nil {
return Summary{}, err
}
return v, nil
}