forked from thrasher-corp/gocryptotrader
/
poloniex_types.go
477 lines (430 loc) · 14 KB
/
poloniex_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
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
package poloniex
import (
"encoding/json"
"time"
"github.com/thrasher-corp/gocryptotrader/currency"
)
// Ticker holds ticker data
type Ticker struct {
ID float64 `json:"id"`
Last float64 `json:"last,string"`
LowestAsk float64 `json:"lowestAsk,string"`
HighestBid float64 `json:"highestBid,string"`
PercentChange float64 `json:"percentChange,string"`
BaseVolume float64 `json:"baseVolume,string"`
QuoteVolume float64 `json:"quoteVolume,string"`
High24Hr float64 `json:"high24hr,string"`
Low24Hr float64 `json:"low24hr,string"`
IsFrozen uint8 `json:"isFrozen,string"`
PostOnly uint8 `json:"postOnly,string"`
}
// OrderbookResponseAll holds the full response type orderbook
type OrderbookResponseAll struct {
Data map[string]OrderbookResponse
}
// CompleteBalances holds the full balance data
type CompleteBalances map[string]CompleteBalance
// OrderbookResponse is a sub-type for orderbooks
type OrderbookResponse struct {
Asks [][]interface{} `json:"asks"`
Bids [][]interface{} `json:"bids"`
IsFrozen string `json:"isFrozen"`
Error string `json:"error"`
Seq int64 `json:"seq"`
}
// OrderbookItem holds data on an individual item
type OrderbookItem struct {
Price float64
Amount float64
}
// OrderbookAll contains the full range of orderbooks
type OrderbookAll struct {
Data map[string]Orderbook
}
// Orderbook is a generic type golding orderbook information
type Orderbook struct {
Asks []OrderbookItem `json:"asks"`
Bids []OrderbookItem `json:"bids"`
}
// TradeHistory holds trade history data
type TradeHistory struct {
GlobalTradeID int64 `json:"globalTradeID"`
TradeID int64 `json:"tradeID"`
Date string `json:"date"`
Type string `json:"type"`
Rate float64 `json:"rate,string"`
Amount float64 `json:"amount,string"`
Total float64 `json:"total,string"`
}
// OrderStatus holds order status data
type OrderStatus struct {
Result json.RawMessage `json:"result"`
Success int64 `json:"success"`
}
// OrderStatusData defines order status details
type OrderStatusData struct {
Pair string `json:"currencyPair"`
Rate float64 `json:"rate,string"`
Amount float64 `json:"amount,string"`
Total float64 `json:"total,string"`
StartingAmount float64 `json:"startingAmount,string"`
Type string `json:"type"`
Status string `json:"status"`
Date string `json:"date"`
Fee float64 `json:"fee,string"`
}
// OrderTrade holds order trade data
type OrderTrade struct {
Status string `json:"status"`
GlobalTradeID int64 `json:"globalTradeID"`
TradeID int64 `json:"tradeID"`
CurrencyPair string `json:"currencyPair"`
Type string `json:"type"`
Rate float64 `json:"rate,string"`
Amount float64 `json:"amount,string"`
Total float64 `json:"total,string"`
Fee float64 `json:"fee,string"`
Date string `json:"date"`
}
// ChartData holds kline data
type ChartData struct {
Date int64 `json:"date"`
High float64 `json:"high"`
Low float64 `json:"low"`
Open float64 `json:"open"`
Close float64 `json:"close"`
Volume float64 `json:"volume"`
QuoteVolume float64 `json:"quoteVolume"`
WeightedAverage float64 `json:"weightedAverage"`
Error string `json:"error"`
}
// Currencies contains currency information
type Currencies struct {
ID float64 `json:"id"`
Name string `json:"name"`
HumanType string `json:"humanType"`
CurrencyType string `json:"currencyType"`
TxFee float64 `json:"txFee,string"`
MinConfirmations int64 `json:"minConf"`
DepositAddress string `json:"depositAddress"`
WithdrawalDepositDisabled uint8 `json:"disabled"`
Frozen uint8 `json:"frozen"`
HexColour string `json:"hexColor"`
Blockchain string `json:"blockchain"`
Delisted uint8 `json:"delisted"`
ParentChain string `json:"parentChain"`
IsMultiChain uint8 `json:"isMultiChain"`
IsChildChain uint8 `json:"isChildChain"`
ChildChains []string `json:"childChains"`
IsGeofenced uint8 `json:"isGeofenced"`
}
// LoanOrder holds loan order information
type LoanOrder struct {
Rate float64 `json:"rate,string"`
Amount float64 `json:"amount,string"`
RangeMin int64 `json:"rangeMin"`
RangeMax int64 `json:"rangeMax"`
}
// LoanOrders holds loan order information range
type LoanOrders struct {
Offers []LoanOrder `json:"offers"`
Demands []LoanOrder `json:"demands"`
}
// Balance holds data for a range of currencies
type Balance struct {
Currency map[string]float64
}
// CompleteBalance contains the complete balance with a btcvalue
type CompleteBalance struct {
Available float64 `json:"available,string"`
OnOrders float64 `json:"onOrders,string"`
BTCValue float64 `json:"btcValue,string"`
}
// DepositAddresses holds the full address per crypto-currency
type DepositAddresses struct {
Addresses map[string]string
}
// DepositsWithdrawals holds withdrawal information
type DepositsWithdrawals struct {
Deposits []struct {
Currency string `json:"currency"`
Address string `json:"address"`
Amount float64 `json:"amount,string"`
Confirmations int64 `json:"confirmations"`
TransactionID string `json:"txid"`
Timestamp int64 `json:"timestamp"`
Status string `json:"status"`
} `json:"deposits"`
Withdrawals []struct {
WithdrawalNumber int64 `json:"withdrawalNumber"`
Currency string `json:"currency"`
Address string `json:"address"`
Amount float64 `json:"amount,string"`
Confirmations int64 `json:"confirmations"`
TransactionID string `json:"txid"`
Timestamp int64 `json:"timestamp"`
Status string `json:"status"`
IPAddress string `json:"ipAddress"`
} `json:"withdrawals"`
}
// Order hold order information
type Order struct {
OrderNumber int64 `json:"orderNumber,string"`
Type string `json:"type"`
Rate float64 `json:"rate,string"`
Amount float64 `json:"amount,string"`
Total float64 `json:"total,string"`
Date string `json:"date"`
Margin float64 `json:"margin"`
}
// OpenOrdersResponseAll holds all open order responses
type OpenOrdersResponseAll struct {
Data map[string][]Order
}
// OpenOrdersResponse holds open response orders
type OpenOrdersResponse struct {
Data []Order
}
// AuthenticatedTradeHistory holds client trade history information
type AuthenticatedTradeHistory struct {
GlobalTradeID int64 `json:"globalTradeID"`
TradeID int64 `json:"tradeID,string"`
Date string `json:"date"`
Rate float64 `json:"rate,string"`
Amount float64 `json:"amount,string"`
Total float64 `json:"total,string"`
Fee float64 `json:"fee,string"`
OrderNumber int64 `json:"orderNumber,string"`
Type string `json:"type"`
Category string `json:"category"`
}
// AuthenticatedTradeHistoryAll holds the full client trade history
type AuthenticatedTradeHistoryAll struct {
Data map[string][]AuthenticatedTradeHistory
}
// AuthenticatedTradeHistoryResponse is a response type for trade history
type AuthenticatedTradeHistoryResponse struct {
Data []AuthenticatedTradeHistory
}
// ResultingTrades holds resultant trade information
type ResultingTrades struct {
Amount float64 `json:"amount,string"`
Date string `json:"date"`
Rate float64 `json:"rate,string"`
Total float64 `json:"total,string"`
TradeID int64 `json:"tradeID,string"`
Type string `json:"type"`
}
// OrderResponse is a response type of trades
type OrderResponse struct {
OrderNumber int64 `json:"orderNumber,string"`
Trades []ResultingTrades `json:"resultingTrades"`
}
// GenericResponse is a response type for exchange generic responses
type GenericResponse struct {
Success int64 `json:"success"`
Error string `json:"error"`
}
// MoveOrderResponse is a response type for move order trades
type MoveOrderResponse struct {
Success int64 `json:"success"`
Error string `json:"error"`
OrderNumber int64 `json:"orderNumber,string"`
Trades map[string][]ResultingTrades `json:"resultingTrades"`
}
// Withdraw holds withdraw information
type Withdraw struct {
Response string `json:"response"`
Error string `json:"error"`
}
// Fee holds fees for specific trades
type Fee struct {
MakerFee float64 `json:"makerFee,string"`
TakerFee float64 `json:"takerFee,string"`
ThirtyDayVolume float64 `json:"thirtyDayVolume,string"`
}
// Margin holds margin information
type Margin struct {
TotalValue float64 `json:"totalValue,string"`
ProfitLoss float64 `json:"pl,string"`
LendingFees float64 `json:"lendingFees,string"`
NetValue float64 `json:"netValue,string"`
BorrowedValue float64 `json:"totalBorrowedValue,string"`
CurrentMargin float64 `json:"currentMargin,string"`
}
// MarginPosition holds margin positional information
type MarginPosition struct {
Amount float64 `json:"amount,string"`
Total float64 `json:"total,string"`
BasePrice float64 `json:"basePrice,string"`
LiquidationPrice float64 `json:"liquidationPrice"`
ProfitLoss float64 `json:"pl,string"`
LendingFees float64 `json:"lendingFees,string"`
Type string `json:"type"`
}
// LoanOffer holds loan offer information
type LoanOffer struct {
ID int64 `json:"id"`
Rate float64 `json:"rate,string"`
Amount float64 `json:"amount,string"`
Duration int64 `json:"duration"`
AutoRenew bool `json:"autoRenew"`
Date string `json:"date"`
}
// ActiveLoans shows the full active loans on the exchange
type ActiveLoans struct {
Provided []LoanOffer `json:"provided"`
Used []LoanOffer `json:"used"`
}
// LendingHistory holds the full lending history data
type LendingHistory struct {
ID int64 `json:"id"`
Currency string `json:"currency"`
Rate float64 `json:"rate,string"`
Amount float64 `json:"amount,string"`
Duration float64 `json:"duration,string"`
Interest float64 `json:"interest,string"`
Fee float64 `json:"fee,string"`
Earned float64 `json:"earned,string"`
Open string `json:"open"`
Close string `json:"close"`
}
// WebsocketTicker holds ticker data for the websocket
type WebsocketTicker struct {
CurrencyPair string
Last float64
LowestAsk float64
HighestBid float64
PercentChange float64
BaseVolume float64
QuoteVolume float64
IsFrozen bool
High float64
Low float64
}
// WebsocketTrollboxMessage holds trollbox messages and information for
// websocket
type WebsocketTrollboxMessage struct {
MessageNumber float64
Username string
Message string
Reputation float64
}
// WsCommand defines the request params after a websocket connection has been
// established
type WsCommand struct {
Command string `json:"command"`
Channel interface{} `json:"channel"`
APIKey string `json:"key,omitempty"`
Payload string `json:"payload,omitempty"`
Sign string `json:"sign,omitempty"`
}
// WsTicker defines the websocket ticker response
type WsTicker struct {
LastPrice float64
LowestAsk float64
HighestBid float64
PercentageChange float64
BaseCurrencyVolume24H float64
QuoteCurrencyVolume24H float64
IsFrozen bool
HighestTradeIn24H float64
LowestTradePrice24H float64
}
// WsTrade defines the websocket trade response
type WsTrade struct {
Symbol string
TradeID int64
Side string
Volume float64
Price float64
Timestamp int64
}
// WithdrawalFees the large list of predefined withdrawal fees
// Prone to change, using highest value
var WithdrawalFees = map[currency.Code]float64{
currency.ZRX: 5,
currency.ARDR: 2,
currency.REP: 0.1,
currency.BTC: 0.0005,
currency.BCH: 0.0001,
currency.XBC: 0.0001,
currency.BTCD: 0.01,
currency.BTM: 0.01,
currency.BTS: 5,
currency.BURST: 1,
currency.BCN: 1,
currency.CVC: 1,
currency.CLAM: 0.001,
currency.XCP: 1,
currency.DASH: 0.01,
currency.DCR: 0.1,
currency.DGB: 0.1,
currency.DOGE: 5,
currency.EMC2: 0.01,
currency.EOS: 0,
currency.ETH: 0.01,
currency.ETC: 0.01,
currency.EXP: 0.01,
currency.FCT: 0.01,
currency.GAME: 0.01,
currency.GAS: 0,
currency.GNO: 0.015,
currency.GNT: 1,
currency.GRC: 0.01,
currency.HUC: 0.01,
currency.LBC: 0.05,
currency.LSK: 0.1,
currency.LTC: 0.001,
currency.MAID: 10,
currency.XMR: 0.015,
currency.NMC: 0.01,
currency.NAV: 0.01,
currency.XEM: 15,
currency.NEOS: 0.0001,
currency.NXT: 1,
currency.OMG: 0.3,
currency.OMNI: 0.1,
currency.PASC: 0.01,
currency.PPC: 0.01,
currency.POT: 0.01,
currency.XPM: 0.01,
currency.XRP: 0.15,
currency.SC: 10,
currency.STEEM: 0.01,
currency.SBD: 0.01,
currency.XLM: 0.00001,
currency.STORJ: 1,
currency.STRAT: 0.01,
currency.AMP: 5,
currency.SYS: 0.01,
currency.USDT: 10,
currency.VRC: 0.01,
currency.VTC: 0.001,
currency.VIA: 0.01,
currency.ZEC: 0.001,
}
// WsOrderUpdateResponse Authenticated Ws Account data
type WsOrderUpdateResponse struct {
OrderNumber float64
NewAmount string
}
// WsTradeNotificationResponse Authenticated Ws Account data
type WsTradeNotificationResponse struct {
TradeID float64
Rate float64
Amount float64
FeeMultiplier float64
FundingType float64
OrderNumber float64
TotalFee float64
Date time.Time
}
// WsAuthorisationRequest Authenticated Ws Account data request
type WsAuthorisationRequest struct {
Command string `json:"command"`
Channel int64 `json:"channel"`
Sign string `json:"sign"`
Key string `json:"key"`
Payload string `json:"payload"`
}