cryptomarket-sdk 3.2.0 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/cryptomarket/client.rb +158 -76
- data/lib/cryptomarket/http_manager.rb +4 -4
- data/lib/cryptomarket/websocket/auth_client.rb +1 -1
- data/lib/cryptomarket/websocket/client_base.rb +1 -1
- data/lib/cryptomarket/websocket/market_data_client.rb +2 -2
- data/lib/cryptomarket/websocket/trading_client.rb +15 -14
- data/lib/cryptomarket/websocket/wallet_client.rb +7 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fd3bed22efeb710b06ddfdc3e22d0d36057eee7b8f313303d12ff1e79073e109
|
4
|
+
data.tar.gz: 6f1dbcd521e512381bd4a07969e1adaad5ef4a3e86753fa27b9bb2d5b4e9b4ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 37fde84fe738a9e068c49d69d0aecdd5321fd73e2f05a688d11d1fd355e547f31a6c4a7b871f129159ee78fc95f5046b87e317981691b4424da7f6577d0ba982
|
7
|
+
data.tar.gz: 3a9be72f60d306bfe2c3e7e16be6a91f184d58a4a69bd2e3deba928d3465294cf4c4f4c4036333246af51b2c983cf51f7cab754186ec3616f806d3bdabe7c242
|
data/README.md
CHANGED
data/lib/cryptomarket/client.rb
CHANGED
@@ -12,31 +12,31 @@ module Cryptomarket
|
|
12
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
13
|
class Client # rubocop:disable Metrics/ClassLength
|
14
14
|
def initialize(api_key: nil, api_secret: nil, window: nil)
|
15
|
-
@http_manager = HttpManager.new api_key
|
15
|
+
@http_manager = HttpManager.new api_key:, api_secret:, window:
|
16
16
|
end
|
17
17
|
|
18
18
|
def public_get(endpoint, params = nil)
|
19
|
-
@http_manager.make_request(method: 'get', endpoint
|
19
|
+
@http_manager.make_request(method: 'get', endpoint:, params:, public: true)
|
20
20
|
end
|
21
21
|
|
22
22
|
def get(endpoint, params = nil)
|
23
|
-
@http_manager.make_request(method: 'get', endpoint
|
23
|
+
@http_manager.make_request(method: 'get', endpoint:, params:)
|
24
24
|
end
|
25
25
|
|
26
26
|
def post(endpoint, params = nil)
|
27
|
-
@http_manager.make_post_request(method: 'post', endpoint
|
27
|
+
@http_manager.make_post_request(method: 'post', endpoint:, params:)
|
28
28
|
end
|
29
29
|
|
30
30
|
def put(endpoint, params = nil)
|
31
|
-
@http_manager.make_request(method: 'put', endpoint
|
31
|
+
@http_manager.make_request(method: 'put', endpoint:, params:)
|
32
32
|
end
|
33
33
|
|
34
34
|
def patch(endpoint, params = nil)
|
35
|
-
@http_manager.make_request(method: 'patch', endpoint
|
35
|
+
@http_manager.make_request(method: 'patch', endpoint:, params:)
|
36
36
|
end
|
37
37
|
|
38
38
|
def delete(endpoint, params = nil)
|
39
|
-
@http_manager.make_request(method: 'delete', endpoint
|
39
|
+
@http_manager.make_request(method: 'delete', endpoint:, params:)
|
40
40
|
end
|
41
41
|
|
42
42
|
# Changes the user credentials used for authentication in calls
|
@@ -46,7 +46,7 @@ module Cryptomarket
|
|
46
46
|
# +String+ +api_secret+:: The user secret key used in new calls
|
47
47
|
|
48
48
|
def change_credentials(api_key:, api_secret:)
|
49
|
-
@http_manager.change_credentials(api_key
|
49
|
+
@http_manager.change_credentials(api_key:, api_secret:)
|
50
50
|
end
|
51
51
|
|
52
52
|
# Changes the window used in authenticated calls
|
@@ -55,7 +55,7 @@ module Cryptomarket
|
|
55
55
|
# +Integer+ +window+:: Acceptable time between request and server execution in millis
|
56
56
|
|
57
57
|
def change_window(window:)
|
58
|
-
@http_manager.change_window(window:
|
58
|
+
@http_manager.change_window(window:)
|
59
59
|
end
|
60
60
|
|
61
61
|
################
|
@@ -74,8 +74,8 @@ module Cryptomarket
|
|
74
74
|
|
75
75
|
def get_currencies(currencies: nil, preferred_network: nil)
|
76
76
|
public_get('public/currency/', {
|
77
|
-
currencies
|
78
|
-
preferred_network:
|
77
|
+
currencies:,
|
78
|
+
preferred_network:
|
79
79
|
})
|
80
80
|
end
|
81
81
|
|
@@ -103,7 +103,7 @@ module Cryptomarket
|
|
103
103
|
# +Array[String]+ +symbols+:: Optional. A list of symbol ids
|
104
104
|
|
105
105
|
def get_symbols(symbols: nil)
|
106
|
-
public_get('public/symbol', { symbols:
|
106
|
+
public_get('public/symbol', { symbols: })
|
107
107
|
end
|
108
108
|
|
109
109
|
# Get a symbol by its id
|
@@ -130,7 +130,7 @@ module Cryptomarket
|
|
130
130
|
# +Array[String]+ +symbols+:: Optional. A list of symbol ids
|
131
131
|
|
132
132
|
def get_tickers(symbols: nil)
|
133
|
-
public_get('public/ticker', { symbols:
|
133
|
+
public_get('public/ticker', { symbols: })
|
134
134
|
end
|
135
135
|
|
136
136
|
# Get the ticker of a symbol
|
@@ -157,7 +157,7 @@ module Cryptomarket
|
|
157
157
|
# +String+ +from+:: Optional. Source currency rate
|
158
158
|
|
159
159
|
def get_prices(to:, from: nil)
|
160
|
-
public_get('public/price/rate', { to
|
160
|
+
public_get('public/price/rate', { to:, from: })
|
161
161
|
end
|
162
162
|
|
163
163
|
# Get quotation prices history
|
@@ -178,7 +178,7 @@ module Cryptomarket
|
|
178
178
|
def get_price_history(to:, from: nil, till: nil, since: nil, limit: nil, period: nil, sort: nil) # rubocop:disable Metrics/ParameterLists
|
179
179
|
public_get(
|
180
180
|
'public/price/history',
|
181
|
-
{ to
|
181
|
+
{ to:, from:, till:, since:, limit:, period:, sort: }
|
182
182
|
)
|
183
183
|
end
|
184
184
|
|
@@ -192,7 +192,7 @@ module Cryptomarket
|
|
192
192
|
# +Array[String]+ +symbols+:: Optional. A list of symbol ids
|
193
193
|
|
194
194
|
def get_ticker_prices(symbols: nil)
|
195
|
-
public_get('public/price/ticker', { symbols:
|
195
|
+
public_get('public/price/ticker', { symbols: })
|
196
196
|
end
|
197
197
|
|
198
198
|
# Get ticker's last prices of a symbol
|
@@ -226,7 +226,7 @@ module Cryptomarket
|
|
226
226
|
def get_trades(symbols: nil, by: nil, sort: nil, from: nil, till: nil, limit: nil, offset: nil) # rubocop:disable Metrics/ParameterLists
|
227
227
|
public_get(
|
228
228
|
'public/trades/',
|
229
|
-
{ symbols
|
229
|
+
{ symbols:, by:, sort:, from:, till:, limit:, offset: }
|
230
230
|
)
|
231
231
|
end
|
232
232
|
|
@@ -249,7 +249,7 @@ module Cryptomarket
|
|
249
249
|
def get_trades_by_symbol(symbol: nil, by: nil, sort: nil, from: nil, till: nil, limit: nil, offset: nil) # rubocop:disable Metrics/ParameterLists
|
250
250
|
public_get(
|
251
251
|
"public/trades/#{symbol}",
|
252
|
-
{ by
|
252
|
+
{ by:, sort:, from:, till:, limit:, offset: }
|
253
253
|
)
|
254
254
|
end
|
255
255
|
|
@@ -265,7 +265,7 @@ module Cryptomarket
|
|
265
265
|
# +Integer+ +depth+:: Optional. Order Book depth. Default value is 100. Set to 0 to view the full Order Book
|
266
266
|
|
267
267
|
def get_orderbooks(symbols: nil, depth: nil)
|
268
|
-
public_get('public/orderbook', { symbols
|
268
|
+
public_get('public/orderbook', { symbols:, depth: })
|
269
269
|
end
|
270
270
|
|
271
271
|
# Get order book of a symbol
|
@@ -280,7 +280,7 @@ module Cryptomarket
|
|
280
280
|
# +Integer+ +depth+:: Optional. Order Book depth. Default value is 100. Set to 0 to view the full Order Book
|
281
281
|
|
282
282
|
def get_orderbook(symbol:, depth: nil)
|
283
|
-
public_get("public/orderbook/#{symbol}", { depth:
|
283
|
+
public_get("public/orderbook/#{symbol}", { depth: })
|
284
284
|
end
|
285
285
|
|
286
286
|
# Get order book of a symbol with the desired volume for market depth search
|
@@ -295,7 +295,7 @@ module Cryptomarket
|
|
295
295
|
# +float+ +volume+:: Optional. Desired volume for market depth search
|
296
296
|
|
297
297
|
def get_orderbook_volume(symbol:, volume: nil)
|
298
|
-
public_get("public/orderbook/#{symbol}", { volume:
|
298
|
+
public_get("public/orderbook/#{symbol}", { volume: })
|
299
299
|
end
|
300
300
|
|
301
301
|
# Get a Hash of candles for all symbols or for specified symbols
|
@@ -317,7 +317,7 @@ module Cryptomarket
|
|
317
317
|
def get_candles(symbols: nil, period: nil, sort: nil, from: nil, till: nil, limit: nil, offset: nil) # rubocop:disable Metrics/ParameterLists
|
318
318
|
public_get(
|
319
319
|
'public/candles/',
|
320
|
-
{ symbols
|
320
|
+
{ symbols:, period:, sort:, from:, till:, limit:, offset: }
|
321
321
|
)
|
322
322
|
end
|
323
323
|
|
@@ -341,7 +341,7 @@ module Cryptomarket
|
|
341
341
|
def get_candles_by_symbol(symbol:, period: nil, sort: nil, from: nil, till: nil, limit: nil, offset: nil) # rubocop:disable Metrics/ParameterLists
|
342
342
|
public_get(
|
343
343
|
"public/candles/#{symbol}",
|
344
|
-
{ period
|
344
|
+
{ period:, sort:, from:, till:, limit:, offset: }
|
345
345
|
)
|
346
346
|
end
|
347
347
|
|
@@ -368,7 +368,7 @@ module Cryptomarket
|
|
368
368
|
def get_converted_candles(target_currency:, symbols: nil, period: nil, sort: nil, from: nil, till: nil, limit: nil) # rubocop:disable Metrics/ParameterLists
|
369
369
|
public_get(
|
370
370
|
'public/converted/candles',
|
371
|
-
{ target_currency
|
371
|
+
{ target_currency:, symbols:, period:, sort:, from:, till:, limit: }
|
372
372
|
)
|
373
373
|
end
|
374
374
|
|
@@ -396,7 +396,7 @@ module Cryptomarket
|
|
396
396
|
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
|
397
397
|
public_get(
|
398
398
|
"public/converted/candles/#{symbol}",
|
399
|
-
{ target_currency
|
399
|
+
{ target_currency:, period:, sort:, from:, till:, limit:, offset: }
|
400
400
|
)
|
401
401
|
end
|
402
402
|
|
@@ -439,7 +439,7 @@ module Cryptomarket
|
|
439
439
|
# +String+ +symbol+:: Optional. A symbol for filtering the active spot orders
|
440
440
|
|
441
441
|
def get_all_active_spot_orders(symbol: nil)
|
442
|
-
get('spot/order', { symbol:
|
442
|
+
get('spot/order', { symbol: })
|
443
443
|
end
|
444
444
|
|
445
445
|
# Get an active spot order by its client order id
|
@@ -484,9 +484,9 @@ module Cryptomarket
|
|
484
484
|
)
|
485
485
|
post(
|
486
486
|
'spot/order',
|
487
|
-
{ client_order_id
|
488
|
-
time_in_force
|
489
|
-
strict_validate
|
487
|
+
{ client_order_id:, symbol:, side:, quantity:, type:,
|
488
|
+
time_in_force:, price:, stop_price:, expire_time:,
|
489
|
+
strict_validate:, post_only:, take_rate:, make_rate: }
|
490
490
|
)
|
491
491
|
end
|
492
492
|
|
@@ -535,9 +535,9 @@ module Cryptomarket
|
|
535
535
|
post(
|
536
536
|
'spot/order/list',
|
537
537
|
{
|
538
|
-
order_list_id
|
539
|
-
contingency_type
|
540
|
-
orders:
|
538
|
+
order_list_id:,
|
539
|
+
contingency_type:,
|
540
|
+
orders:
|
541
541
|
}
|
542
542
|
)
|
543
543
|
end
|
@@ -555,21 +555,24 @@ module Cryptomarket
|
|
555
555
|
# +String+ +quantity+:: Order quantity
|
556
556
|
# +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
|
557
557
|
# +String+ +price+:: Required if order type is 'limit', 'stopLimit', or 'takeProfitLimit'. Order price
|
558
|
+
# +String+ +stop_price+:: Required if order type is 'stopLimit', 'stopMarket', 'takeProfitLimit', or 'takeProfitMarket'. Order stop price
|
558
559
|
|
559
560
|
def replace_spot_order(
|
560
561
|
client_order_id:,
|
561
562
|
new_client_order_id:,
|
562
563
|
quantity:,
|
563
564
|
price: nil,
|
565
|
+
stop_price: nil,
|
564
566
|
strict_validate: nil
|
565
567
|
)
|
566
568
|
patch(
|
567
569
|
"spot/order/#{client_order_id}",
|
568
570
|
{
|
569
|
-
new_client_order_id
|
570
|
-
price
|
571
|
-
|
572
|
-
|
571
|
+
new_client_order_id:,
|
572
|
+
price:,
|
573
|
+
stop_price:,
|
574
|
+
quantity:,
|
575
|
+
strict_validate:
|
573
576
|
}
|
574
577
|
)
|
575
578
|
end
|
@@ -650,8 +653,8 @@ module Cryptomarket
|
|
650
653
|
)
|
651
654
|
get(
|
652
655
|
'spot/history/order',
|
653
|
-
{ client_order_id
|
654
|
-
by
|
656
|
+
{ client_order_id:, symbol:, sort:,
|
657
|
+
by:, from:, till:, limit:, offset: }
|
655
658
|
)
|
656
659
|
end
|
657
660
|
|
@@ -677,8 +680,8 @@ module Cryptomarket
|
|
677
680
|
)
|
678
681
|
get(
|
679
682
|
'spot/history/trade',
|
680
|
-
{ order_id
|
681
|
-
by
|
683
|
+
{ order_id:, symbol:, sort:,
|
684
|
+
by:, from:, till:, limit:, offset: }
|
682
685
|
)
|
683
686
|
end
|
684
687
|
|
@@ -709,6 +712,15 @@ module Cryptomarket
|
|
709
712
|
get("wallet/balance/#{currency}")
|
710
713
|
end
|
711
714
|
|
715
|
+
# Gets the list of whitelisted addresses
|
716
|
+
#
|
717
|
+
# Requires the "Payment information" API key Access Right
|
718
|
+
#
|
719
|
+
# https://api.exchange.cryptomkt.com/#get-whitelisted-addresses
|
720
|
+
def get_whitelisted_addresses # rubocop:disable Naming/AccessorMethodName
|
721
|
+
get('wallet/crypto/address/white-list')
|
722
|
+
end
|
723
|
+
|
712
724
|
# Get a list with the current addresses of the user
|
713
725
|
#
|
714
726
|
# Requires the "Payment information" API key Access Right
|
@@ -732,7 +744,7 @@ module Cryptomarket
|
|
732
744
|
# +String+ +network_code+:: Optional. network code
|
733
745
|
|
734
746
|
def get_deposit_crypto_address(currency: nil, network_code: nil)
|
735
|
-
result = get('wallet/crypto/address', { currency
|
747
|
+
result = get('wallet/crypto/address', { currency:, network_code: })
|
736
748
|
raise CryptomarketSDKException 'Too many currencies recieved, expected 1 currency' if result.length != 1
|
737
749
|
|
738
750
|
result[0]
|
@@ -749,7 +761,7 @@ module Cryptomarket
|
|
749
761
|
# +String+ +network_code+:: Optional. network code
|
750
762
|
|
751
763
|
def create_deposit_crypto_address(currency:, network_code: nil)
|
752
|
-
post('wallet/crypto/address', { currency
|
764
|
+
post('wallet/crypto/address', { currency:, network_code: })
|
753
765
|
end
|
754
766
|
|
755
767
|
# Get the last 10 unique addresses used for deposit, by currency
|
@@ -764,7 +776,7 @@ module Cryptomarket
|
|
764
776
|
# +String+ +network_code+:: Optional. network code
|
765
777
|
|
766
778
|
def get_last_10_deposit_crypto_addresses(currency:, network_code: nil)
|
767
|
-
get('wallet/crypto/address/recent-deposit', { currency
|
779
|
+
get('wallet/crypto/address/recent-deposit', { currency:, network_code: })
|
768
780
|
end
|
769
781
|
|
770
782
|
# Get the last 10 unique addresses used for withdrawals, by currency
|
@@ -779,7 +791,7 @@ module Cryptomarket
|
|
779
791
|
# +String+ +network_code+:: Optional. network code
|
780
792
|
|
781
793
|
def get_last_10_withdrawal_crypto_addresses(currency:, network_code: nil)
|
782
|
-
get('wallet/crypto/address/recent-withdraw', { currency
|
794
|
+
get('wallet/crypto/address/recent-withdraw', { currency:, network_code: })
|
783
795
|
end
|
784
796
|
|
785
797
|
# Please take note that changing security settings affects withdrawals:
|
@@ -810,9 +822,9 @@ module Cryptomarket
|
|
810
822
|
)
|
811
823
|
post(
|
812
824
|
'wallet/crypto/withdraw',
|
813
|
-
{ currency
|
814
|
-
payment_id
|
815
|
-
use_offchain
|
825
|
+
{ currency:, amount:, address:, network_code:,
|
826
|
+
payment_id:, include_fee:, auto_commit:,
|
827
|
+
use_offchain:, public_comment: }
|
816
828
|
)['id']
|
817
829
|
end
|
818
830
|
|
@@ -870,6 +882,16 @@ module Cryptomarket
|
|
870
882
|
post('wallet/crypto/fee/estimate/bulk', params)
|
871
883
|
end
|
872
884
|
|
885
|
+
# Gets the hash of withdrawal fees
|
886
|
+
#
|
887
|
+
# Requires the "Payment information" API key Access Right
|
888
|
+
#
|
889
|
+
# https://api.exchange.cryptomkt.com/#get-withdrawal-fees-hash
|
890
|
+
|
891
|
+
def get_withdrawal_fees_hash
|
892
|
+
get('wallet/crypto/fee/withdraw/hash')['hash']
|
893
|
+
end
|
894
|
+
|
873
895
|
# Get an estimate of the withdrawal fee
|
874
896
|
#
|
875
897
|
# Requires the "Payment information" API key Access Right
|
@@ -881,7 +903,7 @@ module Cryptomarket
|
|
881
903
|
# +float+ +amount+:: the expected withdraw amount
|
882
904
|
|
883
905
|
def get_estimate_withdrawal_fee(currency:, amount:, network_code: nil)
|
884
|
-
params = { amount
|
906
|
+
params = { amount:, currency:, network_code: }
|
885
907
|
get('wallet/crypto/fee/estimate', params)['fee']
|
886
908
|
end
|
887
909
|
|
@@ -930,9 +952,9 @@ module Cryptomarket
|
|
930
952
|
post(
|
931
953
|
'wallet/convert',
|
932
954
|
{
|
933
|
-
from_currency
|
934
|
-
to_currency
|
935
|
-
amount:
|
955
|
+
from_currency:,
|
956
|
+
to_currency:,
|
957
|
+
amount:
|
936
958
|
}
|
937
959
|
)['result']
|
938
960
|
end
|
@@ -947,7 +969,7 @@ module Cryptomarket
|
|
947
969
|
# +String+ +address+:: address to check
|
948
970
|
|
949
971
|
def crypto_address_belongs_to_current_account?(address:)
|
950
|
-
get('wallet/crypto/address/check-mine', { address:
|
972
|
+
get('wallet/crypto/address/check-mine', { address: })['result']
|
951
973
|
end
|
952
974
|
|
953
975
|
# Transfer funds between account types
|
@@ -967,10 +989,10 @@ module Cryptomarket
|
|
967
989
|
post(
|
968
990
|
'wallet/transfer',
|
969
991
|
{
|
970
|
-
currency
|
971
|
-
amount
|
972
|
-
source
|
973
|
-
destination:
|
992
|
+
currency:,
|
993
|
+
amount:,
|
994
|
+
source:,
|
995
|
+
destination:
|
974
996
|
}
|
975
997
|
)
|
976
998
|
end
|
@@ -991,10 +1013,10 @@ module Cryptomarket
|
|
991
1013
|
post(
|
992
1014
|
'wallet/internal/withdraw',
|
993
1015
|
{
|
994
|
-
currency
|
995
|
-
amount
|
996
|
-
by
|
997
|
-
identifier:
|
1016
|
+
currency:,
|
1017
|
+
amount:,
|
1018
|
+
by:,
|
1019
|
+
identifier:
|
998
1020
|
}
|
999
1021
|
)
|
1000
1022
|
end
|
@@ -1033,9 +1055,9 @@ module Cryptomarket
|
|
1033
1055
|
)
|
1034
1056
|
get(
|
1035
1057
|
'wallet/transactions',
|
1036
|
-
{ currency
|
1037
|
-
currencies
|
1038
|
-
order_by
|
1058
|
+
{ currency:, from:, till:, types:, subtypes:, statuses:,
|
1059
|
+
currencies:, networks:, id_from:, id_till:, tx_ids:,
|
1060
|
+
order_by:, sort:, limit:, offset:, group_transactions: }
|
1039
1061
|
)
|
1040
1062
|
end
|
1041
1063
|
|
@@ -1071,9 +1093,9 @@ module Cryptomarket
|
|
1071
1093
|
post(
|
1072
1094
|
'wallet/crypto/check-offchain-available',
|
1073
1095
|
{
|
1074
|
-
currency
|
1075
|
-
address
|
1076
|
-
payment_id:
|
1096
|
+
currency:,
|
1097
|
+
address:,
|
1098
|
+
payment_id:
|
1077
1099
|
}
|
1078
1100
|
)['result']
|
1079
1101
|
end
|
@@ -1097,7 +1119,7 @@ module Cryptomarket
|
|
1097
1119
|
)
|
1098
1120
|
get(
|
1099
1121
|
'wallet/amount-locks',
|
1100
|
-
{ currency
|
1122
|
+
{ currency:, active:, limit:, offset:, from:, till: }
|
1101
1123
|
)
|
1102
1124
|
end
|
1103
1125
|
|
@@ -1135,7 +1157,7 @@ module Cryptomarket
|
|
1135
1157
|
post(
|
1136
1158
|
'sub-account/freeze',
|
1137
1159
|
{
|
1138
|
-
sub_account_ids:
|
1160
|
+
sub_account_ids:
|
1139
1161
|
}
|
1140
1162
|
)['result']
|
1141
1163
|
end
|
@@ -1154,7 +1176,7 @@ module Cryptomarket
|
|
1154
1176
|
post(
|
1155
1177
|
'sub-account/activate',
|
1156
1178
|
{
|
1157
|
-
sub_account_ids:
|
1179
|
+
sub_account_ids:
|
1158
1180
|
}
|
1159
1181
|
)['result']
|
1160
1182
|
end
|
@@ -1180,10 +1202,70 @@ module Cryptomarket
|
|
1180
1202
|
post(
|
1181
1203
|
'sub-account/transfer',
|
1182
1204
|
{
|
1183
|
-
sub_account_id
|
1184
|
-
amount
|
1185
|
-
currency
|
1186
|
-
type:
|
1205
|
+
sub_account_id:,
|
1206
|
+
amount:,
|
1207
|
+
currency:,
|
1208
|
+
type:
|
1209
|
+
}
|
1210
|
+
)['result']
|
1211
|
+
end
|
1212
|
+
|
1213
|
+
# Creates and commits a transfer from a subaccount to its super account
|
1214
|
+
#
|
1215
|
+
# Call is being sent by a subaccount
|
1216
|
+
#
|
1217
|
+
# Created but not committed transfer will reserve pending amount on the sender
|
1218
|
+
# wallet affecting their ability to withdraw or transfer crypto to another
|
1219
|
+
# account. Incomplete withdrawals affect subaccount transfers the same way
|
1220
|
+
#
|
1221
|
+
# Requires the "Withdraw cryptocurrencies" API key Access Right
|
1222
|
+
#
|
1223
|
+
# https://api.exchange.cryptomkt.com/#transfer-to-super-account
|
1224
|
+
#
|
1225
|
+
# ==== Params
|
1226
|
+
# +String+ +amount+:: amount to transfer
|
1227
|
+
# +String+ +currency+:: currency to transfer
|
1228
|
+
def transfer_to_super_account(
|
1229
|
+
amount:,
|
1230
|
+
currency:
|
1231
|
+
)
|
1232
|
+
post(
|
1233
|
+
'sub-account/transfer/sub-to-super',
|
1234
|
+
{
|
1235
|
+
amount:,
|
1236
|
+
currency:
|
1237
|
+
}
|
1238
|
+
)['result']
|
1239
|
+
end
|
1240
|
+
|
1241
|
+
# Creates and commits a transfer between the user (subaccount) and another
|
1242
|
+
# subaccount.
|
1243
|
+
#
|
1244
|
+
# Call is being sent by a subaccount
|
1245
|
+
#
|
1246
|
+
# Created but not committed transfer will reserve pending amount on the sender
|
1247
|
+
# wallet affecting their ability to withdraw or transfer crypto to another
|
1248
|
+
# account. Incomplete withdrawals affect subaccount transfers the same way
|
1249
|
+
#
|
1250
|
+
# Requires the "Withdraw cryptocurrencies" API key Access Right
|
1251
|
+
#
|
1252
|
+
# https://api.exchange.cryptomkt.com/#transfer-across-subaccounts
|
1253
|
+
#
|
1254
|
+
# ==== Params
|
1255
|
+
# +String+ +sub_account_ids+:: id of the sub-account to transfer funds from/to
|
1256
|
+
# +String+ +amount+:: amount to transfer
|
1257
|
+
# +String+ +currency+:: currency to transfer
|
1258
|
+
def transfer_to_another_subaccount(
|
1259
|
+
sub_account_id:,
|
1260
|
+
amount:,
|
1261
|
+
currency:
|
1262
|
+
)
|
1263
|
+
post(
|
1264
|
+
'sub-account/transfer/sub-to-sub',
|
1265
|
+
{
|
1266
|
+
sub_account_id:,
|
1267
|
+
amount:,
|
1268
|
+
currency:
|
1187
1269
|
}
|
1188
1270
|
)['result']
|
1189
1271
|
end
|
@@ -1203,7 +1285,7 @@ module Cryptomarket
|
|
1203
1285
|
get(
|
1204
1286
|
'sub-account/acl',
|
1205
1287
|
{
|
1206
|
-
sub_account_ids:
|
1288
|
+
sub_account_ids:
|
1207
1289
|
}
|
1208
1290
|
)['result']
|
1209
1291
|
end
|
@@ -1228,8 +1310,8 @@ module Cryptomarket
|
|
1228
1310
|
)
|
1229
1311
|
post(
|
1230
1312
|
'sub-account/acl',
|
1231
|
-
{ sub_account_ids
|
1232
|
-
withdraw_enabled
|
1313
|
+
{ sub_account_ids:, deposit_address_generation_enabled:,
|
1314
|
+
withdraw_enabled:, description:, created_at:, updated_at: }
|
1233
1315
|
)['result']
|
1234
1316
|
end
|
1235
1317
|
|
@@ -33,16 +33,16 @@ module Cryptomarket
|
|
33
33
|
|
34
34
|
def initialize(api_key:, api_secret:, window: nil)
|
35
35
|
@credential_factory = Cryptomarket::CredentialsFactory.new(
|
36
|
-
api_version: @@API_VERSION, api_key
|
36
|
+
api_version: @@API_VERSION, api_key:, api_secret:, window:
|
37
37
|
)
|
38
38
|
end
|
39
39
|
|
40
40
|
def change_credentials(api_key:, api_secret:)
|
41
|
-
@credential_factory.change_credentials(api_key
|
41
|
+
@credential_factory.change_credentials(api_key:, api_secret:)
|
42
42
|
end
|
43
43
|
|
44
44
|
def change_window(window:)
|
45
|
-
@credential_factory.change_window(window:
|
45
|
+
@credential_factory.change_window(window:)
|
46
46
|
end
|
47
47
|
|
48
48
|
def make_request(method:, endpoint:, params: nil, public: false)
|
@@ -77,7 +77,7 @@ module Cryptomarket
|
|
77
77
|
end
|
78
78
|
|
79
79
|
def do_request(method, uri, payload, headers)
|
80
|
-
args = { method: method.downcase.to_sym, url: uri.to_s, headers:
|
80
|
+
args = { method: method.downcase.to_sym, url: uri.to_s, headers: }
|
81
81
|
if post?(method) || patch?(method)
|
82
82
|
args[:payload] = post?(method) ? payload.to_json : payload
|
83
83
|
end
|
@@ -11,7 +11,7 @@ module Cryptomarket
|
|
11
11
|
def initialize(url:, subscription_keys:, on_connect: -> {}, on_error: ->(error) {}, on_close: -> {})
|
12
12
|
@subscription_keys = subscription_keys
|
13
13
|
@callback_cache = CallbackCache.new
|
14
|
-
@ws_manager = WSManager.new
|
14
|
+
@ws_manager = WSManager.new(self, url:)
|
15
15
|
@on_connect = on_connect
|
16
16
|
@on_error = on_error
|
17
17
|
@on_close = on_close
|
@@ -291,7 +291,7 @@ module Cryptomarket
|
|
291
291
|
|
292
292
|
def subscribe_to_price_rates(callback:, speed:, target_currency:, currencies: ['*'], result_callback: nil)
|
293
293
|
params = {
|
294
|
-
speed
|
294
|
+
speed:, target_currency:, currencies:
|
295
295
|
}
|
296
296
|
send_channel_subscription("price/rate/#{speed}", callback, intercept_result_callback(result_callback), params)
|
297
297
|
end
|
@@ -314,7 +314,7 @@ module Cryptomarket
|
|
314
314
|
def subscribe_to_price_rates_in_batches(callback:, speed:, target_currency:, currencies: ['*'],
|
315
315
|
result_callback: nil)
|
316
316
|
params = {
|
317
|
-
speed
|
317
|
+
speed:, target_currency:, currencies:
|
318
318
|
}
|
319
319
|
send_channel_subscription("price/rate/#{speed}/batch", callback,
|
320
320
|
intercept_result_callback(result_callback), params)
|
@@ -17,9 +17,9 @@ module Cryptomarket
|
|
17
17
|
def initialize(api_key:, api_secret:, window: nil)
|
18
18
|
super(
|
19
19
|
url: 'wss://api.exchange.cryptomkt.com/api/3/ws/trading',
|
20
|
-
api_key
|
21
|
-
api_secret
|
22
|
-
window
|
20
|
+
api_key:,
|
21
|
+
api_secret:,
|
22
|
+
window:,
|
23
23
|
subscription_keys: build_subscription_hash)
|
24
24
|
end
|
25
25
|
|
@@ -76,7 +76,7 @@ module Cryptomarket
|
|
76
76
|
interceptor = lambda { |notification, _type|
|
77
77
|
callback.call(notification)
|
78
78
|
}
|
79
|
-
send_subscription('spot_balance_subscribe', interceptor, { mode:
|
79
|
+
send_subscription('spot_balance_subscribe', interceptor, { mode: }, result_callback)
|
80
80
|
end
|
81
81
|
|
82
82
|
# stop recieving the feed of balances changes
|
@@ -129,9 +129,9 @@ module Cryptomarket
|
|
129
129
|
expire_time: nil, strict_validate: nil, post_only: nil, take_rate: nil, make_rate: nil, callback: nil
|
130
130
|
)
|
131
131
|
request('spot_new_order', callback,
|
132
|
-
{ client_order_id
|
133
|
-
time_in_force
|
134
|
-
strict_validate
|
132
|
+
{ client_order_id:, symbol:, side:, quantity:, type:,
|
133
|
+
time_in_force:, price:, stop_price:, expire_time:,
|
134
|
+
strict_validate:, post_only:, take_rate:, make_rate: })
|
135
135
|
end
|
136
136
|
|
137
137
|
# creates a list of spot orders
|
@@ -174,7 +174,7 @@ module Cryptomarket
|
|
174
174
|
orders:, contingency_type:, order_list_id: nil, callback: nil
|
175
175
|
)
|
176
176
|
request('spot_new_order_list', callback, {
|
177
|
-
orders
|
177
|
+
orders:, contingency_type:, order_list_id:
|
178
178
|
},
|
179
179
|
orders.count)
|
180
180
|
end
|
@@ -187,7 +187,7 @@ module Cryptomarket
|
|
187
187
|
# +String+ +client_order_id+:: the client order id of the order to cancel
|
188
188
|
# +Proc+ +callback+:: Optional. A +Proc+ of two arguments, An exception and a result, called either with the exception or with the result, a list of reports of the canceled orders
|
189
189
|
def cancel_spot_order(client_order_id:, callback: nil)
|
190
|
-
request('spot_cancel_order', callback, { client_order_id:
|
190
|
+
request('spot_cancel_order', callback, { client_order_id: })
|
191
191
|
end
|
192
192
|
|
193
193
|
# cancel all active spot orders and returns the ones that could not be canceled
|
@@ -222,7 +222,7 @@ module Cryptomarket
|
|
222
222
|
# +String+ +currency+:: The currency code to query the balance
|
223
223
|
# +Proc+ +callback+:: A +Proc+ of two arguments, An exception and a result, called either with the exception or with the result, a trading balance
|
224
224
|
def get_spot_trading_balance(currency:, callback:)
|
225
|
-
request('spot_balance', callback, { currency:
|
225
|
+
request('spot_balance', callback, { currency: })
|
226
226
|
end
|
227
227
|
|
228
228
|
# changes the parameters of an existing order, quantity or price
|
@@ -234,14 +234,15 @@ module Cryptomarket
|
|
234
234
|
# +String+ +new_client_order_id+:: the new client order id for the modified order. must be unique within the trading day
|
235
235
|
# +String+ +quantity+:: new order quantity
|
236
236
|
# +String+ +price+:: new order price
|
237
|
+
# +String+ +stop_price+:: Required if order type is 'stopLimit', 'stopMarket', 'takeProfitLimit', or 'takeProfitMarket'. Order stop price
|
237
238
|
# +Bool+ +strict_validate+:: price and quantity will be checked for the incrementation with tick size and quantity step. See symbol's tick_size and quantity_increment
|
238
239
|
# +Proc+ +callback+:: Optional. A +Proc+ of two arguments, An exception and a result, called either with the exception or with the result, the new version of the order
|
239
240
|
def replace_spot_order( # rubocop:disable Metrics/ParameterLists
|
240
|
-
client_order_id:, new_client_order_id:, quantity:, price:, strict_validate: nil, callback: nil
|
241
|
+
client_order_id:, new_client_order_id:, quantity:, price:, stop_price: nil, strict_validate: nil, callback: nil
|
241
242
|
)
|
242
243
|
request('spot_replace_order', callback, {
|
243
|
-
client_order_id
|
244
|
-
price
|
244
|
+
client_order_id:, new_client_order_id:, quantity:,
|
245
|
+
price:, stop_price:, strict_validate:
|
245
246
|
})
|
246
247
|
end
|
247
248
|
|
@@ -267,7 +268,7 @@ module Cryptomarket
|
|
267
268
|
# +String+ +symbol+:: The symbol of the commission rate
|
268
269
|
# +Proc+ +callback+:: A +Proc+ of two arguments, An exception and a result, called either with the exception or with the result, a commission for a symbol for the user
|
269
270
|
def get_spot_commission(symbol:, callback:)
|
270
|
-
request('spot_fee', callback, { symbol:
|
271
|
+
request('spot_fee', callback, { symbol: })
|
271
272
|
end
|
272
273
|
|
273
274
|
alias get_spot_trading_balance_of_currency get_spot_trading_balance
|
@@ -18,9 +18,9 @@ module Cryptomarket
|
|
18
18
|
def initialize(api_key:, api_secret:, window: nil)
|
19
19
|
super(
|
20
20
|
url: 'wss://api.exchange.cryptomkt.com/api/3/ws/wallet',
|
21
|
-
api_key
|
22
|
-
api_secret
|
23
|
-
window
|
21
|
+
api_key:,
|
22
|
+
api_secret:,
|
23
|
+
window:,
|
24
24
|
subscription_keys: build_subscription_hash)
|
25
25
|
end
|
26
26
|
|
@@ -125,7 +125,7 @@ module Cryptomarket
|
|
125
125
|
balance['currency'] = currency
|
126
126
|
callback.call(err, balance)
|
127
127
|
}
|
128
|
-
request('wallet_balance', interceptor, { currency:
|
128
|
+
request('wallet_balance', interceptor, { currency: })
|
129
129
|
end
|
130
130
|
|
131
131
|
# Get the transaction history of the account
|
@@ -160,9 +160,9 @@ module Cryptomarket
|
|
160
160
|
id_from: nil, id_till: nil, order_by: nil, sort: nil, limit: nil, offset: nil, group_transactions: nil
|
161
161
|
)
|
162
162
|
request('get_transactions', callback, {
|
163
|
-
tx_ids
|
164
|
-
from
|
165
|
-
limit
|
163
|
+
tx_ids:, types:, subtypes:, statuses:, currencies:,
|
164
|
+
from:, till:, id_from:, id_till:, order_by:, sort:,
|
165
|
+
limit:, offset:, group_transactions:
|
166
166
|
})
|
167
167
|
end
|
168
168
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cryptomarket-sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- T. Ismael Verdugo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-01-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|