forked from luno/luno-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.go
574 lines (436 loc) · 17 KB
/
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
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
package luno
import "github.com/luno/luno-go/decimal"
type AccountBalance struct {
// ID of the account.
AccountId string `json:"account_id"`
// Currency code for the asset held in this account.
Asset string `json:"asset"`
// The amount available to send or trade.
Balance decimal.Decimal `json:"balance"`
// The name set by the user upon creating the account.
Name string `json:"name"`
// Amount locked by Luno and cannot be sent or traded. This could be due to
// open orders.
Reserved decimal.Decimal `json:"reserved"`
// Amount that is awaiting some sort of verification to be credited to this
// account. This could be an on-chain transaction that Luno is waiting for
// further block verifications to happen.
Unconfirmed decimal.Decimal `json:"unconfirmed"`
}
type AddressMeta struct {
Label string `json:"label"`
Value string `json:"value"`
}
type Candle struct {
// Closing price
Close decimal.Decimal `json:"close"`
// High price
High decimal.Decimal `json:"high"`
// Low price
Low decimal.Decimal `json:"low"`
// Opening price
Open decimal.Decimal `json:"open"`
// Unix timestamp in milliseconds
Timestamp Time `json:"timestamp"`
// Volume traded
Volume decimal.Decimal `json:"volume"`
}
type CryptoDetails struct {
Address string `json:"address"`
Txid string `json:"txid"`
}
type DetailFields struct {
CryptoDetails CryptoDetails `json:"crypto_details"`
TradeDetails TradeDetails `json:"trade_details"`
}
type FundsMove struct {
// The assets quantity to move from the debit account to credit account. This is always a positive value.
Amount decimal.Decimal `json:"amount"`
// User defined unique ID
ClientMoveId string `json:"client_move_id"`
// Unix time the move was initiated, in milliseconds
CreatedAt Time `json:"created_at"`
// The account to credit the funds to.
CreditAccountId string `json:"credit_account_id"`
// The account to debit the funds from.
DebitAccountId string `json:"debit_account_id"`
// Unique ID, defined by Luno
Id string `json:"id"`
// Current status of the move.
//
// Status meaning:<br>
// <code>CREATED</code> The move is awaiting execution.<br>
// <code>MOVING</code> The funds have been reserved and the move is being executed.<br>
// <code>SUCCESSFUL</code> The move has completed successfully and should be reflected in both accounts available
// balance.<br>
// <code>FAILED</code> The move has failed. There could be many reasons for this but the most likely is that the
// debit account doesn't have enough available funds to move.<br>
Status Status `json:"status"`
// Unix time the move was last updated, in milliseconds
UpdatedAt Time `json:"updated_at"`
}
type Kind string
const (
KindExchange Kind = "EXCHANGE"
KindFee Kind = "FEE"
KindInterest Kind = "INTEREST"
KindTransfer Kind = "TRANSFER"
)
type MarketInfo struct {
// Base currency code
BaseCurrency string `json:"base_currency"`
// Counter currency code
CounterCurrency string `json:"counter_currency"`
// Fee decimal places
FeeScale int64 `json:"fee_scale"`
// Unique identifier for the market
MarketId string `json:"market_id"`
// Maximum order price
MaxPrice decimal.Decimal `json:"max_price"`
// Maximum order volume
MaxVolume decimal.Decimal `json:"max_volume"`
// Minimum order price
MinPrice decimal.Decimal `json:"min_price"`
// Minimum order volume
MinVolume decimal.Decimal `json:"min_volume"`
// Price decimal places
PriceScale int64 `json:"price_scale"`
// Current market trading status:<br>
// <code>POST_ONLY</code> Trading is indefinitely suspended. This state is
// commonly used when new markets are being launched to give traders enough
// time to setup their orders before trading begins. When in this status,
// orders can only be posted as post-only.<br>
// <code>ACTIVE</code> Trading is fully enabled.<br>
// <code>SUSPENDED</code> Trading has been temporarily suspended due to very
// high volatility. When in this status, orders can only be posted as
// post-only.<br>
TradingStatus TradingStatus `json:"trading_status"`
// Volume decimal places
VolumeScale int64 `json:"volume_scale"`
}
type Order struct {
// Amount of base filled, this value is always positive.
Base decimal.Decimal `json:"base"`
// Time of order completion (Unix milliseconds)
//
// This value is set at the time of this order leaving the order book,
// either immediately upon posting or later on due to a trade or cancellation.
// Whilst the order is still pending/live it will be 0.
CompletedTimestamp Time `json:"completed_timestamp"`
// Amount of counter filled, this value is always positive.
Counter decimal.Decimal `json:"counter"`
// Time of order creation (Unix milliseconds)
CreationTimestamp Time `json:"creation_timestamp"`
// Time of order expiration (Unix milliseconds)
//
// This value is set at the time of processing a request from you to cancel the order, otherwise it will be 0.
ExpirationTimestamp Time `json:"expiration_timestamp"`
// Base amount of fees to be charged
FeeBase decimal.Decimal `json:"fee_base"`
// Counter amount of fees to be charged
FeeCounter decimal.Decimal `json:"fee_counter"`
// Limit price to transact
LimitPrice decimal.Decimal `json:"limit_price"`
// Limit volume to transact
LimitVolume decimal.Decimal `json:"limit_volume"`
OrderId string `json:"order_id"`
// Specifies the market.
Pair string `json:"pair"`
// <code>PENDING</code> The order has been placed. Some trades may have
// taken place but the order is not filled yet.<br>
// <code>COMPLETE</code> The order is no longer active. It has been settled
// or has been cancelled.
State OrderState `json:"state"`
// The Time in force option used when the LimitOrder was posted.
//
// Only returned on limit orders.<br>
// <code>GTC</code> Good 'Til Cancelled. The order remains open until it is filled or cancelled by the user. (default)</br>
// <code>IOC</code> Immediate Or Cancel. The part of the order that cannot be filled immediately will be cancelled. Cannot be post-only.</br>
// <code>FOK</code> Fill Or Kill. If the order cannot be filled immediately and completely it will be cancelled before any trade. Cannot be post-only.
TimeInForce string `json:"time_in_force"`
// <code>BUY</code> buy market order.<br>
// <code>SELL</code> sell market order.<br>
// <code>BID</code> bid (buy) limit order.<br>
// <code>ASK</code> ask (sell) limit order.
Type OrderType `json:"type"`
}
type OrderBookEntry struct {
// ID is the unique identifier of the order
ID string `json:"id"`
// Limit price at which orders are trading at
Price decimal.Decimal `json:"price"`
// The volume available at the limit price
Volume decimal.Decimal `json:"volume"`
}
type OrderState string
const (
OrderStateComplete OrderState = "COMPLETE"
OrderStatePending OrderState = "PENDING"
)
type OrderType string
const (
OrderTypeAsk OrderType = "ASK"
OrderTypeBid OrderType = "BID"
OrderTypeBuy OrderType = "BUY"
OrderTypeSell OrderType = "SELL"
)
type OrderV2 struct {
// Amount of base filled, this value is always positive.
//
// Use this field and `side` to determine credit or debit of funds.
Base decimal.Decimal `json:"base"`
// Client Order ID has the value that was passed in when the Order was posted.
ClientOrderId string `json:"client_order_id"`
// Time of order completion (Unix milliseconds)
//
// This value is set at the time of this order leaving the order book,
// either immediately upon posting or later on due to a trade or cancellation.
// Whilst the order is still pending/live it will be 0.
CompletedTimestamp Time `json:"completed_timestamp"`
// Amount of counter filled, this value is always positive.
//
// Use this field and `side` to determine credit or debit of funds.
Counter decimal.Decimal `json:"counter"`
// Time of order creation (Unix milliseconds)
CreationTimestamp Time `json:"creation_timestamp"`
// Time of order expiration (Unix milliseconds)
//
// This value is set at the time of processing a request from you to cancel the order, otherwise it will be 0.
ExpirationTimestamp Time `json:"expiration_timestamp"`
// Base amount of fees to be charged
FeeBase decimal.Decimal `json:"fee_base"`
// Counter amount of fees to be charged
FeeCounter decimal.Decimal `json:"fee_counter"`
// Limit price to transact
LimitPrice decimal.Decimal `json:"limit_price"`
// Limit volume to transact
LimitVolume decimal.Decimal `json:"limit_volume"`
// The order reference
OrderId string `json:"order_id"`
// Specifies the market
Pair string `json:"pair"`
// The intention of the order, whether to buy or sell funds in the market.
//
// You can use this to determine the flow of funds in the order.
Side Side `json:"side"`
// The current state of the order
//
// Status meaning:<br>
// <code>AWAITING</code> The order is awaiting to enter the order book.<br>
// <code>PENDING</code> The order is in the order book. Some trades may
// have taken place but the order is not filled yet.<br>
// <code>COMPLETE</code> The order is no longer in the order book. It has
// been settled/filled or has been cancelled.
Status Status `json:"status"`
// Direction to trigger the order
StopDirection StopDirection `json:"stop_direction"`
// Price to trigger the order
StopPrice decimal.Decimal `json:"stop_price"`
// The Time in force option used when the LimitOrder was posted.
//
// Only returned on limit orders.<br>
// <code>GTC</code> Good 'Til Cancelled. The order remains open until it is filled or cancelled by the user. (default)</br>
// <code>IOC</code> Immediate Or Cancel. The part of the order that cannot be filled immediately will be cancelled. Cannot be post-only.</br>
// <code>FOK</code> Fill Or Kill. If the order cannot be filled immediately and completely it will be cancelled before any trade. Cannot be post-only.
TimeInForce string `json:"time_in_force"`
// The order type
Type Type `json:"type"`
}
type PublicTrade struct {
// Whether the taker was buying or not.
IsBuy bool `json:"is_buy"`
// Price at which the asset traded at
Price decimal.Decimal `json:"price"`
// The ever incrementing trade identifier within a market
Sequence int64 `json:"sequence"`
// Unix timestamp in milliseconds
Timestamp Time `json:"timestamp"`
// Amount of assets traded
Volume decimal.Decimal `json:"volume"`
}
type Side string
const (
SideBuy Side = "BUY"
SideSell Side = "SELL"
)
type Status string
const (
StatusActive Status = "ACTIVE"
StatusAwaiting Status = "AWAITING"
StatusCancelled Status = "CANCELLED"
StatusCancelling Status = "CANCELLING"
StatusComplete Status = "COMPLETE"
StatusCompleted Status = "COMPLETED"
StatusCreated Status = "CREATED"
StatusDisabled Status = "DISABLED"
StatusFailed Status = "FAILED"
StatusMoving Status = "MOVING"
StatusPending Status = "PENDING"
StatusPostonly Status = "POSTONLY"
StatusProcessing Status = "PROCESSING"
StatusSuccessful Status = "SUCCESSFUL"
StatusUnknown Status = "UNKNOWN"
StatusWaiting Status = "WAITING"
)
type StopDirection string
const (
StopDirectionAbove StopDirection = "ABOVE"
StopDirectionBelow StopDirection = "BELOW"
StopDirectionRelative_last_trade StopDirection = "RELATIVE_LAST_TRADE"
)
type Ticker struct {
// The lowest ask price
Ask decimal.Decimal `json:"ask"`
// The highest bid price
Bid decimal.Decimal `json:"bid"`
// Last trade price
LastTrade decimal.Decimal `json:"last_trade"`
Pair string `json:"pair"`
// 24h rolling trade volume
Rolling24HourVolume decimal.Decimal `json:"rolling_24_hour_volume"`
// Market current status
//
// <code>ACTIVE</code> when the market is trading normally
//
// <code>POSTONLY</code> when the market has been suspended and only post-only orders will be accepted
//
// <code>DISABLED</code> when the market is shutdown and no orders can be accepted
Status Status `json:"status"`
// Unix timestamp in milliseconds of the tick
Timestamp Time `json:"timestamp"`
}
type TimeInForce string
const (
TimeInForceGtc TimeInForce = "GTC"
TimeInForceIoc TimeInForce = "IOC"
TimeInForceFok TimeInForce = "FOK"
)
type TradeDetails struct {
// Pair of the market
Pair string `json:"pair"`
// Price at which the volume traded for
Price decimal.Decimal `json:"price"`
// Sequence identifies the trade within a market
Sequence int64 `json:"sequence"`
// Volume is the amount of base traded
Volume decimal.Decimal `json:"volume"`
}
type TradeV2 struct {
// Amount of base filled
Base decimal.Decimal `json:"base"`
// Client Order ID has the value that was passed in when the Order was posted.
ClientOrderId string `json:"client_order_id"`
// Amount of counter filled
Counter decimal.Decimal `json:"counter"`
// Base amount of fees charged
FeeBase decimal.Decimal `json:"fee_base"`
// Counter amount of fees charged
FeeCounter decimal.Decimal `json:"fee_counter"`
IsBuy bool `json:"is_buy"`
// Unique order identifier
OrderId string `json:"order_id"`
// Currency pair
Pair string `json:"pair"`
// Order price
Price decimal.Decimal `json:"price"`
Sequence int64 `json:"sequence"`
// Unix timestamp in milliseconds
Timestamp Time `json:"timestamp"`
// Order type
Type OrderType `json:"type"`
// Order volume
Volume decimal.Decimal `json:"volume"`
}
type TradingStatus string
const (
TradingStatusPost_only TradingStatus = "POST_ONLY"
TradingStatusActive TradingStatus = "ACTIVE"
TradingStatusSuspended TradingStatus = "SUSPENDED"
)
type Transaction struct {
AccountId string `json:"account_id"`
// Amount available
Available decimal.Decimal `json:"available"`
// Change in amount available
AvailableDelta decimal.Decimal `json:"available_delta"`
// Account balance
Balance decimal.Decimal `json:"balance"`
// Change in balance
BalanceDelta decimal.Decimal `json:"balance_delta"`
Currency string `json:"currency"`
// Human-readable description of the transaction.
Description string `json:"description"`
DetailFields DetailFields `json:"detail_fields"`
// Human-readable label-value attributes.
Details map[string]string `json:"details"`
// The kind of the transaction indicates the transaction flow
//
// Kinds explained:<br>
// <code>FEE</code> when transaction is towards Luno fees<br>
// <code>TRANSFER</code> when the transaction is a one way flow of funds, e.g. a deposit or crypto send<br>
// <code>EXCHANGE</code> when the transaction is part of a two way exchange, e.g. a trade or instant buy
Kind Kind `json:"kind"`
// A unique reference for the transaction this statement entry relates to.
// There may be multiple statement entries related to the same transaction.
// E.g. a withdrawal and the withdrawal fee are two separate statement entries with the same reference.
Reference string `json:"reference"`
RowIndex int64 `json:"row_index"`
// Unix timestamp, in milliseconds
Timestamp Time `json:"timestamp"`
}
type Transfer struct {
// Amount that has been credited or debited on the account. This is always a
// positive value regardless of the transfer direction.
Amount decimal.Decimal `json:"amount"`
// Unix timestamp the transfer was initiated, in milliseconds
CreatedAt Time `json:"created_at"`
// Fee that has been charged by Luno with regards to this transfer.
// This is not included in the `amount`.
// For example, if you receive a transaction with the raw amount of 1 BTC
// and we charge a `fee` of 0.003 BTC on this transaction you will be
// credited the `amount` of 0.997 BTC.
Fee decimal.Decimal `json:"fee"`
// Transfer unique identifier
Id string `json:"id"`
// True for credit transfers, false for debits.
Inbound bool `json:"inbound"`
// When the transfer reflects an on-chain transaction this field will have
// the transaction ID.
TransactionId string `json:"transaction_id"`
}
type Type string
const (
TypeLimit Type = "LIMIT"
TypeMarket Type = "MARKET"
TypeStop_limit Type = "STOP_LIMIT"
)
type Withdrawal struct {
// Amount to withdraw
Amount decimal.Decimal `json:"amount"`
// Unix time the withdrawal was initiated, in milliseconds
CreatedAt Time `json:"created_at"`
// Withdrawal currency.
Currency string `json:"currency"`
// External ID has the value that was passed in when the Withdrawal request was posted.
ExternalId string `json:"external_id"`
// Withdrawal fee
Fee decimal.Decimal `json:"fee"`
Id string `json:"id"`
// Status
Status Status `json:"status"`
// Type distinguishes between different withdrawal methods where more than one is supported
// for the given currency.
Type string `json:"type"`
}
type beneficiary struct {
BankAccountBranch string `json:"bank_account_branch"`
BankAccountNumber string `json:"bank_account_number"`
BankAccountType string `json:"bank_account_type"`
BankCountry string `json:"bank_country"`
BankName string `json:"bank_name"`
BankRecipient string `json:"bank_recipient"`
CreatedAt int64 `json:"created_at"`
Id string `json:"id"`
SupportsFastWithdrawals bool `json:"supports_fast_withdrawals"`
}
// vi: ft=go