forked from thrasher-corp/gocryptotrader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
huobihadax_types.go
225 lines (200 loc) · 7.78 KB
/
huobihadax_types.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
package huobihadax
// Response stores the Huobi response information
type Response struct {
Status string `json:"status"`
Channel string `json:"ch"`
Timestamp int64 `json:"ts"`
ErrorCode string `json:"err-code"`
ErrorMessage string `json:"err-msg"`
}
// KlineItem stores a kline item
type KlineItem struct {
ID int64 `json:"id"`
Open float64 `json:"open"`
Close float64 `json:"close"`
Low float64 `json:"low"`
High float64 `json:"high"`
Amount float64 `json:"amount"`
Vol float64 `json:"vol"`
Count int `json:"count"`
}
// DetailMerged stores the ticker detail merged data
type DetailMerged struct {
Detail
Version int `json:"version"`
Ask []float64 `json:"ask"`
Bid []float64 `json:"bid"`
}
// Orderbook stores the orderbook data
type Orderbook struct {
ID int64 `json:"id"`
Timetstamp int64 `json:"ts"`
Bids [][]float64 `json:"bids"`
Asks [][]float64 `json:"asks"`
}
// Trade stores the trade data
type Trade struct {
ID float64 `json:"id"`
Price float64 `json:"price"`
Amount float64 `json:"amount"`
Direction string `json:"direction"`
Timestamp int64 `json:"ts"`
}
// TradeHistory stores the the trade history data
type TradeHistory struct {
ID int64 `json:"id"`
Timestamp int64 `json:"ts"`
Trades []Trade `json:"data"`
}
// Detail stores the ticker detail data
type Detail struct {
Amount float64 `json:"amount"`
Open float64 `json:"open"`
Close float64 `json:"close"`
High float64 `json:"high"`
Timestamp int64 `json:"timestamp"`
ID int `json:"id"`
Count int `json:"count"`
Low float64 `json:"low"`
Volume float64 `json:"vol"`
}
// Symbol stores the symbol data
type Symbol struct {
BaseCurrency string `json:"base-currency"`
QuoteCurrency string `json:"quote-currency"`
PricePrecision int `json:"price-precision"`
AmountPrecision int `json:"amount-precision"`
SymbolPartition string `json:"symbol-partition"`
}
// Account stores the account data
type Account struct {
ID int64 `json:"id"`
Type string `json:"type"`
State string `json:"working"`
UserID int64 `json:"user-id"`
}
// AccountBalance stores the user all account balance
type AccountBalance struct {
ID int64 `json:"id"`
Type string `json:"type"`
State string `json:"state"`
AccountBalanceDetails []AccountBalanceDetail `json:"list"`
}
// AccountBalanceDetail stores the user account balance
type AccountBalanceDetail struct {
Currency string `json:"currency"`
Type string `json:"type"`
Balance float64 `json:"balance,string"`
}
// CancelOrderBatch stores the cancel order batch data
type CancelOrderBatch struct {
Success []string `json:"success"`
Failed []struct {
OrderID int64 `json:"order-id,string"`
ErrorCode string `json:"err-code"`
ErrorMessage string `json:"err-msg"`
} `json:"failed"`
}
// OrderInfo stores the order info
type OrderInfo struct {
ID int `json:"id"`
Symbol string `json:"symbol"`
AccountID int `json:"account-id"`
Amount string `json:"amount"`
Price string `json:"price"`
CreatedAt int64 `json:"created-at"`
Type string `json:"type"`
FieldAmount string `json:"field-amount"`
FieldCashAmount string `json:"field-cash-amount"`
FieldFees string `json:"field-fees"`
FinishedAt int64 `json:"finished-at"`
UserID int `json:"user-id"`
Source string `json:"source"`
State string `json:"state"`
CanceledAt int `json:"canceled-at"`
Exchange string `json:"exchange"`
Batch string `json:"batch"`
}
// OrderMatchInfo stores the order match info
type OrderMatchInfo struct {
ID int `json:"id"`
OrderID int `json:"order-id"`
MatchID int `json:"match-id"`
Symbol string `json:"symbol"`
Type string `json:"type"`
Source string `json:"source"`
Price string `json:"price"`
FilledAmount string `json:"filled-amount"`
FilledFees string `json:"filled-fees"`
CreatedAt int64 `json:"created-at"`
}
// MarginOrder stores the margin order info
type MarginOrder struct {
Currency string `json:"currency"`
Symbol string `json:"symbol"`
AccruedAt int64 `json:"accrued-at"`
LoanAmount string `json:"loan-amount"`
LoanBalance string `json:"loan-balance"`
InterestBalance string `json:"interest-balance"`
CreatedAt int64 `json:"created-at"`
InterestAmount string `json:"interest-amount"`
InterestRate string `json:"interest-rate"`
AccountID int `json:"account-id"`
UserID int `json:"user-id"`
UpdatedAt int64 `json:"updated-at"`
ID int `json:"id"`
State string `json:"state"`
}
// MarginAccountBalance stores the margin account balance info
type MarginAccountBalance struct {
ID int `json:"id"`
Type string `json:"type"`
State string `json:"state"`
Symbol string `json:"symbol"`
FlPrice string `json:"fl-price"`
FlType string `json:"fl-type"`
RiskRate string `json:"risk-rate"`
List []AccountBalance `json:"list"`
}
// SpotNewOrderRequestParams holds the params required to place
// an order
type SpotNewOrderRequestParams struct {
AccountID int `json:"account-id"` // Account ID, obtained using the accounts method. Curency trades use the accountid of the ‘spot’ account; for loan asset transactions, please use the accountid of the ‘margin’ account.
Amount float64 `json:"amount"` // The limit price indicates the quantity of the order, the market price indicates how much to buy when the order is paid, and the market price indicates how much the coin is sold when the order is sold.
Price float64 `json:"price"` // Order price, market price does not use this parameter
Source string `json:"source"` // Order source, api: API call, margin-api: loan asset transaction
Symbol string `json:"symbol"` // The symbol to use; example btcusdt, bccbtc......
Type SpotNewOrderRequestParamsType `json:"type"` // Order type as listed below (buy-market, sell-market etc)
}
// SpotNewOrderRequestParamsType order types
type SpotNewOrderRequestParamsType string
var (
// SpotNewOrderRequestTypeBuyMarket buy market order
SpotNewOrderRequestTypeBuyMarket = SpotNewOrderRequestParamsType("buy-market")
// SpotNewOrderRequestTypeSellMarket sell market order
SpotNewOrderRequestTypeSellMarket = SpotNewOrderRequestParamsType("sell-market")
// SpotNewOrderRequestTypeBuyLimit buy limit order
SpotNewOrderRequestTypeBuyLimit = SpotNewOrderRequestParamsType("buy-limit")
// SpotNewOrderRequestTypeSellLimit sell limit order
SpotNewOrderRequestTypeSellLimit = SpotNewOrderRequestParamsType("sell-limit")
)
// KlinesRequestParams represents Klines request data.
type KlinesRequestParams struct {
Symbol string // Symbol; btcusdt, bccbtc......
Period TimeInterval // Kline data time interval; 1min, 5min, 15min......
Size int // Size [1-2000]
}
// TimeInterval base value
type TimeInterval string
// TimeInterval vars
var (
TimeIntervalMinute = TimeInterval("1min")
TimeIntervalFiveMinutes = TimeInterval("5min")
TimeIntervalFifteenMinutes = TimeInterval("15min")
TimeIntervalThirtyMinutes = TimeInterval("30min")
TimeIntervalHour = TimeInterval("60min")
TimeIntervalDay = TimeInterval("1day")
TimeIntervalWeek = TimeInterval("1week")
TimeIntervalMohth = TimeInterval("1mon")
TimeIntervalYear = TimeInterval("1year")
)