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