/
account.go
53 lines (47 loc) · 1.25 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
package binance
import (
"encoding/json"
"log"
"net/url"
binance_struct "github.com/IEatLemons/goUtils/trading/binance/struct"
)
type account struct {
account *binance
apiRestrictions *binance
apiKey string
secretKey string
}
func InitAccount(apiKey, secretKey string, env Environment) *account {
return &account{
account: NewBinance(env, "/api/v3/account"),
apiRestrictions: NewBinance(env, "/sapi/v1/account/apiRestrictions"),
apiKey: apiKey,
secretKey: secretKey,
}
}
func (c *account) Account() (data *binance_struct.AccountInfo, err error) {
result, err := c.account.HmacGet(c.apiKey, c.secretKey, &url.Values{})
if err != nil {
return
}
log.Println("["+c.account.SpotPath+"][result]", string(result))
data = &binance_struct.AccountInfo{}
err = json.Unmarshal(result, data)
if err != nil {
return
}
return
}
func (c *account) ApiRestrictions() (data *binance_struct.ApiRestrictions, err error) {
result, err := c.apiRestrictions.HmacGet(c.apiKey, c.secretKey, &url.Values{})
if err != nil {
return
}
log.Println("["+c.apiRestrictions.SpotPath+"][result]", string(result))
data = &binance_struct.ApiRestrictions{}
err = json.Unmarshal(result, data)
if err != nil {
return
}
return
}