cryptomarket-sdk 1.0.1 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +156 -70
- data/lib/cryptomarket/client.rb +1240 -730
- data/lib/cryptomarket/constants.rb +123 -0
- data/lib/cryptomarket/credentials_factory.rb +53 -0
- data/lib/cryptomarket/exceptions.rb +18 -19
- data/lib/cryptomarket/http_manager.rb +98 -0
- data/lib/cryptomarket/websocket/auth_client.rb +72 -0
- data/lib/cryptomarket/websocket/callback_cache.rb +54 -0
- data/lib/cryptomarket/websocket/client_base.rb +135 -0
- data/lib/cryptomarket/websocket/market_data_client.rb +324 -0
- data/lib/cryptomarket/websocket/market_data_client_core.rb +62 -0
- data/lib/cryptomarket/websocket/methods.rb +36 -54
- data/lib/cryptomarket/websocket/reusable_callback.rb +21 -0
- data/lib/cryptomarket/websocket/trading_client.rb +279 -0
- data/lib/cryptomarket/websocket/wallet_client.rb +173 -0
- data/lib/cryptomarket/websocket/ws_manager.rb +65 -0
- metadata +77 -18
- data/lib/cryptomarket/HttpManager.rb +0 -75
- data/lib/cryptomarket/utils.rb +0 -57
- data/lib/cryptomarket/websocket/accountClient.rb +0 -150
- data/lib/cryptomarket/websocket/authClient.rb +0 -53
- data/lib/cryptomarket/websocket/callbackCache.rb +0 -51
- data/lib/cryptomarket/websocket/orderbookCache.rb +0 -123
- data/lib/cryptomarket/websocket/publicClient.rb +0 -275
- data/lib/cryptomarket/websocket/tradingClient.rb +0 -134
- data/lib/cryptomarket/websocket/wsClientBase.rb +0 -158
- data/lib/cryptomarket/websocket/wsManager.rb +0 -59
data/lib/cryptomarket/client.rb
CHANGED
@@ -1,732 +1,1242 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# rubocop:disable Layout/LineLength
|
4
|
+
require_relative 'http_manager'
|
3
5
|
|
4
6
|
module Cryptomarket
|
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
|
-
|
7
|
+
# Creates a new rest client
|
8
|
+
#
|
9
|
+
# ==== Params
|
10
|
+
# +String+ +api_key+:: the user api key
|
11
|
+
# +String+ +api_secret+:: the user api secret
|
12
|
+
# +Integer+ +window+:: Maximum difference between the creation of the request and the moment of request processing in milliseconds. Max is 60_000. Defaul is 10_000
|
13
|
+
class Client # rubocop:disable Metrics/ClassLength
|
14
|
+
def initialize(api_key: nil, api_secret: nil, window: nil)
|
15
|
+
@http_manager = HttpManager.new api_key: api_key, api_secret: api_secret, window: window
|
16
|
+
end
|
17
|
+
|
18
|
+
def public_get(endpoint, params = nil)
|
19
|
+
@http_manager.make_request(method: 'get', endpoint: endpoint, params: params, public: true)
|
20
|
+
end
|
21
|
+
|
22
|
+
def get(endpoint, params = nil)
|
23
|
+
@http_manager.make_request(method: 'get', endpoint: endpoint, params: params)
|
24
|
+
end
|
25
|
+
|
26
|
+
def post(endpoint, params = nil)
|
27
|
+
@http_manager.make_post_request(method: 'post', endpoint: endpoint, params: params)
|
28
|
+
end
|
29
|
+
|
30
|
+
def put(endpoint, params = nil)
|
31
|
+
@http_manager.make_request(method: 'put', endpoint: endpoint, params: params)
|
32
|
+
end
|
33
|
+
|
34
|
+
def patch(endpoint, params = nil)
|
35
|
+
@http_manager.make_request(method: 'patch', endpoint: endpoint, params: params)
|
36
|
+
end
|
37
|
+
|
38
|
+
def delete(endpoint, params = nil)
|
39
|
+
@http_manager.make_request(method: 'delete', endpoint: endpoint, params: params)
|
40
|
+
end
|
41
|
+
|
42
|
+
###########
|
43
|
+
# aliases #
|
44
|
+
###########
|
45
|
+
|
46
|
+
# market data
|
47
|
+
|
48
|
+
# alias of get ticker
|
49
|
+
alias get_ticker_by_symbol get_ticker
|
50
|
+
alias get_ticker_of_symbol get_ticker
|
51
|
+
alias get_ticker_price_by_symbol get_ticker_price
|
52
|
+
alias get_ticker_price_of_symbol get_ticker_price
|
53
|
+
alias get_trades_of_symbol get_trades_by_symbol
|
54
|
+
alias get_orderbook_by_symbol get_orderbook
|
55
|
+
alias get_orderbook_of_symbol get_orderbook
|
56
|
+
alias get_orderbook_volume_by_symbol get_orderbook_volume
|
57
|
+
alias get_orderbook_volume_of_symbol get_orderbook_volume
|
58
|
+
alias get_candles_of_symbol get_candles_by_symbol
|
59
|
+
alias get_converted_candles_of_symbol get_converted_candles_by_symbol
|
60
|
+
# spot trading
|
61
|
+
alias get_spot_trading_balance_of_currency get_spot_trading_balance
|
62
|
+
alias get_spot_trading_balance_by_currency get_spot_trading_balance
|
63
|
+
alias get_all_trading_commissions get_all_trading_commission
|
64
|
+
alias get_trading_commission get_all_trading_commission
|
65
|
+
alias get_trading_commission_of_symbol get_trading_commission
|
66
|
+
alias get_trading_commission_by_symbol get_trading_commission
|
67
|
+
# wallet management
|
68
|
+
alias get_wallet_balance_of_currency get_wallet_balance
|
69
|
+
alias get_wallet_balance_by_currency get_wallet_balance
|
70
|
+
alias get_deposit_crypto_address_of_cyrrency get_deposit_crypto_address
|
71
|
+
alias get_deposit_crypto_address_by_cyrrency get_deposit_crypto_address
|
72
|
+
|
73
|
+
################
|
74
|
+
# public calls #
|
75
|
+
################
|
76
|
+
|
77
|
+
# Get a Hash of all currencies or specified currencies. indexed by id
|
78
|
+
#
|
79
|
+
# Requires no API key Access Rights
|
80
|
+
#
|
81
|
+
# https://api.exchange.cryptomkt.com/#currencies
|
82
|
+
#
|
83
|
+
# ==== Params
|
84
|
+
# +Array[String]+ +currencies+:: Optional. A list of currencies ids
|
85
|
+
# +String+ +preferred_network+:: Optional. Code of de default network code of currencies
|
86
|
+
|
87
|
+
def get_currencies(currencies: nil, preferred_network: nil)
|
88
|
+
public_get('public/currency/', {
|
89
|
+
currencies: currencies,
|
90
|
+
preferred_network: preferred_network
|
91
|
+
})
|
92
|
+
end
|
93
|
+
|
94
|
+
# Get the data of a currency
|
95
|
+
#
|
96
|
+
# Requires no API key Access Rights
|
97
|
+
#
|
98
|
+
# https://api.exchange.cryptomkt.com/#currencies
|
99
|
+
#
|
100
|
+
# ==== Params
|
101
|
+
# +String+ +currency+:: A currency id
|
102
|
+
|
103
|
+
def get_currency(currency:)
|
104
|
+
public_get("public/currency/#{currency}")
|
105
|
+
end
|
106
|
+
|
107
|
+
# Get a Hash of all symbols or for specified symbols. indexed by id
|
108
|
+
# A symbol is the combination of the base currency (first one) and quote currency (second one)
|
109
|
+
#
|
110
|
+
# Requires no API key Access Rights
|
111
|
+
#
|
112
|
+
# https://api.exchange.cryptomkt.com/#symbols
|
113
|
+
#
|
114
|
+
# ==== Params
|
115
|
+
# +Array[String]+ +symbols+:: Optional. A list of symbol ids
|
116
|
+
|
117
|
+
def get_symbols(symbols: nil)
|
118
|
+
public_get('public/symbol', { symbols: symbols })
|
119
|
+
end
|
120
|
+
|
121
|
+
# Get a symbol by its id
|
122
|
+
# A symbol is the combination of the base currency (first one) and quote currency (second one)
|
123
|
+
#
|
124
|
+
# Requires no API key Access Rights
|
125
|
+
#
|
126
|
+
# https://api.exchange.cryptomkt.com/#symbols
|
127
|
+
#
|
128
|
+
# ==== Params
|
129
|
+
# +String+ +symbol+:: A symbol id
|
130
|
+
|
131
|
+
def get_symbol(symbol:)
|
132
|
+
public_get("public/symbol/#{symbol}")
|
133
|
+
end
|
134
|
+
|
135
|
+
# Get a Hash of tickers for all symbols or for specified symbols. indexed by symbol
|
136
|
+
#
|
137
|
+
# Requires no API key Access Rights
|
138
|
+
#
|
139
|
+
# https://api.exchange.cryptomkt.com/#tickers
|
140
|
+
#
|
141
|
+
# ==== Params
|
142
|
+
# +Array[String]+ +symbols+:: Optional. A list of symbol ids
|
143
|
+
|
144
|
+
def get_tickers(symbols: nil)
|
145
|
+
public_get('public/ticker', { symbols: symbols })
|
146
|
+
end
|
147
|
+
|
148
|
+
# Get the ticker of a symbol
|
149
|
+
#
|
150
|
+
# Requires no API key Access Rights
|
151
|
+
#
|
152
|
+
# https://api.exchange.cryptomkt.com/#tickers
|
153
|
+
#
|
154
|
+
# ==== Params
|
155
|
+
# +String+ +symbol+:: A symbol id
|
156
|
+
|
157
|
+
def get_ticker(symbol:)
|
158
|
+
public_get("public/ticker/#{symbol}")
|
159
|
+
end
|
160
|
+
|
161
|
+
# Get a Hash of quotation prices of currencies
|
162
|
+
#
|
163
|
+
# Requires no API key Access Rights
|
164
|
+
#
|
165
|
+
# https://api.exchange.cryptomkt.com/#prices
|
166
|
+
#
|
167
|
+
# ==== Params
|
168
|
+
# +String+ +to+:: Target currency code
|
169
|
+
# +String+ +from+:: Optional. Source currency rate
|
170
|
+
|
171
|
+
def get_prices(to:, from: nil)
|
172
|
+
public_get('public/price/rate', { to: to, from: from })
|
173
|
+
end
|
174
|
+
|
175
|
+
# Get quotation prices history
|
176
|
+
#
|
177
|
+
# Requires no API key Access Rights
|
178
|
+
#
|
179
|
+
# https://api.exchange.cryptomkt.com/#prices
|
180
|
+
#
|
181
|
+
# ==== Params
|
182
|
+
# +String+ +to+:: Target currency code
|
183
|
+
# +String+ +from+:: Optional. Source currency rate
|
184
|
+
# +String+ +period+:: Optional. A valid tick interval. 'M1' (one minute), 'M3', 'M5', 'M15', 'M30', 'H1' (one hour), 'H4', 'D1' (one day), 'D7', '1M' (one month). Default is 'M30'
|
185
|
+
# +String+ +sort+:: Optional. Sort direction. 'ASC' or 'DESC'. Default is 'DESC'
|
186
|
+
# +String+ +since+:: Optional. Initial value of the queried interval
|
187
|
+
# +String+ +until+:: Optional. Last value of the queried interval
|
188
|
+
# +Integer+ +limit+:: Optional. Prices per currency pair. Defaul is 1. Min is 1. Max is 1_000
|
189
|
+
|
190
|
+
def get_price_history(to:, from: nil, till: nil, since: nil, limit: nil, period: nil, sort: nil) # rubocop:disable Metrics/ParameterLists
|
191
|
+
public_get(
|
192
|
+
'public/price/history',
|
193
|
+
{ to: to, from: from, till: till, since: since, limit: limit, period: period, sort: sort }
|
194
|
+
)
|
195
|
+
end
|
196
|
+
|
197
|
+
# Get a Hash of the ticker's last prices for all symbols or for the specified symbols
|
198
|
+
#
|
199
|
+
# Requires no API key Access Rights
|
200
|
+
#
|
201
|
+
# https://api.exchange.cryptomkt.com/#prices
|
202
|
+
#
|
203
|
+
# ==== Params
|
204
|
+
# +Array[String]+ +symbols+:: Optional. A list of symbol ids
|
205
|
+
|
206
|
+
def get_ticker_prices(symbols: nil)
|
207
|
+
public_get('public/price/ticker', { symbols: symbols })
|
208
|
+
end
|
209
|
+
|
210
|
+
# Get ticker's last prices of a symbol
|
211
|
+
#
|
212
|
+
# Requires no API key Access Rights
|
213
|
+
#
|
214
|
+
# https://api.exchange.cryptomkt.com/#prices
|
215
|
+
#
|
216
|
+
# ==== Params
|
217
|
+
# +String+ +symbol+:: A symbol id
|
218
|
+
|
219
|
+
def get_ticker_price(symbol:)
|
220
|
+
public_get("public/price/ticker/#{symbol}")
|
221
|
+
end
|
222
|
+
|
223
|
+
# Get a Hash of trades for all symbols or for specified symbols
|
224
|
+
# 'from' param and 'till' param must have the same format, both id or both timestamp
|
225
|
+
#
|
226
|
+
# Requires no API key Access Rights
|
227
|
+
#
|
228
|
+
# https://api.exchange.cryptomkt.com/#trades
|
229
|
+
#
|
230
|
+
# ==== Params
|
231
|
+
# +Array[String]+ +symbols+:: Optional. A list of symbol ids
|
232
|
+
# +String+ +by+:: Optional. Sorting parameter. 'id' or 'timestamp'. Default is 'timestamp'
|
233
|
+
# +String+ +sort+:: Optional. Sort direction. 'ASC' or 'DESC'. Default is 'DESC'
|
234
|
+
# +String+ +since+:: Optional. Initial value of the queried interval
|
235
|
+
# +String+ +until+:: Optional. Last value of the queried interval
|
236
|
+
# +Integer+ +limit+:: Optional. Prices per currency pair. Defaul is 10. Min is 1. Max is 1_000
|
237
|
+
|
238
|
+
def get_trades(symbols: nil, by: nil, sort: nil, from: nil, till: nil, limit: nil, offset: nil) # rubocop:disable Metrics/ParameterLists
|
239
|
+
public_get(
|
240
|
+
'public/trades/',
|
241
|
+
{ symbols: symbols, by: by, sort: sort, from: from, till: till, limit: limit, offset: offset }
|
242
|
+
)
|
243
|
+
end
|
244
|
+
|
245
|
+
# Get trades of a symbol
|
246
|
+
# 'from' param and 'till' param must have the same format, both id or both timestamp
|
247
|
+
#
|
248
|
+
# Requires no API key Access Rights
|
249
|
+
#
|
250
|
+
# https://api.exchange.cryptomkt.com/#trades
|
251
|
+
#
|
252
|
+
# ==== Params
|
253
|
+
# +String+ +symbol+:: A symbol id
|
254
|
+
# +String+ +by+:: Optional. Sorting parameter. 'id' or 'timestamp'. Default is 'timestamp'
|
255
|
+
# +String+ +sort+:: Optional. Sort direction. 'ASC' or 'DESC'. Default is 'DESC'
|
256
|
+
# +String+ +since+:: Optional. Initial value of the queried interval
|
257
|
+
# +String+ +until+:: Optional. Last value of the queried interval
|
258
|
+
# +Integer+ +limit+:: Optional. Prices per currency pair. Defaul is 10. Min is 1. Max is 1_000
|
259
|
+
# +Integer+ +offset+:: Optional. Default is 0. Min is 0. Max is 100_000
|
260
|
+
|
261
|
+
def get_trades_by_symbol(symbol: nil, by: nil, sort: nil, from: nil, till: nil, limit: nil, offset: nil) # rubocop:disable Metrics/ParameterLists
|
262
|
+
public_get(
|
263
|
+
"public/trades/#{symbol}",
|
264
|
+
{ by: by, sort: sort, from: from, till: till, limit: limit, offset: offset }
|
265
|
+
)
|
266
|
+
end
|
267
|
+
|
268
|
+
# Get a Hash of orderbooks for all symbols or for the specified symbols
|
269
|
+
# An Order Book is an electronic list of buy and sell orders for a specific symbol, structured by price level
|
270
|
+
#
|
271
|
+
# Requires no API key Access Rights
|
272
|
+
#
|
273
|
+
# https://api.exchange.cryptomkt.com/#order-books
|
274
|
+
#
|
275
|
+
# ==== Params
|
276
|
+
# +Array[String]+ +symbols+:: Optional. A list of symbol ids
|
277
|
+
# +Integer+ +depth+:: Optional. Order Book depth. Default value is 100. Set to 0 to view the full Order Book
|
278
|
+
|
279
|
+
def get_orderbooks(symbols: nil, depth: nil)
|
280
|
+
public_get('public/orderbook', { symbols: symbols, depth: depth })
|
281
|
+
end
|
282
|
+
|
283
|
+
# Get order book of a symbol
|
284
|
+
# An Order Book is an electronic list of buy and sell orders for a specific symbol, structured by price level
|
285
|
+
#
|
286
|
+
# Requires no API key Access Rights
|
287
|
+
#
|
288
|
+
# https://api.exchange.cryptomkt.com/#order-books
|
289
|
+
#
|
290
|
+
# ==== Params
|
291
|
+
# +String+ +symbol+:: A symbol id
|
292
|
+
# +Integer+ +depth+:: Optional. Order Book depth. Default value is 100. Set to 0 to view the full Order Book
|
293
|
+
|
294
|
+
def get_orderbook(symbol:, depth: nil)
|
295
|
+
public_get("public/orderbook/#{symbol}", { depth: depth })
|
296
|
+
end
|
297
|
+
|
298
|
+
# Get order book of a symbol with the desired volume for market depth search
|
299
|
+
# An Order Book is an electronic list of buy and sell orders for a specific symbol, structured by price level
|
300
|
+
#
|
301
|
+
# Requires no API key Access Rights
|
302
|
+
#
|
303
|
+
# https://api.exchange.cryptomkt.com/#order-books
|
304
|
+
#
|
305
|
+
# ==== Params
|
306
|
+
# +String+ +symbol+:: A symbol id
|
307
|
+
# +float+ +volume+:: Optional. Desired volume for market depth search
|
308
|
+
|
309
|
+
def get_orderbook_volume(symbol:, volume: nil)
|
310
|
+
public_get("public/orderbook/#{symbol}", { volume: volume })
|
311
|
+
end
|
312
|
+
|
313
|
+
# Get a Hash of candles for all symbols or for specified symbols
|
314
|
+
# Candles are used for OHLC representation
|
315
|
+
# The result contains candles with non-zero volume only (no trades = no candles)
|
316
|
+
#
|
317
|
+
# Requires no API key Access Rights
|
318
|
+
#
|
319
|
+
# https://api.exchange.cryptomkt.com/#candles
|
320
|
+
#
|
321
|
+
# ==== Params
|
322
|
+
# +String+ +symbol+:: A symbol id
|
323
|
+
# +String+ +period+:: Optional. A valid tick interval. 'M1' (one minute), 'M3', 'M5', 'M15', 'M30', 'H1' (one hour), 'H4', 'D1' (one day), 'D7', '1M' (one month). Default is 'M30'
|
324
|
+
# +String+ +sort+:: Optional. Sort direction. 'ASC' or 'DESC'. Default is 'DESC'
|
325
|
+
# +String+ +from+:: Optional. Initial value of the queried interval. As DateTime
|
326
|
+
# +String+ +till+:: Optional. Last value of the queried interval. As DateTime
|
327
|
+
# +Integer+ +limit+:: Optional. Prices per currency pair. Defaul is 10. Min is 1. Max is 1_000
|
328
|
+
|
329
|
+
def get_candles(symbols: nil, period: nil, sort: nil, from: nil, till: nil, limit: nil, offset: nil) # rubocop:disable Metrics/ParameterLists
|
330
|
+
public_get(
|
331
|
+
'public/candles/',
|
332
|
+
{ symbols: symbols, period: period, sort: sort, from: from, till: till, limit: limit, offset: offset }
|
333
|
+
)
|
334
|
+
end
|
335
|
+
|
336
|
+
# Get candles of a symbol
|
337
|
+
# Candles are used for OHLC representation
|
338
|
+
# The result contains candles with non-zero volume only (no trades = no candles)
|
339
|
+
#
|
340
|
+
# Requires no API key Access Rights
|
341
|
+
#
|
342
|
+
# https://api.exchange.cryptomkt.com/#candles
|
343
|
+
#
|
344
|
+
# ==== Params
|
345
|
+
# +String+ +symbol+:: A symbol id
|
346
|
+
# +String+ +period+:: Optional. A valid tick interval. 'M1' (one minute), 'M3', 'M5', 'M15', 'M30', 'H1' (one hour), 'H4', 'D1' (one day), 'D7', '1M' (one month). Default is 'M30'
|
347
|
+
# +String+ +sort+:: Optional. Sort direction. 'ASC' or 'DESC'. Default is 'DESC'
|
348
|
+
# +String+ +from+:: Optional. Initial value of the queried interval. As DateTime
|
349
|
+
# +String+ +till+:: Optional. Last value of the queried interval. As DateTime
|
350
|
+
# +Integer+ +limit+:: Optional. Prices per currency pair. Defaul is 100. Min is 1. Max is 1_000
|
351
|
+
# +Integer+ +offset+:: Optional. Default is 0. Min is 0. Max is 100_000
|
352
|
+
|
353
|
+
def get_candles_by_symbol(symbol:, period: nil, sort: nil, from: nil, till: nil, limit: nil, offset: nil) # rubocop:disable Metrics/ParameterLists
|
354
|
+
public_get(
|
355
|
+
"public/candles/#{symbol}",
|
356
|
+
{ period: period, sort: sort, from: from, till: till, limit: limit, offset: offset }
|
357
|
+
)
|
358
|
+
end
|
359
|
+
|
360
|
+
# Gets OHLCV data regarding the last price converted to the target currency for all symbols or for the specified symbols
|
361
|
+
#
|
362
|
+
# Candles are used for OHLC representation
|
363
|
+
#
|
364
|
+
# The result contains candles with non-zero volume only (no trades = no candles)
|
365
|
+
#
|
366
|
+
# Conversion from the symbol quote currency to the target currency is the mean of "best" bid price and "best" ask price in the order book. If there is no "best" bid or ask price, the last price is returned.
|
367
|
+
#
|
368
|
+
# Requires no API key Access Rights
|
369
|
+
#
|
370
|
+
# https://api.exchange.cryptomkt.com/#candles
|
371
|
+
#
|
372
|
+
# +String+ +target_currency+:: Target currency for conversion
|
373
|
+
# +Array[String]+ +symbols+:: Optional. A list of symbols
|
374
|
+
# +String+ +period+:: Optional. A valid tick interval. 'M1' (one minute), 'M3', 'M5', 'M15', 'M30', 'H1' (one hour), 'H4', 'D1' (one day), 'D7', '1M' (one month). Default is 'M30'
|
375
|
+
# +String+ +sort+:: Optional. Sort direction. 'ASC' or 'DESC'. Default is 'DESC'
|
376
|
+
# +String+ +from+:: Optional. Initial value of the queried interval. As DateTime
|
377
|
+
# +String+ +till+:: Optional. Last value of the queried interval. As DateTime
|
378
|
+
# +Integer+ +limit+:: Optional. Prices per currency pair. Defaul is 100. Min is 1. Max is 1_000
|
379
|
+
|
380
|
+
def get_converted_candles(target_currency:, symbols: nil, period: nil, sort: nil, from: nil, till: nil, limit: nil) # rubocop:disable Metrics/ParameterLists
|
381
|
+
public_get(
|
382
|
+
'public/converted/candles',
|
383
|
+
{ target_currency: target_currency, symbols: symbols, period: period, sort: sort, from: from, till: till, limit: limit }
|
384
|
+
)
|
385
|
+
end
|
386
|
+
|
387
|
+
# Gets OHLCV data regarding the last price converted to the target currency for the specified symbol
|
388
|
+
#
|
389
|
+
# Candles are used for OHLC representation
|
390
|
+
#
|
391
|
+
# The result contains candles with non-zero volume only (no trades = no candles)
|
392
|
+
#
|
393
|
+
# Conversion from the symbol quote currency to the target currency is the mean of "best" bid price and "best" ask price in the order book. If there is no "best" bid or ask price, the last price is returned.
|
394
|
+
#
|
395
|
+
# Requires no API key Access Rights
|
396
|
+
#
|
397
|
+
# https://api.exchange.cryptomkt.com/#candles
|
398
|
+
#
|
399
|
+
# +String+ +target_currency+:: Target currency for conversion
|
400
|
+
# +String+ +symbol+:: A symbol id
|
401
|
+
# +String+ +period+:: Optional. A valid tick interval. 'M1' (one minute), 'M3', 'M5', 'M15', 'M30', 'H1' (one hour), 'H4', 'D1' (one day), 'D7', '1M' (one month). Default is 'M30'
|
402
|
+
# +String+ +sort+:: Optional. Sort direction. 'ASC' or 'DESC'. Default is 'DESC'
|
403
|
+
# +String+ +from+:: Optional. Initial value of the queried interval. As DateTime
|
404
|
+
# +String+ +till+:: Optional. Last value of the queried interval. As DateTime
|
405
|
+
# +Integer+ +limit+:: Optional. Prices per currency pair. Defaul is 100. Min is 1. Max is 1_000
|
406
|
+
# +Integer+ +offset+:: Optional. Default is 0. Min is 0. Max is 100_000
|
407
|
+
|
408
|
+
def get_converted_candles_by_symbol(target_currency:, symbol:, period: nil, sort: nil, from: nil, till: nil, limit: nil, offset: nil) # rubocop:disable Metrics/ParameterLists
|
409
|
+
public_get(
|
410
|
+
"public/converted/candles/#{symbol}",
|
411
|
+
{ target_currency: target_currency, period: period, sort: sort, from: from, till: till, limit: limit, offset: offset }
|
412
|
+
)
|
413
|
+
end
|
414
|
+
|
415
|
+
######################
|
416
|
+
# Spot Trading calls #
|
417
|
+
######################
|
418
|
+
|
419
|
+
# Get the user's spot trading balance for all currencies with balance
|
420
|
+
#
|
421
|
+
# Requires the "Orderbook, History, Trading balance" API key Access Right
|
422
|
+
#
|
423
|
+
# https://api.exchange.cryptomkt.com/#get-spot-trading-balance
|
424
|
+
|
425
|
+
def get_spot_trading_balances # rubocop:disable Naming/AccessorMethodName
|
426
|
+
get('spot/balance')
|
427
|
+
end
|
428
|
+
|
429
|
+
# Get the user spot trading balance of a currency
|
430
|
+
#
|
431
|
+
# Requires the "Orderbook, History, Trading balance" API key Access Right
|
432
|
+
#
|
433
|
+
# https://api.exchange.cryptomkt.com/#get-spot-trading-balance
|
434
|
+
#
|
435
|
+
# ==== Params
|
436
|
+
# +String+ +currency+:: The currency code to query the balance
|
437
|
+
|
438
|
+
def get_spot_trading_balance(currency:)
|
439
|
+
balance = get("spot/balance/#{currency}")
|
440
|
+
balance['currency'] = currency
|
441
|
+
balance
|
442
|
+
end
|
443
|
+
|
444
|
+
# Get the user's active spot orders
|
445
|
+
#
|
446
|
+
# Requires the "Place/cancel orders" API key Access Right
|
447
|
+
#
|
448
|
+
# https://api.exchange.cryptomkt.com/#get-all-active-spot-orders
|
449
|
+
#
|
450
|
+
# ==== Params
|
451
|
+
# +String+ +symbol+:: Optional. A symbol for filtering the active spot orders
|
452
|
+
|
453
|
+
def get_all_active_spot_orders(symbol: nil)
|
454
|
+
get('spot/order', { symbol: symbol })
|
455
|
+
end
|
456
|
+
|
457
|
+
# Get an active spot order by its client order id
|
458
|
+
#
|
459
|
+
# Requires the "Place/cancel orders" API key Access Right
|
460
|
+
#
|
461
|
+
# https://api.exchange.cryptomkt.com/#get-active-spot-order
|
462
|
+
#
|
463
|
+
# ==== Params
|
464
|
+
# +String+ +client_order_id+:: The client order id of the order
|
465
|
+
|
466
|
+
def get_active_spot_order(client_order_id:)
|
467
|
+
get("spot/order/#{client_order_id}")
|
468
|
+
end
|
469
|
+
|
470
|
+
# Creates a new spot order
|
471
|
+
# For fee, for price accuracy and quantity, and for order status information see the api docs
|
472
|
+
#
|
473
|
+
# Requires the "Place/cancel orders" API key Access Right
|
474
|
+
#
|
475
|
+
# https://api.exchange.cryptomkt.com/#create-new-spot-order
|
476
|
+
#
|
477
|
+
# ==== Params
|
478
|
+
# +String+ +symbol+:: Trading symbol
|
479
|
+
# +String+ +side+:: Either 'buy' or 'sell'
|
480
|
+
# +String+ +quantity+:: Order quantity
|
481
|
+
# +String+ +client_order_id+:: Optional. If given must be unique within the trading day, including all active orders. If not given, is generated by the server
|
482
|
+
# +String+ +type+:: Optional. 'limit', 'market', 'stopLimit', 'stopMarket', 'takeProfitLimit' or 'takeProfitMarket'. Default is 'limit'
|
483
|
+
# +String+ +time_in_force+:: Optional. 'GTC', 'IOC', 'FOK', 'Day', 'GTD'. Default is 'GTC' if 'limit', 'stopLimit' or 'takeProfitLimit' order, Default is 'FOK' if 'market', 'stopMarket' or 'takeProfitMarket' order
|
484
|
+
# +String+ +price+:: Optional. Required for 'limit' and 'stopLimit'. limit price of the order
|
485
|
+
# +String+ +stop_price+:: Optional. Required for 'stopLimit' and 'stopMarket' orders. stop price of the order
|
486
|
+
# +String+ +expire_time+:: Optional. Required for orders with timeInForce = GDT
|
487
|
+
# +bool+ +strict_validate+:: Optional. If False, the server rounds half down for tickerSize and quantityIncrement. Example of ETHBTC: tickSize = '0.000001', then price '0.046016' is valid, '0.0460165' is invalid
|
488
|
+
# +bool+ +post_only+:: Optional. If True, your post_only order causes a match with a pre-existing order as a taker, then the order will be cancelled
|
489
|
+
# +String+ +take_rate+:: Optional. Liquidity taker fee, a fraction of order volume, such as 0.001 (for 0.1% fee). Can only increase the fee. Used for fee markup.
|
490
|
+
# +String+ +make_rate+:: Optional. Liquidity provider fee, a fraction of order volume, such as 0.001 (for 0.1% fee). Can only increase the fee. Used for fee markup.
|
491
|
+
|
492
|
+
def create_spot_order( # rubocop:disable Metrics/ParameterLists
|
493
|
+
symbol:, side:, quantity:, client_order_id: nil, type: nil, time_in_force: nil, price: nil,
|
494
|
+
stop_price: nil, expire_time: nil, strict_validate: nil, post_only: nil, take_rate: nil,
|
495
|
+
make_rate: nil
|
496
|
+
)
|
497
|
+
post(
|
498
|
+
'spot/order',
|
499
|
+
{ client_order_id: client_order_id, symbol: symbol, side: side, quantity: quantity, type: type,
|
500
|
+
time_in_force: time_in_force, price: price, stop_price: stop_price, expire_time: expire_time,
|
501
|
+
strict_validate: strict_validate, post_only: post_only, take_rate: take_rate, make_rate: make_rate }
|
502
|
+
)
|
503
|
+
end
|
504
|
+
|
505
|
+
# creates a list of spot orders
|
506
|
+
#
|
507
|
+
# = Types or contingency
|
508
|
+
# - 'allOrNone' (AON)
|
509
|
+
# - 'oneCancelAnother' (OCO)
|
510
|
+
# - 'oneTriggerOther' (OTO)
|
511
|
+
# - 'oneTriggerOneCancelOther' (OTOCO)
|
512
|
+
#
|
513
|
+
# = Restriction in the number of orders:
|
514
|
+
# - An AON list must have 2 or 3 orders
|
515
|
+
# - An OCO list must have 2 or 3 orders
|
516
|
+
# - An OTO list must have 2 or 3 orders
|
517
|
+
# - An OTOCO must have 3 or 4 orders
|
518
|
+
#
|
519
|
+
# = Symbol restrictions
|
520
|
+
# - For an AON order list, the symbol code of orders must be unique for each order in the list.
|
521
|
+
# - For an OCO order list, there are no symbol code restrictions.
|
522
|
+
# - For an OTO order list, there are no symbol code restrictions.
|
523
|
+
# - For an OTOCO order list, the symbol code of orders must be the same for all orders in the list (placing orders in different order books is not supported).
|
524
|
+
#
|
525
|
+
# = OrderType restrictions
|
526
|
+
# - For an AON order list, orders must be 'limit' or 'market'
|
527
|
+
# - For an OCO order list, orders must be 'limit', 'stopLimit', 'stopMarket', takeProfitLimit or takeProfitMarket.
|
528
|
+
# - An OCO order list cannot include more than one limit order (the same
|
529
|
+
# applies to secondary orders in an OTOCO order list).
|
530
|
+
# - For OTO order list, there are no order type restrictions.
|
531
|
+
# - For an OTOCO order list, the first order must be 'limit', 'market', 'stopLimit', 'stopMarket', takeProfitLimit or takeProfitMarket.
|
532
|
+
# - For an OTOCO order list, the secondary orders have the same restrictions as an OCO order
|
533
|
+
# - Default is 'limit'
|
534
|
+
#
|
535
|
+
# https://api.exchange.cryptomkt.com/#create-new-spot-order-list
|
536
|
+
#
|
537
|
+
# ==== Params
|
538
|
+
# +String+ +order_list_id+:: order list identifier. If ommited, it will be generated by the system. Must be equal to the client order id of the first order in the request
|
539
|
+
# +String+ +contingency_type+:: order list type. 'allOrNone', 'oneCancelOther' or 'oneTriggerOneCancelOther'
|
540
|
+
# +Array[]+ +orders+:: the list of orders. aech order in the list has the same parameters of a new spot order
|
541
|
+
|
542
|
+
def create_spot_order_list(
|
543
|
+
contingency_type:,
|
544
|
+
orders:,
|
545
|
+
order_list_id: nil
|
546
|
+
)
|
547
|
+
post(
|
548
|
+
'spot/order/list',
|
549
|
+
{
|
550
|
+
order_list_id: order_list_id,
|
551
|
+
contingency_type: contingency_type,
|
552
|
+
orders: orders
|
553
|
+
}
|
554
|
+
)
|
555
|
+
end
|
556
|
+
|
557
|
+
# Replaces a spot order
|
558
|
+
# For fee, for price accuracy and quantity, and for order status information see the api docs
|
559
|
+
#
|
560
|
+
# Requires the "Place/cancel orders" API key Access Right
|
561
|
+
#
|
562
|
+
# https://api.exchange.cryptomkt.com/#replace-spot-order
|
563
|
+
#
|
564
|
+
# ==== Params
|
565
|
+
# +String+ +client_order_id+:: client order id of the old order
|
566
|
+
# +String+ +new client order id+:: client order id for the new order
|
567
|
+
# +String+ +quantity+:: Order quantity
|
568
|
+
# +bool+ +strict_validate+:: Price and quantity will be checked for incrementation within the symbol’s tick size and quantity step. See the symbol's tick_size and quantity_increment
|
569
|
+
# +String+ +price+:: Required if order type is 'limit', 'stopLimit', or 'takeProfitLimit'. Order price
|
570
|
+
|
571
|
+
def replace_spot_order(
|
572
|
+
client_order_id:,
|
573
|
+
new_client_order_id:,
|
574
|
+
quantity:,
|
575
|
+
price: nil,
|
576
|
+
strict_validate: nil
|
577
|
+
)
|
578
|
+
patch(
|
579
|
+
"spot/order/#{client_order_id}",
|
580
|
+
{
|
581
|
+
new_client_order_id: new_client_order_id,
|
582
|
+
price: price,
|
583
|
+
quantity: quantity,
|
584
|
+
strict_validate: strict_validate
|
585
|
+
}
|
586
|
+
)
|
587
|
+
end
|
588
|
+
|
589
|
+
# Cancel all active spot orders
|
590
|
+
#
|
591
|
+
# Requires the "Place/cancel orders" API key Access Right
|
592
|
+
#
|
593
|
+
# https://api.exchange.cryptomkt.com/#cancel-all-spot-orders
|
594
|
+
#
|
595
|
+
|
596
|
+
def cancel_all_spot_orders
|
597
|
+
delete('spot/order')
|
598
|
+
end
|
599
|
+
|
600
|
+
# Cancel the order with the client order id
|
601
|
+
#
|
602
|
+
# Requires the "Place/cancel orders" API key Access Right
|
603
|
+
#
|
604
|
+
# https://api.exchange.cryptomkt.com/#cancel-spot-order
|
605
|
+
#
|
606
|
+
# ==== Params
|
607
|
+
# +String+ +client_order_id+:: client order id of the order to cancel
|
608
|
+
|
609
|
+
def cancel_spot_order(client_order_id:)
|
610
|
+
delete("spot/order/#{client_order_id}")
|
611
|
+
end
|
612
|
+
|
613
|
+
# Get the personal trading commission rates for all symbols
|
614
|
+
#
|
615
|
+
# Requires the "Place/cancel orders" API key Access Right
|
616
|
+
#
|
617
|
+
# https://api.exchange.cryptomkt.com/#get-all-trading-commissions
|
618
|
+
|
619
|
+
def get_all_trading_commission # rubocop:disable Naming/AccessorMethodName
|
620
|
+
get('spot/fee')
|
621
|
+
end
|
622
|
+
|
623
|
+
# Get the personal trading commission rate of a symbol
|
624
|
+
#
|
625
|
+
# Requires the "Place/cancel orders" API key Access Right
|
626
|
+
#
|
627
|
+
# https://api.exchange.cryptomkt.com/#get-trading-commission
|
628
|
+
#
|
629
|
+
# ==== Params
|
630
|
+
# +String+ +symbol+:: The symbol of the commission rate
|
631
|
+
|
632
|
+
def get_trading_commission(symbol:)
|
633
|
+
commission = get("spot/fee/#{symbol}")
|
634
|
+
commission['symbol'] = symbol
|
635
|
+
commission
|
636
|
+
end
|
637
|
+
|
638
|
+
########################
|
639
|
+
# spot trading history #
|
640
|
+
########################
|
641
|
+
|
642
|
+
# Get all the spot orders
|
643
|
+
# Orders without executions are deleted after 24 hours
|
644
|
+
# 'from' param and 'till' param must have the same format, both id or both timestamp
|
645
|
+
#
|
646
|
+
# Requires the "Orderbook, History, Trading balance" API key Access Right
|
647
|
+
#
|
648
|
+
# https://api.exchange.cryptomkt.com/#spot-orders-history
|
649
|
+
#
|
650
|
+
# ==== Params
|
651
|
+
# +String+ +symbol+:: Optional. Filter orders by symbol
|
652
|
+
# +String+ +by+:: Optional. Sorting parameter. 'id' or 'timestamp'. Default is 'timestamp'
|
653
|
+
# +String+ +sort+:: Optional. Sort direction. 'ASC' or 'DESC'. Default is 'DESC'
|
654
|
+
# +String+ +from+:: Optional. Initial value of the queried interval
|
655
|
+
# +String+ +till+:: Optional. Last value of the queried interval
|
656
|
+
# +Integer+ +limit+:: Optional. Prices per currency pair. Defaul is 100. Max is 1_000
|
657
|
+
# +Integer+ +offset+:: Optional. Default is 0. Max is 100_000
|
658
|
+
|
659
|
+
def get_spot_orders_history( # rubocop:disable Metrics/ParameterLists
|
660
|
+
client_order_id: nil, symbol: nil, sort: nil, by: nil, from: nil,
|
661
|
+
till: nil, limit: nil, offset: nil
|
662
|
+
)
|
663
|
+
get(
|
664
|
+
'spot/history/order',
|
665
|
+
{ client_order_id: client_order_id, symbol: symbol, sort: sort,
|
666
|
+
by: by, from: from, till: till, limit: limit, offset: offset }
|
667
|
+
)
|
668
|
+
end
|
669
|
+
|
670
|
+
# Get the user's spot trading history
|
671
|
+
#
|
672
|
+
# Requires the "Orderbook, History, Trading balance" API key Access Right
|
673
|
+
#
|
674
|
+
# https://api.exchange.cryptomkt.com/#spot-trades-history
|
675
|
+
#
|
676
|
+
# ==== Params
|
677
|
+
# +String+ +order id+:: Optional. Order unique identifier as assigned by the exchange
|
678
|
+
# +String+ +symbol+:: Optional. Filter orders by symbol
|
679
|
+
# +String+ +by+:: Optional. Sorting parameter. 'id' or 'timestamp'. Default is 'timestamp'
|
680
|
+
# +String+ +sort+:: Optional. Sort direction. 'ASC' or 'DESC'. Default is 'DESC'
|
681
|
+
# +String+ +from+:: Optional. Initial value of the queried interval
|
682
|
+
# +String+ +till+:: Optional. Last value of the queried interval
|
683
|
+
# +Integer+ +limit+:: Optional. Prices per currency pair. Defaul is 100. Max is 1_000
|
684
|
+
# +Integer+ +offset+:: Optional. Default is 0. Max is 100_000
|
685
|
+
|
686
|
+
def get_spot_trades_history( # rubocop:disable Metrics/ParameterLists
|
687
|
+
order_id: nil, symbol: nil, sort: nil, by: nil, from: nil,
|
688
|
+
till: nil, limit: nil, offset: nil
|
689
|
+
)
|
690
|
+
get(
|
691
|
+
'spot/history/trade',
|
692
|
+
{ order_id: order_id, symbol: symbol, sort: sort,
|
693
|
+
by: by, from: from, till: till, limit: limit, offset: offset }
|
694
|
+
)
|
695
|
+
end
|
696
|
+
|
697
|
+
#####################
|
698
|
+
# Wallet Management #
|
699
|
+
#####################
|
700
|
+
|
701
|
+
# Get the user's wallet balance for all currencies with balance
|
702
|
+
#
|
703
|
+
# Requires the "Payment information" API key Access Right
|
704
|
+
#
|
705
|
+
# https://api.exchange.cryptomkt.com/#wallet-balance
|
706
|
+
|
707
|
+
def get_wallet_balances # rubocop:disable Naming/AccessorMethodName
|
708
|
+
get('wallet/balance')
|
709
|
+
end
|
710
|
+
|
711
|
+
# Get the user's wallet balance of a currency
|
712
|
+
#
|
713
|
+
# Requires the "Payment information" API key Access Right
|
714
|
+
#
|
715
|
+
# https://api.exchange.cryptomkt.com/#wallet-balance
|
716
|
+
#
|
717
|
+
# ==== Params
|
718
|
+
# +String+ +currency+:: The currency code to query the balance
|
719
|
+
|
720
|
+
def get_wallet_balance(currency:)
|
721
|
+
get("wallet/balance/#{currency}")
|
722
|
+
end
|
723
|
+
|
724
|
+
# Get a list with the current addresses of the user
|
725
|
+
#
|
726
|
+
# Requires the "Payment information" API key Access Right
|
727
|
+
#
|
728
|
+
# https://api.exchange.cryptomkt.com/#get-deposit-crypto-address
|
729
|
+
|
730
|
+
def get_deposit_crypto_addresses # rubocop:disable Naming/AccessorMethodName
|
731
|
+
get('wallet/crypto/address')
|
732
|
+
end
|
733
|
+
|
734
|
+
# Get the current addresses of a currency of the user
|
735
|
+
#
|
736
|
+
# Getting the address of a new currency will create an address
|
737
|
+
#
|
738
|
+
# Requires the "Payment information" API key Access Right
|
739
|
+
#
|
740
|
+
# https://api.exchange.cryptomkt.com/#get-deposit-crypto-address
|
741
|
+
#
|
742
|
+
# ==== Params
|
743
|
+
# +String+ +currency+:: Currency to get the address
|
744
|
+
# +String+ +network_code+:: Optional. network code
|
745
|
+
|
746
|
+
def get_deposit_crypto_address(currency: nil, network_code: nil)
|
747
|
+
result = get('wallet/crypto/address', { currency: currency, network_code: network_code })
|
748
|
+
raise CryptomarketSDKException 'Too many currencies recieved, expected 1 currency' if result.length != 1
|
749
|
+
|
750
|
+
result[0]
|
751
|
+
end
|
752
|
+
|
753
|
+
# Creates a new address for a currency
|
754
|
+
#
|
755
|
+
# Requires the "Payment information" API key Access Right
|
756
|
+
#
|
757
|
+
# https://api.exchange.cryptomkt.com/#generate-deposit-crypto-address
|
758
|
+
#
|
759
|
+
# ==== Params
|
760
|
+
# +String+ +currency+:: currency to create a new address
|
761
|
+
# +String+ +network_code+:: Optional. network code
|
762
|
+
|
763
|
+
def create_deposit_crypto_address(currency:, network_code: nil)
|
764
|
+
post('wallet/crypto/address', { currency: currency, network_code: network_code })
|
765
|
+
end
|
766
|
+
|
767
|
+
# Get the last 10 unique addresses used for deposit, by currency
|
768
|
+
# Addresses used a long time ago may be omitted, even if they are among the last 10 unique addresses
|
769
|
+
#
|
770
|
+
# Requires the "Payment information" API key Access Right
|
771
|
+
#
|
772
|
+
# https://api.exchange.cryptomkt.com/#last-10-deposit-crypto-addresses
|
773
|
+
#
|
774
|
+
# ==== Params
|
775
|
+
# +String+ +currency+:: currency to get the list of addresses
|
776
|
+
# +String+ +network_code+:: Optional. network code
|
777
|
+
|
778
|
+
def get_last_10_deposit_crypto_addresses(currency:, network_code: nil)
|
779
|
+
get('wallet/crypto/address/recent-deposit', { currency: currency, network_code: network_code })
|
780
|
+
end
|
781
|
+
|
782
|
+
# Get the last 10 unique addresses used for withdrawals, by currency
|
783
|
+
# Addresses used a long time ago may be omitted, even if they are among the last 10 unique addresses
|
784
|
+
#
|
785
|
+
# Requires the "Payment information" API key Access Right
|
786
|
+
#
|
787
|
+
# https://api.exchange.cryptomkt.com/#last-10-withdrawal-crypto-addresses
|
788
|
+
#
|
789
|
+
# ==== Params
|
790
|
+
# +String+ +currency+:: currency to get the list of addresses
|
791
|
+
# +String+ +network_code+:: Optional. network code
|
792
|
+
|
793
|
+
def get_last_10_withdrawal_crypto_addresses(currency:, network_code: nil)
|
794
|
+
get('wallet/crypto/address/recent-withdraw', { currency: currency, network_code: network_code })
|
795
|
+
end
|
796
|
+
|
797
|
+
# Please take note that changing security settings affects withdrawals:
|
798
|
+
# - It is impossible to withdraw funds without enabling the two-factor authentication (2FA)
|
799
|
+
# - Password reset blocks withdrawals for 72 hours
|
800
|
+
# - Each time a new address is added to the whitelist, it takes 48 hours before that address becomes active for withdrawal
|
801
|
+
# Successful response to the request does not necessarily mean the resulting transaction got executed immediately. It has to be processed first and may eventually be rolled back
|
802
|
+
# To see whether a transaction has been finalized, call #get_transaction
|
803
|
+
#
|
804
|
+
# Requires the "Withdraw cryptocurrencies" API key Access Right
|
805
|
+
#
|
806
|
+
# https://api.exchange.cryptomkt.com/#withdraw-crypto
|
807
|
+
#
|
808
|
+
# ==== Params
|
809
|
+
# +String+ +currency+:: currency code of the crypto to withdraw
|
810
|
+
# +float+ +amount+:: amount to be sent to the specified address
|
811
|
+
# +String+ +address+:: address identifier
|
812
|
+
# +String+ +network_code+:: Optional. network code
|
813
|
+
# +String+ +payment id+:: Optional.
|
814
|
+
# +bool+ +include fee+:: Optional. If true then the amount includes fees. Default is false
|
815
|
+
# +bool+ +auto commit+:: Optional. If false then you should commit or rollback the transaction in an hour. Used in two phase commit schema. Default is true
|
816
|
+
# +String+ +use offchain+:: Optional. Whether the withdrawal may be comitted offchain. Accepted values are 'never', 'optionaly' and 'required'.
|
817
|
+
# +String+ +public comment+:: Optional. Maximum lenght is 255
|
818
|
+
|
819
|
+
def withdraw_crypto( # rubocop:disable Metrics/ParameterLists
|
820
|
+
currency:, amount:, address:, network_code: nil, payment_id: nil,
|
821
|
+
include_fee: nil, auto_commit: nil, use_offchain: nil, public_comment: nil
|
822
|
+
)
|
823
|
+
post(
|
824
|
+
'wallet/crypto/withdraw',
|
825
|
+
{ currency: currency, amount: amount, address: address, network_code: network_code,
|
826
|
+
payment_id: payment_id, include_fee: include_fee, auto_commit: auto_commit,
|
827
|
+
use_offchain: use_offchain, public_comment: public_comment }
|
828
|
+
)['id']
|
829
|
+
end
|
830
|
+
|
831
|
+
# Commit a withdrawal
|
832
|
+
#
|
833
|
+
# Requires the "Withdraw cryptocurrencies" API key Access Right
|
834
|
+
#
|
835
|
+
# https://api.exchange.cryptomkt.com/#withdraw-crypto-commit-or-rollback
|
836
|
+
#
|
837
|
+
# ==== Params
|
838
|
+
# +String+ +id+:: the withdrawal transaction identifier
|
839
|
+
|
840
|
+
def withdraw_crypto_commit(id:)
|
841
|
+
put("wallet/crypto/withdraw/#{id}")['result']
|
842
|
+
end
|
843
|
+
|
844
|
+
# Rollback a withdrawal
|
845
|
+
#
|
846
|
+
# Requires the "Withdraw cryptocurrencies" API key Access Right
|
847
|
+
#
|
848
|
+
# https://api.exchange.cryptomkt.com/#withdraw-crypto-commit-or-rollback
|
849
|
+
#
|
850
|
+
# ==== Params
|
851
|
+
# +String+ +id+:: the withdrawal transaction identifier
|
852
|
+
|
853
|
+
def withdraw_crypto_rollback(id:)
|
854
|
+
delete("wallet/crypto/withdraw/#{id}")['result']
|
855
|
+
end
|
856
|
+
|
857
|
+
# Get an estimates for withdrawal fees of currencies
|
858
|
+
#
|
859
|
+
# Requires the "Payment information" API key Access Right
|
860
|
+
#
|
861
|
+
# https://api.exchange.cryptomkt.com/#estimate-withdrawal-fees
|
862
|
+
#
|
863
|
+
# ==== Params
|
864
|
+
# +Array[]+ +fee_requests+:: the list of fee requests, each request is a Hash in the form {currency:"string", amount:"string", network_code:"optional string"}
|
865
|
+
|
866
|
+
def get_estimate_withdrawal_fees(fee_requests)
|
867
|
+
params = fee_requests
|
868
|
+
post('wallet/crypto/fees/estimate', params)
|
869
|
+
end
|
870
|
+
|
871
|
+
# Get an estimate of the withdrawal fee
|
872
|
+
#
|
873
|
+
# Requires the "Payment information" API key Access Right
|
874
|
+
#
|
875
|
+
# https://api.exchange.cryptomkt.com/#estimate-withdrawal-fee
|
876
|
+
#
|
877
|
+
# ==== Params
|
878
|
+
# +String+ +currency+:: the currency code for withdrawal
|
879
|
+
# +float+ +amount+:: the expected withdraw amount
|
880
|
+
|
881
|
+
def get_estimate_withdrawal_fee(currency:, amount:, network_code: nil)
|
882
|
+
params = { amount: amount, currency: currency, network_code: network_code }
|
883
|
+
get('wallet/crypto/fee/estimate', params)['fee']
|
884
|
+
end
|
885
|
+
|
886
|
+
# Converts between currencies
|
887
|
+
# Successful response to the request does not necessarily mean the resulting transaction got executed immediately. It has to be processed first and may eventually be rolled back
|
888
|
+
# To see whether a transaction has been finalized, call #get_transaction
|
889
|
+
#
|
890
|
+
# Requires the "Payment information" API key Access Right
|
891
|
+
#
|
892
|
+
# https://api.exchange.cryptomkt.com/#convert-between-currencies
|
893
|
+
#
|
894
|
+
# ==== Params
|
895
|
+
# +String+ +from currency+:: currency code of origin
|
896
|
+
# +String+ +to currency+:: currency code of destiny
|
897
|
+
# +float+ +amount+:: the amount to be converted
|
898
|
+
|
899
|
+
def convert_between_currencies(from_currency:, to_currency:, amount:)
|
900
|
+
post(
|
901
|
+
'wallet/convert',
|
902
|
+
{
|
903
|
+
from_currency: from_currency,
|
904
|
+
to_currency: to_currency,
|
905
|
+
amount: amount
|
906
|
+
}
|
907
|
+
)['result']
|
908
|
+
end
|
909
|
+
|
910
|
+
# Check if an address is from this account
|
911
|
+
#
|
912
|
+
# Requires the "Payment information" API key Access Right
|
913
|
+
#
|
914
|
+
# https://api.exchange.cryptomkt.com/#check-if-crypto-address-belongs-to-current-account
|
915
|
+
#
|
916
|
+
# ==== Params
|
917
|
+
# +String+ +address+:: address to check
|
918
|
+
|
919
|
+
def crypto_address_belongs_to_current_account?(address:)
|
920
|
+
get('wallet/crypto/address/check-mine', { address: address })['result']
|
921
|
+
end
|
922
|
+
|
923
|
+
# Transfer funds between account types
|
924
|
+
# 'source' param and 'destination' param must be different account types
|
925
|
+
#
|
926
|
+
# Requires the "Payment information" API key Access Right
|
927
|
+
#
|
928
|
+
# https://api.exchange.cryptomkt.com/#transfer-between-wallet-and-exchange
|
929
|
+
#
|
930
|
+
# ==== Params
|
931
|
+
# +String+ +currency+:: currency code for transfering
|
932
|
+
# +float+ +amount+:: amount to be transfered
|
933
|
+
# +String+ +source+:: transfer source account type. Either 'wallet' or 'spot'
|
934
|
+
# +String+ +destination+:: transfer source account type. Either 'wallet' or 'spot'
|
935
|
+
|
936
|
+
def transfer_between_wallet_and_exchange(currency:, amount:, source:, destination:)
|
937
|
+
post(
|
938
|
+
'wallet/transfer',
|
939
|
+
{
|
940
|
+
currency: currency,
|
941
|
+
amount: amount,
|
942
|
+
source: source,
|
943
|
+
destination: destination
|
944
|
+
}
|
945
|
+
)
|
946
|
+
end
|
947
|
+
|
948
|
+
# Transfer funds to another user
|
949
|
+
#
|
950
|
+
# Requires the "Withdraw cryptocurrencies" API key Access Right
|
951
|
+
#
|
952
|
+
# https://api.exchange.cryptomkt.com/#transfer-money-to-another-user
|
953
|
+
#
|
954
|
+
# ==== Params
|
955
|
+
# +String+ +currency+:: currency code
|
956
|
+
# +float+ +amount+:: amount to be transfered
|
957
|
+
# +String+ +transfer by+:: type of identifier. Either 'email' or 'username'
|
958
|
+
# +String+ +identifier+:: the email or username of the recieving user
|
959
|
+
|
960
|
+
def transfer_money_to_another_user(currency:, amount:, by:, identifier:)
|
961
|
+
post(
|
962
|
+
'wallet/internal/withdraw',
|
963
|
+
{
|
964
|
+
currency: currency,
|
965
|
+
amount: amount,
|
966
|
+
by: by,
|
967
|
+
identifier: identifier
|
968
|
+
}
|
969
|
+
)
|
970
|
+
end
|
971
|
+
|
972
|
+
# Get the transaction history of the account
|
973
|
+
# Important:
|
974
|
+
# - The list of supported transaction types may be expanded in future versions
|
975
|
+
# - Some transaction subtypes are reserved for future use and do not purport to provide any functionality on the platform
|
976
|
+
# - The list of supported transaction subtypes may be expanded in future versions
|
977
|
+
#
|
978
|
+
# Requires the "Payment information" API key Access Right
|
979
|
+
#
|
980
|
+
# https://api.exchange.cryptomkt.com/#get-transactions-history
|
981
|
+
#
|
982
|
+
# ==== Params
|
983
|
+
# +Array[String]+ +tx_ids+:: Optional. List of transaction identifiers to query
|
984
|
+
# +Array[String]+ +types+:: Optional. List of transaction types to query. valid types are: 'DEPOSIT', 'WITHDRAW', 'TRANSFER' and 'SWAP'
|
985
|
+
# +Array[String]+ +subtyes+:: Optional. List of transaction subtypes to query. valid subtypes are: 'UNCLASSIFIED', 'BLOCKCHAIN', 'AIRDROP', 'AFFILIATE', 'STAKING', 'BUY_CRYPTO', 'OFFCHAIN', 'FIAT', 'SUB_ACCOUNT', 'WALLET_TO_SPOT', 'SPOT_TO_WALLET', 'WALLET_TO_DERIVATIVES', 'DERIVATIVES_TO_WALLET', 'CHAIN_SWITCH_FROM', 'CHAIN_SWITCH_TO' and 'INSTANT_EXCHANGE'
|
986
|
+
# +Array[String]+ +statuses+:: Optional. List of statuses to query. valid subtypes are: 'CREATED', 'PENDING', 'FAILED', 'SUCCESS' and 'ROLLED_BACK'
|
987
|
+
# +Array[String]+ +currencies+:: Optional. Currency codes of the transactions to fetch
|
988
|
+
# +Array[String]+ +networks+:: Optional. Network codes of the transactions to fetch
|
989
|
+
# +String+ +order_by+:: Optional. sorting parameter.'created_at' or 'id'. Default is 'created_at'
|
990
|
+
# +String+ +from+:: Optional. Interval initial value when ordering by 'created_at'. As Datetime
|
991
|
+
# +String+ +till+:: Optional. Interval end value when ordering by 'created_at'. As Datetime
|
992
|
+
# +String+ +id_from+:: Optional. Interval initial value when ordering by id. Min is 0
|
993
|
+
# +String+ +id_till+:: Optional. Interval end value when ordering by id. Min is 0
|
994
|
+
# +String+ +sort+:: Optional. Sort direction. 'ASC' or 'DESC'. Default is 'DESC'
|
995
|
+
# +Integer+ +limit+:: Optional. Transactions per query. Defaul is 100. Max is 1_000
|
996
|
+
# +Integer+ +offset+:: Optional. Default is 0. Max is 100_000
|
997
|
+
# +bool+ +group_transactions+:: Optional. Flag indicating whether the returned transactions will be parts of a single operation. Default is false
|
998
|
+
|
999
|
+
def get_transaction_history( # rubocop:disable Metrics/ParameterLists
|
1000
|
+
currency: nil, from: nil, till: nil, types: nil, subtypes: nil, statuses: nil,
|
1001
|
+
currencies: nil, networks: nil, id_from: nil, id_till: nil, tx_ids: nil, order_by: nil,
|
1002
|
+
sort: nil, limit: nil, offset: nil, group_transactions: nil
|
1003
|
+
)
|
1004
|
+
get(
|
1005
|
+
'wallet/transactions',
|
1006
|
+
{ currency: currency, from: from, till: till, types: types, subtypes: subtypes, statuses: statuses,
|
1007
|
+
currencies: currencies, networks: networks, id_from: id_from, id_till: id_till, tx_ids: tx_ids,
|
1008
|
+
order_by: order_by, sort: sort, limit: limit, offset: offset, group_transactions: group_transactions }
|
1009
|
+
)
|
1010
|
+
end
|
1011
|
+
|
1012
|
+
# Get a transaction by its identifier
|
1013
|
+
#
|
1014
|
+
# Requires the "Payment information" API key Access Right
|
1015
|
+
#
|
1016
|
+
# https://api.exchange.cryptomkt.com/#get-transactions-history
|
1017
|
+
#
|
1018
|
+
# ==== Params
|
1019
|
+
# +String+ +id+:: The identifier of the transaction
|
1020
|
+
|
1021
|
+
def get_transaction(id:)
|
1022
|
+
get("wallet/transactions/#{id}")
|
1023
|
+
end
|
1024
|
+
|
1025
|
+
# get the status of the offchain
|
1026
|
+
#
|
1027
|
+
# Requires the "Payment information" API key Access Right
|
1028
|
+
#
|
1029
|
+
# https://api.exchange.cryptomkt.com/#check-if-offchain-is-available
|
1030
|
+
#
|
1031
|
+
# ==== Params
|
1032
|
+
# +String+ +currency+:: currency code
|
1033
|
+
# +String+ +address+:: address identifier
|
1034
|
+
# +String+ +payment id+:: Optional.
|
1035
|
+
|
1036
|
+
def offchain_available?(
|
1037
|
+
currency:,
|
1038
|
+
address:,
|
1039
|
+
payment_id: nil
|
1040
|
+
)
|
1041
|
+
post(
|
1042
|
+
'wallet/crypto/check-offchain-available',
|
1043
|
+
{
|
1044
|
+
currency: currency,
|
1045
|
+
address: address,
|
1046
|
+
payment_id: payment_id
|
1047
|
+
}
|
1048
|
+
)['result']
|
1049
|
+
end
|
1050
|
+
|
1051
|
+
# Get the list of amount locks
|
1052
|
+
#
|
1053
|
+
# Requires the "Payment information" API key Access Right
|
1054
|
+
#
|
1055
|
+
# https://api.exchange.cryptomkt.com/#get-amount-locks
|
1056
|
+
#
|
1057
|
+
# ==== Params
|
1058
|
+
# +String+ +currency+:: Optional. Currency code
|
1059
|
+
# +bool+ +active+:: Optional. value showing whether the lock is active
|
1060
|
+
# +Integer+ +limit+:: Optional. Dafault is 100. Min is 0. Max is 1_000
|
1061
|
+
# +Integer+ +offset+:: Optional. Default is 0. Min is 0
|
1062
|
+
# +String+ +from+:: Optional. Interval initial value. As Datetime
|
1063
|
+
# +String+ +till+:: Optional. Interval end value. As Datetime
|
1064
|
+
|
1065
|
+
def get_amount_locks( # rubocop:disable Metrics/ParameterLists
|
1066
|
+
currency: nil, active: nil, limit: nil, offset: nil, from: nil, till: nil
|
1067
|
+
)
|
1068
|
+
get(
|
1069
|
+
'wallet/amount-locks',
|
1070
|
+
{ currency: currency, active: active, limit: limit, offset: offset, from: from, till: till }
|
1071
|
+
)
|
1072
|
+
end
|
1073
|
+
|
1074
|
+
# Returns list of sub-accounts per a super account.
|
1075
|
+
#
|
1076
|
+
# Requires no API key Access Rights.
|
1077
|
+
#
|
1078
|
+
# https://api.exchange.cryptomkt.com/#sub-accounts
|
1079
|
+
|
1080
|
+
def get_sub_account_list # rubocop:disable Naming/AccessorMethodName
|
1081
|
+
get(
|
1082
|
+
'sub-account'
|
1083
|
+
)['result']
|
1084
|
+
end
|
1085
|
+
|
1086
|
+
# Freezes sub-accounts listed
|
1087
|
+
# Sub-accounts frozen wouldn't be able to:
|
1088
|
+
# * login
|
1089
|
+
# * withdraw funds
|
1090
|
+
# * trade
|
1091
|
+
# * complete pending orders
|
1092
|
+
# * use API keys
|
1093
|
+
#
|
1094
|
+
# For any sub-account listed, all orders will be canceled and all funds will be transferred form the Trading balance
|
1095
|
+
#
|
1096
|
+
# Requires no API key Access Rights
|
1097
|
+
#
|
1098
|
+
# https://api.exchange.cryptomkt.com/#freeze-sub-account
|
1099
|
+
#
|
1100
|
+
# ==== Params
|
1101
|
+
# +Array[String]+ +sub_account_ids+:: A list of sub-account ids to freeze
|
1102
|
+
def freeze_sub_accounts(
|
1103
|
+
sub_account_ids:
|
1104
|
+
)
|
1105
|
+
post(
|
1106
|
+
'sub-account/freeze',
|
1107
|
+
{
|
1108
|
+
sub_account_ids: sub_account_ids
|
1109
|
+
}
|
1110
|
+
)['result']
|
1111
|
+
end
|
1112
|
+
|
1113
|
+
# Activates sub-accounts listed. It would make sub-accounts active after being frozen
|
1114
|
+
#
|
1115
|
+
# Requires no API key Access Rights
|
1116
|
+
#
|
1117
|
+
# https://api.exchange.cryptomkt.com/#activate-sub-account
|
1118
|
+
#
|
1119
|
+
# ==== Params
|
1120
|
+
# +Array[String]+ +sub_account_ids+:: A list of sub-account ids to activate
|
1121
|
+
def activate_sub_accounts(
|
1122
|
+
sub_account_ids:
|
1123
|
+
)
|
1124
|
+
post(
|
1125
|
+
'sub-account/activate',
|
1126
|
+
{
|
1127
|
+
sub_account_ids: sub_account_ids
|
1128
|
+
}
|
1129
|
+
)['result']
|
1130
|
+
end
|
1131
|
+
|
1132
|
+
# Transfers funds from the super-account to a sub-account or from a sub-account to the super-account
|
1133
|
+
# and returns the transaction id
|
1134
|
+
#
|
1135
|
+
# Requires the "Withdraw cryptocurrencies" API key Access Right
|
1136
|
+
#
|
1137
|
+
# https://api.exchange.cryptomkt.com/#transfer-funds
|
1138
|
+
#
|
1139
|
+
# ==== Params
|
1140
|
+
# +String+ +sub_account_ids+:: id of the sub-account to transfer funds from/to
|
1141
|
+
# +String+ +amount+:: amount to transfer
|
1142
|
+
# +String+ +currency+:: currency to transfer
|
1143
|
+
# +String+ +type+:: Direction of transfer, "to_sub_account" or "from_sub_account"
|
1144
|
+
def transfer_funds(
|
1145
|
+
sub_account_id:,
|
1146
|
+
amount:,
|
1147
|
+
currency:,
|
1148
|
+
type:
|
1149
|
+
)
|
1150
|
+
post(
|
1151
|
+
'sub-account/transfer',
|
1152
|
+
{
|
1153
|
+
sub_account_id: sub_account_id,
|
1154
|
+
amount: amount,
|
1155
|
+
currency: currency,
|
1156
|
+
type: type
|
1157
|
+
}
|
1158
|
+
)['result']
|
1159
|
+
end
|
1160
|
+
|
1161
|
+
# Returns a list of withdrawal settings for sub-accounts listed
|
1162
|
+
#
|
1163
|
+
# Requires the "Payment information" API key Access Right
|
1164
|
+
#
|
1165
|
+
# https://api.exchange.cryptomkt.com/#get-acl-settings
|
1166
|
+
#
|
1167
|
+
# ==== Params
|
1168
|
+
# +Array[String]+ +sub_account_ids+:: A list of sub-account ids to get the acl settings
|
1169
|
+
|
1170
|
+
def get_acl_settings(
|
1171
|
+
sub_account_ids:
|
1172
|
+
)
|
1173
|
+
get(
|
1174
|
+
'sub-account/acl',
|
1175
|
+
{
|
1176
|
+
sub_account_ids: sub_account_ids
|
1177
|
+
}
|
1178
|
+
)['result']
|
1179
|
+
end
|
1180
|
+
|
1181
|
+
# Returns a list of withdrawal settings for sub-accounts listed
|
1182
|
+
#
|
1183
|
+
# Requires the "Payment information" API key Access Right
|
1184
|
+
#
|
1185
|
+
# https://api.exchange.cryptomkt.com/#get-acl-settings
|
1186
|
+
#
|
1187
|
+
# ==== Params
|
1188
|
+
# +Array[String]+ +sub_account_ids+:: A list of sub-account ids to get the acl settings
|
1189
|
+
# +bool+ +deposit_address_generation_enabled+:: Optional. Enables deposits
|
1190
|
+
# +bool+ +withdraw_enabled+:: Optional. Enables withdrawals
|
1191
|
+
# +String+ +description+:: Optional. Textual description
|
1192
|
+
# +String+ +created_at+:: Optional. ACL creation time
|
1193
|
+
# +String+ +updated_at+:: Optional. ACL update time
|
1194
|
+
|
1195
|
+
def change_acl_settings( # rubocop:disable Metrics/ParameterLists
|
1196
|
+
sub_account_ids:, deposit_address_generation_enabled: nil, withdraw_enabled: nil,
|
1197
|
+
description: nil, created_at: nil, updated_at: nil
|
1198
|
+
)
|
1199
|
+
post(
|
1200
|
+
'sub-account/acl',
|
1201
|
+
{ sub_account_ids: sub_account_ids, deposit_address_generation_enabled: deposit_address_generation_enabled,
|
1202
|
+
withdraw_enabled: withdraw_enabled, description: description, created_at: created_at, updated_at: updated_at }
|
1203
|
+
)['result']
|
1204
|
+
end
|
1205
|
+
|
1206
|
+
# Returns non-zero balance values by sub-account
|
1207
|
+
# Report will include the wallet and Trading balances for each currency
|
1208
|
+
# It is functional with no regard to the state of a sub-account
|
1209
|
+
#
|
1210
|
+
# Requires the "Payment information" API key Access Right
|
1211
|
+
#
|
1212
|
+
# https://api.exchange.cryptomkt.com/#get-sub-account-balance
|
1213
|
+
#
|
1214
|
+
# ==== Params
|
1215
|
+
# +String+ +sub_account_id+:: The id of the sub-account
|
1216
|
+
def get_sub_account_balance(
|
1217
|
+
sub_account_id:
|
1218
|
+
)
|
1219
|
+
get(
|
1220
|
+
"sub-account/balance/#{sub_account_id}"
|
1221
|
+
)['result']
|
1222
|
+
end
|
1223
|
+
|
1224
|
+
# Returns sub-account crypto address for currency
|
1225
|
+
#
|
1226
|
+
# Requires the "Payment information" API key Access Right
|
1227
|
+
#
|
1228
|
+
# https://api.exchange.cryptomkt.com/#get-sub-account-crypto-address
|
1229
|
+
#
|
1230
|
+
# ==== Params
|
1231
|
+
# +String+ +sub_account_id+:: The id of the sub-account
|
1232
|
+
# +String+ +currency+:: The currency of the address
|
1233
|
+
def get_sub_account_crypto_address(
|
1234
|
+
sub_account_id:,
|
1235
|
+
currency:
|
1236
|
+
)
|
1237
|
+
get(
|
1238
|
+
"sub-account/crypto/address/#{sub_account_id}/#{currency}"
|
1239
|
+
)['result']['address']
|
1240
|
+
end
|
1241
|
+
end
|
1242
|
+
end
|