-
Notifications
You must be signed in to change notification settings - Fork 2
/
lbank_types.go
274 lines (243 loc) · 8.15 KB
/
lbank_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
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
package lbank
import (
"encoding/json"
"github.com/thrasher-corp/gocryptotrader/currency"
)
// Ticker stores the ticker price data for a currency pair
type Ticker struct {
Change float64 `json:"change"`
High float64 `json:"high"`
Latest float64 `json:"latest"`
Low float64 `json:"low"`
Turnover float64 `json:"turnover"`
Volume float64 `json:"vol"`
}
// TickerResponse stores the ticker price data and timestamp for a currency pair
type TickerResponse struct {
Symbol currency.Pair `json:"symbol"`
Timestamp int64 `json:"timestamp"`
Ticker Ticker `json:"ticker"`
}
// MarketDepthResponse stores arrays for asks, bids and a timestamp for a currecy pair
type MarketDepthResponse struct {
ErrCapture `json:",omitempty"`
Data struct {
Asks [][2]string `json:"asks"`
Bids [][2]string `json:"bids"`
Timestamp int64 `json:"timestamp"`
}
}
// TradeResponse stores date_ms, amount, price, type, tid for a currency pair
type TradeResponse struct {
DateMS int64 `json:"date_ms"`
Amount float64 `json:"amount"`
Price float64 `json:"price"`
Type string `json:"type"`
TID string `json:"tid"`
}
// KlineResponse stores kline info for given currency exchange
type KlineResponse struct {
TimeStamp int64 `json:"timestamp"`
OpenPrice float64 `json:"openprice"`
HigestPrice float64 `json:"highestprice"`
LowestPrice float64 `json:"lowestprice"`
ClosePrice float64 `json:"closeprice"`
TradingVolume float64 `json:"tradingvolume"`
}
// InfoResponse stores info
type InfoResponse struct {
Freeze map[string]string `json:"freeze"`
Asset map[string]string `json:"asset"`
Free map[string]string `json:"Free"`
}
// InfoFinalResponse stores info
type InfoFinalResponse struct {
ErrCapture `json:",omitempty"`
Info InfoResponse `json:"info"`
}
// CreateOrderResponse stores the result of the Order and
type CreateOrderResponse struct {
ErrCapture `json:",omitempty"`
OrderID string `json:"order_id"`
}
// RemoveOrderResponse stores the result when an order is cancelled
type RemoveOrderResponse struct {
ErrCapture `json:",omitempty"`
Err string `json:"error"`
OrderID string `json:"order_id"`
Success string `json:"success"`
}
// OrderResponse stores the data related to the given OrderIDs
type OrderResponse struct {
Symbol string `json:"symbol"`
Amount float64 `json:"amount"`
CreateTime int64 `json:"created_time"`
Price float64 `json:"price"`
AvgPrice float64 `json:"avg_price"`
Type string `json:"type"`
OrderID string `json:"order_id"`
DealAmount float64 `json:"deal_amount"`
Status int64 `json:"status"`
}
// QueryOrderResponse stores the data from queries
type QueryOrderResponse struct {
ErrCapture `json:",omitempty"`
Orders json.RawMessage `json:"orders"`
}
// QueryOrderFinalResponse stores data from queries
type QueryOrderFinalResponse struct {
ErrCapture
Orders []OrderResponse
}
// OrderHistory stores data for past orders
type OrderHistory struct {
Result bool `json:"result,string"`
Total string `json:"total"`
PageLength uint8 `json:"page_length"`
Orders json.RawMessage `json:"orders"`
CurrentPage uint8 `json:"current_page"`
ErrorCode int64 `json:"error_code"`
}
// OrderHistoryResponse stores past orders
type OrderHistoryResponse struct {
ErrCapture `json:",omitempty"`
PageLength uint8 `json:"page_length"`
Orders json.RawMessage `json:"orders"`
CurrentPage uint8 `json:"current_page"`
}
// OrderHistoryFinalResponse stores past orders
type OrderHistoryFinalResponse struct {
ErrCapture
PageLength uint8
Orders []OrderResponse
CurrentPage uint8
}
// PairInfoResponse stores information about trading pairs
type PairInfoResponse struct {
MinimumQuantity string `json:"minTranQua"`
PriceAccuracy string `json:"priceAccuracy"`
QuantityAccuracy string `json:"quantityAccuracy"`
Symbol string `json:"symbol"`
}
// TransactionTemp stores details about transactions
type TransactionTemp struct {
TxUUID string `json:"txUuid"`
OrderUUID string `json:"orderUuid"`
TradeType string `json:"tradeType"`
DealTime int64 `json:"dealTime"`
DealPrice float64 `json:"dealPrice"`
DealQuantity float64 `json:"dealQuantity"`
DealVolPrice float64 `json:"dealVolumePrice"`
TradeFee float64 `json:"tradeFee"`
TradeFeeRate float64 `json:"tradeFeeRate"`
}
// TransactionHistoryResp stores details about past transactions
type TransactionHistoryResp struct {
ErrCapture `json:",omitempty"`
Transaction []TransactionTemp `json:"transaction"`
}
// OpenOrderResponse stores information about the opening orders
type OpenOrderResponse struct {
ErrCapture `json:",omitempty"`
PageLength uint8 `json:"page_length"`
PageNumber uint8 `json:"page_number"`
Total string `json:"total"`
Orders json.RawMessage `json:"orders"`
}
// OpenOrderFinalResponse stores the unmarshalled value of OpenOrderResponse
type OpenOrderFinalResponse struct {
ErrCapture
PageLength uint8
PageNumber uint8
Total string
Orders []OrderResponse
}
// ExchangeRateResponse stores information about USD-RMB rate
type ExchangeRateResponse struct {
USD2CNY string `json:"USD2CNY"`
}
// WithdrawConfigResponse stores info about withdrawal configurations
type WithdrawConfigResponse struct {
AssetCode string `json:"assetCode"`
Minimum string `json:"min"`
CanWithDraw bool `json:"canWithDraw"`
Fee string `json:"fee"`
}
// WithdrawResponse stores info about the withdrawal
type WithdrawResponse struct {
ErrCapture `json:",omitempty"`
WithdrawID string `json:"withdrawId"`
Fee float64 `json:"fee"`
}
// RevokeWithdrawResponse stores info about the revoked withdrawal
type RevokeWithdrawResponse struct {
ErrCapture `json:",omitempty"`
WithdrawID string `json:"string"`
}
// ListDataResponse contains some of withdrawal data
type ListDataResponse struct {
ErrCapture `json:",omitempty"`
Amount float64 `json:"amount"`
AssetCode string `json:"assetCode"`
Address string `json:"address"`
Fee float64 `json:"fee"`
ID int64 `json:"id"`
Time int64 `json:"time"`
TXHash string `json:"txhash"`
Status string `json:"status"`
}
// WithdrawalResponse stores data for withdrawals
type WithdrawalResponse struct {
ErrCapture `json:",omitempty"`
TotalPages int64 `json:"totalPages"`
PageSize int64 `json:"pageSize"`
PageNo int64 `json:"pageNo"`
List []ListDataResponse `json:"list"`
}
// ErrCapture helps with error info
type ErrCapture struct {
Error int64 `json:"error_code"`
Result bool `json:"result,string"`
}
// GetAllOpenIDResp stores orderIds and currency pairs for open orders
type GetAllOpenIDResp struct {
CurrencyPair string
OrderID string
}
var errorCodes = map[int64]string{
10000: "Internal error",
10001: "The required parameters can not be empty",
10002: "Validation Failed",
10003: "Invalid parameter",
10004: "Request too frequent",
10005: "Secret key does not exist",
10006: "User does not exist",
10007: "Invalid signature",
10008: "Invalid Trading Pair",
10009: "Price and/or Amount are required for limit order",
10010: "Price and/or Amount must be more than 0",
10013: "The amount is too small",
10014: "Insufficient amount of money in account",
10015: "Invalid order type",
10016: "Insufficient account balance",
10017: "Server Error",
10018: "Page size should be between 1 and 50",
10019: "Cancel NO more than 3 orders in one request",
10020: "Volume < 0.001",
10021: "Price < 0.01",
10022: "Access denied",
10023: "Market Order is not supported yet.",
10024: "User cannot trade on this pair",
10025: "Order has been filled",
10026: "Order has been cancelld",
10027: "Order is cancelling",
10028: "Wrong query time",
10029: "'from' is not in the query time",
10030: "'from' does not match the transaction type of inqury",
10100: "Has no privilege to withdraw",
10101: "Invalid fee rate to withdraw",
10102: "Too little to withdraw",
10103: "Exceed daily limitation of withdraw",
10104: "Cancel was rejected",
10105: "Request has been cancelled",
}