-
Notifications
You must be signed in to change notification settings - Fork 59
/
api.go
1711 lines (1457 loc) · 59.9 KB
/
api.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
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
package luno
import (
"context"
"github.com/luno/luno-go/decimal"
)
// CancelWithdrawalRequest is the request struct for CancelWithdrawal.
type CancelWithdrawalRequest struct {
// ID of the withdrawal to cancel.
//
// required: true
Id int64 `json:"id" url:"id"`
}
// CancelWithdrawalResponse is the response struct for CancelWithdrawal.
type CancelWithdrawalResponse 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"`
}
// CancelWithdrawal makes a call to DELETE /api/1/withdrawals/{id}.
//
// Cancels a withdrawal request.
// This can only be done if the request is still in state <code>PENDING</code>.
//
// Permissions required: <code>Perm_W_Withdrawals</code>
func (cl *Client) CancelWithdrawal(ctx context.Context, req *CancelWithdrawalRequest) (*CancelWithdrawalResponse, error) {
var res CancelWithdrawalResponse
err := cl.do(ctx, "DELETE", "/api/1/withdrawals/{id}", req, &res, true)
if err != nil {
return nil, err
}
return &res, nil
}
// CreateAccountRequest is the request struct for CreateAccount.
type CreateAccountRequest struct {
// The currency code for the Account you want to create. Please see the Currency section for a detailed list of currencies supported by the Luno platform.
//
// Users must be verified to trade currency in order to be able to create an Account. For more information on the verification process, please see <a href="/help/en/articles/1000168396">How do I verify my identity?</a>.
//
// Users have a limit of 4 accounts per currency.
//
// required: true
Currency string `json:"currency" url:"currency"`
// The label to use for this account
//
// required: true
Name string `json:"name" url:"name"`
}
// CreateAccountResponse is the response struct for CreateAccount.
type CreateAccountResponse struct {
Currency string `json:"currency"`
Id string `json:"id"`
Name string `json:"name"`
Pending []Transaction `json:"pending"`
Transactions []Transaction `json:"transactions"`
}
// CreateAccount makes a call to POST /api/1/accounts.
//
// This request creates an Account for the specified currency. Please note that the balances for the Account will be displayed based on the <code>asset</code> value, which is the currency the Account is based on.
//
// Permissions required: <code>Perm_W_Addresses</code>
func (cl *Client) CreateAccount(ctx context.Context, req *CreateAccountRequest) (*CreateAccountResponse, error) {
var res CreateAccountResponse
err := cl.do(ctx, "POST", "/api/1/accounts", req, &res, true)
if err != nil {
return nil, err
}
return &res, nil
}
// CreateFundingAddressRequest is the request struct for CreateFundingAddress.
type CreateFundingAddressRequest struct {
// Currency code of the asset.
//
// required: true
Asset string `json:"asset" url:"asset"`
// An optional name for the new Receive Address
Name string `json:"name" url:"name"`
}
// CreateFundingAddressResponse is the response struct for CreateFundingAddress.
type CreateFundingAddressResponse struct {
AccountId string `json:"account_id"`
Address string `json:"address"`
AddressMeta []AddressMeta `json:"address_meta"`
Asset string `json:"asset"`
AssignedAt Time `json:"assigned_at"`
Name string `json:"name"`
QrCodeUri string `json:"qr_code_uri"`
ReceiveFee decimal.Decimal `json:"receive_fee"`
TotalReceived decimal.Decimal `json:"total_received"`
TotalUnconfirmed decimal.Decimal `json:"total_unconfirmed"`
}
// CreateFundingAddress makes a call to POST /api/1/funding_address.
//
// Allocates a new receive address to your account. There is a rate limit of 1
// address per hour, but bursts of up to 10 addresses are allowed. Only 1
// Ethereum receive address can be created.
//
// Permissions required: <code>Perm_W_Addresses</code>
func (cl *Client) CreateFundingAddress(ctx context.Context, req *CreateFundingAddressRequest) (*CreateFundingAddressResponse, error) {
var res CreateFundingAddressResponse
err := cl.do(ctx, "POST", "/api/1/funding_address", req, &res, true)
if err != nil {
return nil, err
}
return &res, nil
}
// CreateWithdrawalRequest is the request struct for CreateWithdrawal.
type CreateWithdrawalRequest struct {
// Amount to withdraw. The currency withdrawn depends on the type setting.
//
// required: true
Amount decimal.Decimal `json:"amount" url:"amount"`
// Withdrawal type.
//
// required: true
Type string `json:"type" url:"type"`
// The beneficiary ID of the bank account the withdrawal will be paid out to.
// This parameter is required if the user has set up multiple beneficiaries.
// The beneficiary ID can be found by selecting on the beneficiary name on the user’s <a href="/wallet/beneficiaries">Beneficiaries</a> page.
BeneficiaryId int64 `json:"beneficiary_id" url:"beneficiary_id"`
// Optional unique ID to associate with this withdrawal.
// Useful to prevent duplicate sends.
// This field supports all alphanumeric characters including "-" and "_".
ExternalId string `json:"external_id" url:"external_id"`
// If true, it will be a fast withdrawal if possible. Fast withdrawals come with a fee.
// Currently fast withdrawals are only available for `type=ZAR_EFT`; for other types, an error is returned.
// Fast withdrawals are not possible for Bank of Baroda, Deutsche Bank, Merrill Lynch South Africa, UBS, Postbank and Tyme Bank.
// The fee to be charged is the same as when withdrawing from the UI.
Fast bool `json:"fast" url:"fast"`
// For internal use.
Reference string `json:"reference" url:"reference"`
}
// CreateWithdrawalResponse is the response struct for CreateWithdrawal.
type CreateWithdrawalResponse 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"`
}
// CreateWithdrawal makes a call to POST /api/1/withdrawals.
//
// Creates a new withdrawal request to the specified beneficiary.
//
// Permissions required: <code>Perm_W_Withdrawals</code>
func (cl *Client) CreateWithdrawal(ctx context.Context, req *CreateWithdrawalRequest) (*CreateWithdrawalResponse, error) {
var res CreateWithdrawalResponse
err := cl.do(ctx, "POST", "/api/1/withdrawals", req, &res, true)
if err != nil {
return nil, err
}
return &res, nil
}
// GetBalancesRequest is the request struct for GetBalances.
type GetBalancesRequest struct {
// Only return balances for wallets with these currencies (if not provided,
// all balances will be returned). To request balances for multiple currencies,
// pass the parameter multiple times,
// e.g. `assets=XBT&assets=ETH`.
Assets []string `json:"assets" url:"assets"`
}
// GetBalancesResponse is the response struct for GetBalances.
type GetBalancesResponse struct {
Balance []AccountBalance `json:"balance"`
}
// GetBalances makes a call to GET /api/1/balance.
//
// The list of all Accounts and their respective balances for the requesting user.
//
// Permissions required: <code>Perm_R_Balance</code>
func (cl *Client) GetBalances(ctx context.Context, req *GetBalancesRequest) (*GetBalancesResponse, error) {
var res GetBalancesResponse
err := cl.do(ctx, "GET", "/api/1/balance", req, &res, true)
if err != nil {
return nil, err
}
return &res, nil
}
// GetCandlesRequest is the request struct for GetCandles.
type GetCandlesRequest struct {
// Candle duration in seconds.
// For example, 300 corresponds to 5m candles. Currently supported
// durations are: 60 (1m), 300 (5m), 900 (15m), 1800 (30m), 3600 (1h),
// 10800 (3h), 14400 (4h), 28800 (8h), 86400 (24h), 259200 (3d), 604800
// (7d).
//
// required: true
Duration int64 `json:"duration" url:"duration"`
// Currency pair
//
// required: true
Pair string `json:"pair" url:"pair"`
// Filter to candles starting on or after this timestamp (Unix milliseconds).
// Only up to 1000 of the earliest candles are returned.
//
// required: true
Since Time `json:"since" url:"since"`
}
// GetCandlesResponse is the response struct for GetCandles.
type GetCandlesResponse struct {
Candles []Candle `json:"candles"`
// Duration in seconds
Duration int64 `json:"duration"`
Pair string `json:"pair"`
}
// GetCandles makes a call to GET /api/exchange/1/candles.
//
// Get candlestick market data from the specified time until now, from the oldest to the most recent.
//
// Permissions required: <code>MP_None</code>
func (cl *Client) GetCandles(ctx context.Context, req *GetCandlesRequest) (*GetCandlesResponse, error) {
var res GetCandlesResponse
err := cl.do(ctx, "GET", "/api/exchange/1/candles", req, &res, true)
if err != nil {
return nil, err
}
return &res, nil
}
// GetFeeInfoRequest is the request struct for GetFeeInfo.
type GetFeeInfoRequest struct {
// Get fee information about this pair.
//
// required: true
Pair string `json:"pair" url:"pair"`
}
// GetFeeInfoResponse is the response struct for GetFeeInfo.
type GetFeeInfoResponse struct {
MakerFee string `json:"maker_fee"`
TakerFee string `json:"taker_fee"`
ThirtyDayVolume string `json:"thirty_day_volume"`
}
// GetFeeInfo makes a call to GET /api/1/fee_info.
//
// Returns the fees and 30 day trading volume (as of midnight) for a given currency pair. For complete details, please see <a href="en/countries">Fees & Features</a>.
//
// Permissions required: <code>Perm_R_Orders</code>
func (cl *Client) GetFeeInfo(ctx context.Context, req *GetFeeInfoRequest) (*GetFeeInfoResponse, error) {
var res GetFeeInfoResponse
err := cl.do(ctx, "GET", "/api/1/fee_info", req, &res, true)
if err != nil {
return nil, err
}
return &res, nil
}
// GetFundingAddressRequest is the request struct for GetFundingAddress.
type GetFundingAddressRequest struct {
// Currency code of the asset.
//
// required: true
Asset string `json:"asset" url:"asset"`
// Specific cryptocurrency address to retrieve. If not provided, the
// default address will be used.
Address string `json:"address" url:"address"`
}
// GetFundingAddressResponse is the response struct for GetFundingAddress.
type GetFundingAddressResponse struct {
AccountId string `json:"account_id"`
Address string `json:"address"`
AddressMeta []AddressMeta `json:"address_meta"`
Asset string `json:"asset"`
AssignedAt Time `json:"assigned_at"`
Name string `json:"name"`
QrCodeUri string `json:"qr_code_uri"`
ReceiveFee decimal.Decimal `json:"receive_fee"`
TotalReceived decimal.Decimal `json:"total_received"`
TotalUnconfirmed decimal.Decimal `json:"total_unconfirmed"`
}
// GetFundingAddress makes a call to GET /api/1/funding_address.
//
// Returns the default receive address associated with your account and the
// amount received via the address. Users can specify an optional address parameter to return information for a non-default receive address.
// In the response, <code>total_received</code> is the total confirmed amount received excluding unconfirmed transactions.
// <code>total_unconfirmed</code> is the total sum of unconfirmed receive transactions.
//
// Permissions required: <code>Perm_R_Addresses</code>
func (cl *Client) GetFundingAddress(ctx context.Context, req *GetFundingAddressRequest) (*GetFundingAddressResponse, error) {
var res GetFundingAddressResponse
err := cl.do(ctx, "GET", "/api/1/funding_address", req, &res, true)
if err != nil {
return nil, err
}
return &res, nil
}
// GetMoveRequest is the request struct for GetMove.
type GetMoveRequest struct {
// Get by the user defined ID. This is mutually exclusive with <code>id</code> and is required if <code>id</code> is
// not provided.
ClientMoveId string `json:"client_move_id" url:"client_move_id"`
// Get by the system ID. This is mutually exclusive with <code>client_move_id</code> and is required if
// <code>client_move_id</code> is not provided.
Id string `json:"id" url:"id"`
}
// GetMoveResponse is the response struct for GetMove.
type GetMoveResponse 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"`
}
// GetMove makes a call to GET /api/exchange/1/move.
//
// Get a specific move funds instruction by either <code>id</code> or
// <code>client_move_id</code>. If both are provided an API error will be
// returned.
//
// This endpoint is in BETA, behaviour and specification may change without
// any previous notice.
//
// Permissions required: <code>MP_None</code>
func (cl *Client) GetMove(ctx context.Context, req *GetMoveRequest) (*GetMoveResponse, error) {
var res GetMoveResponse
err := cl.do(ctx, "GET", "/api/exchange/1/move", req, &res, true)
if err != nil {
return nil, err
}
return &res, nil
}
// GetOrderRequest is the request struct for GetOrder.
type GetOrderRequest struct {
// Order reference
//
// required: true
Id string `json:"id" url:"id"`
}
// GetOrderResponse is the response struct for GetOrder.
type GetOrderResponse 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"`
}
// GetOrder makes a call to GET /api/1/orders/{id}.
//
// Get an Order's details by its ID.
//
// Permissions required: <code>Perm_R_Orders</code>
func (cl *Client) GetOrder(ctx context.Context, req *GetOrderRequest) (*GetOrderResponse, error) {
var res GetOrderResponse
err := cl.do(ctx, "GET", "/api/1/orders/{id}", req, &res, true)
if err != nil {
return nil, err
}
return &res, nil
}
// GetOrderBookRequest is the request struct for GetOrderBook.
type GetOrderBookRequest struct {
// Currency pair of the Orders to retrieve
//
// required: true
Pair string `json:"pair" url:"pair"`
}
// GetOrderBookResponse is the response struct for GetOrderBook.
type GetOrderBookResponse struct {
// List of asks sorted from lowest to highest price
Asks []OrderBookEntry `json:"asks"`
// List of bids sorted from highest to lowest price
Bids []OrderBookEntry `json:"bids"`
// Unix timestamp in milliseconds
Timestamp int64 `json:"timestamp"`
}
// GetOrderBook makes a call to GET /api/1/orderbook_top.
//
// This request returns the best 100 `bids` and `asks`, for the currency pair specified, in the Order Book.
//
// `asks` are sorted by price ascending and `bids` are sorted by price descending.
//
// Multiple orders at the same price are aggregated.
func (cl *Client) GetOrderBook(ctx context.Context, req *GetOrderBookRequest) (*GetOrderBookResponse, error) {
var res GetOrderBookResponse
err := cl.do(ctx, "GET", "/api/1/orderbook_top", req, &res, false)
if err != nil {
return nil, err
}
return &res, nil
}
// GetOrderBookFullRequest is the request struct for GetOrderBookFull.
type GetOrderBookFullRequest struct {
// Currency pair of the Orders to retrieve
//
// required: true
Pair string `json:"pair" url:"pair"`
}
// GetOrderBookFullResponse is the response struct for GetOrderBookFull.
type GetOrderBookFullResponse struct {
// List of asks sorted from lowest to highest price
Asks []OrderBookEntry `json:"asks"`
// List of bids sorted from highest to lowest price
Bids []OrderBookEntry `json:"bids"`
// Unix timestamp in milliseconds
Timestamp int64 `json:"timestamp"`
}
// GetOrderBookFull makes a call to GET /api/1/orderbook.
//
// This request returns all `bids` and `asks`, for the currency pair specified, in the Order Book.
//
// `asks` are sorted by price ascending and `bids` are sorted by price descending.
//
// Multiple orders at the same price are not aggregated.
//
// <b>WARNING:</b> This may return a large amount of data.
// Users are recommended to use the <a href="#operation/getOrderBookTop">top 100 bids and asks</a>
// or the <a href="#tag/Streaming-API">Streaming API</a>.
func (cl *Client) GetOrderBookFull(ctx context.Context, req *GetOrderBookFullRequest) (*GetOrderBookFullResponse, error) {
var res GetOrderBookFullResponse
err := cl.do(ctx, "GET", "/api/1/orderbook", req, &res, false)
if err != nil {
return nil, err
}
return &res, nil
}
// GetOrderV2Request is the request struct for GetOrderV2.
type GetOrderV2Request struct {
// Order reference
//
// required: true
Id string `json:"id" url:"id"`
}
// GetOrderV2Response is the response struct for GetOrderV2.
type GetOrderV2Response 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"`
}
// GetOrderV2 makes a call to GET /api/exchange/2/orders/{id}.
//
// Get the details for an order.
//
// Permissions required: <code>Perm_R_Orders</code>
func (cl *Client) GetOrderV2(ctx context.Context, req *GetOrderV2Request) (*GetOrderV2Response, error) {
var res GetOrderV2Response
err := cl.do(ctx, "GET", "/api/exchange/2/orders/{id}", req, &res, true)
if err != nil {
return nil, err
}
return &res, nil
}
// GetOrderV3Request is the request struct for GetOrderV3.
type GetOrderV3Request struct {
// Client Order ID has the value that was passed in when the Order was posted.
ClientOrderId string `json:"client_order_id" url:"client_order_id"`
// Order reference
Id string `json:"id" url:"id"`
}
// GetOrderV3Response is the response struct for GetOrderV3.
type GetOrderV3Response 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"`
}
// GetOrderV3 makes a call to GET /api/exchange/3/order.
//
// Get the details for an order by order reference or client order ID.
// Exactly one of the two parameters must be provided, otherwise an error is returned.
// Permissions required: <code>Perm_R_Orders</code>
func (cl *Client) GetOrderV3(ctx context.Context, req *GetOrderV3Request) (*GetOrderV3Response, error) {
var res GetOrderV3Response
err := cl.do(ctx, "GET", "/api/exchange/3/order", req, &res, true)
if err != nil {
return nil, err
}
return &res, nil
}
// GetTickerRequest is the request struct for GetTicker.
type GetTickerRequest struct {
// Currency pair
//
// required: true
Pair string `json:"pair" url:"pair"`
}
// GetTickerResponse is the response struct for GetTicker.
type GetTickerResponse 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"`
}
// GetTicker makes a call to GET /api/1/ticker.
//
// Returns the latest ticker indicators for the specified currency pair.
//
// Please see the <a href="#tag/currency ">Currency list</a> for the complete list of supported currency pairs.
func (cl *Client) GetTicker(ctx context.Context, req *GetTickerRequest) (*GetTickerResponse, error) {
var res GetTickerResponse
err := cl.do(ctx, "GET", "/api/1/ticker", req, &res, false)
if err != nil {
return nil, err
}
return &res, nil
}
// GetTickersRequest is the request struct for GetTickers.
type GetTickersRequest struct {
// Return tickers for multiple markets (if not provided, all tickers will be returned).
// To request tickers for multiple markets, pass the parameter multiple times,
// e.g. `pair=XBTZAR&pair=ETHZAR`.
Pair []string `json:"pair" url:"pair"`
}
// GetTickersResponse is the response struct for GetTickers.
type GetTickersResponse struct {
Tickers []Ticker `json:"tickers"`
}
// GetTickers makes a call to GET /api/1/tickers.
//
// Returns the latest ticker indicators from all active Luno exchanges.
//
// Please see the <a href="#tag/currency ">Currency list</a> for the complete list of supported currency pairs.
func (cl *Client) GetTickers(ctx context.Context, req *GetTickersRequest) (*GetTickersResponse, error) {
var res GetTickersResponse
err := cl.do(ctx, "GET", "/api/1/tickers", req, &res, false)
if err != nil {
return nil, err
}
return &res, nil
}
// GetWithdrawalRequest is the request struct for GetWithdrawal.
type GetWithdrawalRequest struct {
// Withdrawal ID to retrieve.
//
// required: true
Id int64 `json:"id" url:"id"`
}
// GetWithdrawalResponse is the response struct for GetWithdrawal.
type GetWithdrawalResponse 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"`
}
// GetWithdrawal makes a call to GET /api/1/withdrawals/{id}.
//
// Returns the status of a particular withdrawal request.
//
// Permissions required: <code>Perm_R_Withdrawals</code>
func (cl *Client) GetWithdrawal(ctx context.Context, req *GetWithdrawalRequest) (*GetWithdrawalResponse, error) {
var res GetWithdrawalResponse
err := cl.do(ctx, "GET", "/api/1/withdrawals/{id}", req, &res, true)
if err != nil {
return nil, err
}
return &res, nil
}
// ListBeneficiariesResponseRequest is the request struct for ListBeneficiariesResponse.
type ListBeneficiariesResponseRequest struct {
}
// ListBeneficiariesResponseResponse is the response struct for ListBeneficiariesResponse.
type ListBeneficiariesResponseResponse struct {
Beneficiaries []beneficiary `json:"beneficiaries"`
}
// ListBeneficiariesResponse makes a call to GET /api/1/beneficiaries.
//
// Returns a list of bank beneficiaries.
//
// Permissions required: <code>Perm_R_Beneficiaries</code>
func (cl *Client) ListBeneficiariesResponse(ctx context.Context, req *ListBeneficiariesResponseRequest) (*ListBeneficiariesResponseResponse, error) {
var res ListBeneficiariesResponseResponse
err := cl.do(ctx, "GET", "/api/1/beneficiaries", req, &res, true)
if err != nil {
return nil, err
}
return &res, nil
}
// ListMovesRequest is the request struct for ListMoves.
type ListMovesRequest struct {
// Filter to moves requested before this timestamp (Unix milliseconds)
Before int64 `json:"before" url:"before"`
// Limit to this many moves
Limit int64 `json:"limit" url:"limit"`
}
// ListMovesResponse is the response struct for ListMoves.
type ListMovesResponse struct {
Moves []FundsMove `json:"moves"`
}
// ListMoves makes a call to GET /api/exchange/1/move/list_moves.
//
// Returns a list of the most recent moves ordered from newest to oldest.
// This endpoint will list up to 100 most recent moves by default.
//
// This endpoint is in BETA, behaviour and specification may change without
// any previous notice.
//
// Permissions required: <code>MP_None</code>
func (cl *Client) ListMoves(ctx context.Context, req *ListMovesRequest) (*ListMovesResponse, error) {
var res ListMovesResponse
err := cl.do(ctx, "GET", "/api/exchange/1/move/list_moves", req, &res, true)
if err != nil {
return nil, err
}
return &res, nil
}
// ListOrdersRequest is the request struct for ListOrders.
type ListOrdersRequest struct {
// Filter to orders created before this timestamp (Unix milliseconds)
CreatedBefore int64 `json:"created_before" url:"created_before"`
// Limit to this many orders
Limit int64 `json:"limit" url:"limit"`
// Filter to only orders of this currency pair
Pair string `json:"pair" url:"pair"`
// Filter to only orders of this state
State OrderState `json:"state" url:"state"`
}
// ListOrdersResponse is the response struct for ListOrders.
type ListOrdersResponse struct {
Orders []Order `json:"orders"`
}
// ListOrders makes a call to GET /api/1/listorders.
//
// Returns a list of the most recently placed Orders.
// Users can specify an optional <code>state=PENDING</code> parameter to restrict the results to only open Orders.
// Users can also specify the market by using the optional currency pair parameter.
//
// Permissions required: <code>Perm_R_Orders</code>
func (cl *Client) ListOrders(ctx context.Context, req *ListOrdersRequest) (*ListOrdersResponse, error) {
var res ListOrdersResponse
err := cl.do(ctx, "GET", "/api/1/listorders", req, &res, true)
if err != nil {
return nil, err
}
return &res, nil