Skip to content

Commit 7c40b3f

Browse files
author
Pedro Pablo Bustamante Barrera
committed
Merge branch 'develop'
2 parents b3f92c2 + ef387e0 commit 7c40b3f

File tree

9 files changed

+169
-32
lines changed

9 files changed

+169
-32
lines changed

cryptomarket-sdk.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
33

44
Gem::Specification.new do |s|
55
s.name = "cryptomarket-sdk"
6-
s.version = "3.0.0"
6+
s.version = "3.1.0"
77
s.platform = Gem::Platform::RUBY
88
s.authors = ["T. Ismael Verdugo"]
99
s.email = ["[email protected]"]

lib/cryptomarket/client.rb

Lines changed: 102 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,37 @@ def delete(endpoint, params = nil)
3939
@http_manager.make_request(method: 'delete', endpoint: endpoint, params: params)
4040
end
4141

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+
4273
################
4374
# public calls #
4475
################
@@ -154,7 +185,7 @@ def get_prices(to:, from: nil)
154185
# +String+ +sort+:: Optional. Sort direction. 'ASC' or 'DESC'. Default is 'DESC'
155186
# +String+ +since+:: Optional. Initial value of the queried interval
156187
# +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
188+
# +Integer+ +limit+:: Optional. Prices per currency pair. Defaul is 1. Min is 1. Max is 1_000
158189

159190
def get_price_history(to:, from: nil, till: nil, since: nil, limit: nil, period: nil, sort: nil) # rubocop:disable Metrics/ParameterLists
160191
public_get(
@@ -202,7 +233,7 @@ def get_ticker_price(symbol:)
202233
# +String+ +sort+:: Optional. Sort direction. 'ASC' or 'DESC'. Default is 'DESC'
203234
# +String+ +since+:: Optional. Initial value of the queried interval
204235
# +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
236+
# +Integer+ +limit+:: Optional. Prices per currency pair. Defaul is 10. Min is 1. Max is 1_000
206237

207238
def get_trades(symbols: nil, by: nil, sort: nil, from: nil, till: nil, limit: nil, offset: nil) # rubocop:disable Metrics/ParameterLists
208239
public_get(
@@ -224,8 +255,8 @@ def get_trades(symbols: nil, by: nil, sort: nil, from: nil, till: nil, limit: ni
224255
# +String+ +sort+:: Optional. Sort direction. 'ASC' or 'DESC'. Default is 'DESC'
225256
# +String+ +since+:: Optional. Initial value of the queried interval
226257
# +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
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
229260

230261
def get_trades_by_symbol(symbol: nil, by: nil, sort: nil, from: nil, till: nil, limit: nil, offset: nil) # rubocop:disable Metrics/ParameterLists
231262
public_get(
@@ -280,7 +311,7 @@ def get_orderbook_volume(symbol:, volume: nil)
280311
end
281312

282313
# Get a Hash of candles for all symbols or for specified symbols
283-
# Candels are used for OHLC representation
314+
# Candles are used for OHLC representation
284315
# The result contains candles with non-zero volume only (no trades = no candles)
285316
#
286317
# Requires no API key Access Rights
@@ -293,7 +324,7 @@ def get_orderbook_volume(symbol:, volume: nil)
293324
# +String+ +sort+:: Optional. Sort direction. 'ASC' or 'DESC'. Default is 'DESC'
294325
# +String+ +from+:: Optional. Initial value of the queried interval. As DateTime
295326
# +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
327+
# +Integer+ +limit+:: Optional. Prices per currency pair. Defaul is 10. Min is 1. Max is 1_000
297328

298329
def get_candles(symbols: nil, period: nil, sort: nil, from: nil, till: nil, limit: nil, offset: nil) # rubocop:disable Metrics/ParameterLists
299330
public_get(
@@ -303,7 +334,7 @@ def get_candles(symbols: nil, period: nil, sort: nil, from: nil, till: nil, limi
303334
end
304335

305336
# Get candles of a symbol
306-
# Candels are used for OHLC representation
337+
# Candles are used for OHLC representation
307338
# The result contains candles with non-zero volume only (no trades = no candles)
308339
#
309340
# Requires no API key Access Rights
@@ -316,8 +347,8 @@ def get_candles(symbols: nil, period: nil, sort: nil, from: nil, till: nil, limi
316347
# +String+ +sort+:: Optional. Sort direction. 'ASC' or 'DESC'. Default is 'DESC'
317348
# +String+ +from+:: Optional. Initial value of the queried interval. As DateTime
318349
# +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
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
321352

322353
def get_candles_by_symbol(symbol:, period: nil, sort: nil, from: nil, till: nil, limit: nil, offset: nil) # rubocop:disable Metrics/ParameterLists
323354
public_get(
@@ -326,6 +357,61 @@ def get_candles_by_symbol(symbol:, period: nil, sort: nil, from: nil, till: nil,
326357
)
327358
end
328359

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+
329415
######################
330416
# Spot Trading calls #
331417
######################
@@ -567,8 +653,8 @@ def get_trading_commission(symbol:)
567653
# +String+ +sort+:: Optional. Sort direction. 'ASC' or 'DESC'. Default is 'DESC'
568654
# +String+ +from+:: Optional. Initial value of the queried interval
569655
# +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
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
572658

573659
def get_spot_orders_history( # rubocop:disable Metrics/ParameterLists
574660
client_order_id: nil, symbol: nil, sort: nil, by: nil, from: nil,
@@ -594,8 +680,8 @@ def get_spot_orders_history( # rubocop:disable Metrics/ParameterLists
594680
# +String+ +sort+:: Optional. Sort direction. 'ASC' or 'DESC'. Default is 'DESC'
595681
# +String+ +from+:: Optional. Initial value of the queried interval
596682
# +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
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
599685

600686
def get_spot_trades_history( # rubocop:disable Metrics/ParameterLists
601687
order_id: nil, symbol: nil, sort: nil, by: nil, from: nil,
@@ -906,8 +992,8 @@ def transfer_money_to_another_user(currency:, amount:, by:, identifier:)
906992
# +String+ +id_from+:: Optional. Interval initial value when ordering by id. Min is 0
907993
# +String+ +id_till+:: Optional. Interval end value when ordering by id. Min is 0
908994
# +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
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
911997
# +bool+ +group_transactions+:: Optional. Flag indicating whether the returned transactions will be parts of a single operation. Default is false
912998

913999
def get_transaction_history( # rubocop:disable Metrics/ParameterLists
@@ -971,7 +1057,7 @@ def offchain_available?(
9711057
# ==== Params
9721058
# +String+ +currency+:: Optional. Currency code
9731059
# +bool+ +active+:: Optional. value showing whether the lock is active
974-
# +Integer+ +limit+:: Optional. Dafault is 100. Min is 0. Max is 1000
1060+
# +Integer+ +limit+:: Optional. Dafault is 100. Min is 0. Max is 1_000
9751061
# +Integer+ +offset+:: Optional. Default is 0. Min is 0
9761062
# +String+ +from+:: Optional. Interval initial value. As Datetime
9771063
# +String+ +till+:: Optional. Interval end value. As Datetime

lib/cryptomarket/websocket/auth_client.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def wait_authed
4848
# err is None for successful calls, result is None for calls with error: Proc.new {|err, result| ...}
4949

5050
def authenticate(callback = nil)
51-
timestamp = Time.now.to_i * 1000
51+
timestamp = Time.now.to_i * 1_000
5252
digest = OpenSSL::Digest.new 'sha256'
5353
message = timestamp.to_s
5454
message += @window.to_s unless @window.nil?

lib/cryptomarket/websocket/market_data_client.rb

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class MarketDataClient < MarketDataClientCore
2626
# ==== Params
2727
# +Proc+ +callback+:: A +Proc+ that recieves notifications as a hash of trades indexed by symbol, and the type of notification (either 'snapshot' or 'update')
2828
# +Array[String]+ +symbols+:: A list of symbol ids
29-
# +Integer+ +limit+:: Number of historical entries returned in the first feed. Min is 0. Max is 1000. Default is 0
29+
# +Integer+ +limit+:: Number of historical entries returned in the first feed. Min is 0. Max is 1_000. Default is 0
3030
# +Proc+ +result_callback+:: Optional. A +Proc+ of two arguments, An exception and a result, called either with the exception or with the result, a list of subscribed symbols
3131

3232
def subscribe_to_trades(callback:, symbols:, limit: nil, result_callback: nil)
@@ -40,18 +40,15 @@ def subscribe_to_trades(callback:, symbols:, limit: nil, result_callback: nil)
4040
#
4141
# normal subscriptions have one update message per symbol
4242
#
43-
# the first notification are n candles, with n defined by the limit argument,
44-
# the next notification are updates, with one candle at a time
45-
#
4643
# Requires no API key Access Rights
4744
#
4845
# https://api.exchange.cryptomkt.com/#subscribe-to-candles
4946
#
5047
# ==== Params
5148
# +Proc+ +callback+:: A +Proc+ that recieves notifications as a hash of candles indexed by symbol, and the type of notification (either 'snapshot' or 'update')
52-
# +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'
49+
# +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).
5350
# +Array[String]+ +symbols+:: Optional. A list of symbol ids
54-
# +Integer+ +limit+:: Number of historical entries returned in the first feed. Min is 0. Max is 1000. Default is 0
51+
# +Integer+ +limit+:: Number of historical entries returned in the first feed. Min is 0. Max is 1_000. Default is 0
5552
# +Proc+ +result_callback+:: Optional. A +Proc+ called with a list of subscribed symbols
5653

5754
def subscribe_to_candles(callback:, period:, symbols:, limit: nil, result_callback: nil)
@@ -60,6 +57,31 @@ def subscribe_to_candles(callback:, period:, symbols:, limit: nil, result_callba
6057
intercept_result_callback(result_callback), params)
6158
end
6259

60+
# subscribes to a feed of candles regarding the last price converted to the target currency for all symbols or for the specified symbols
61+
#
62+
# Candles are used for the representation of a specific symbol as an OHLC chart
63+
#
64+
# 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.
65+
#
66+
# Requires no API key Access Rights
67+
#
68+
# https://api.exchange.cryptomkt.com/#subscribe-to-converted-candles
69+
#
70+
# +Proc+ +callback+:: A +Proc+ that recieves notifications as a hash of candles indexed by symbol, and the type of notification (either 'snapshot' or 'update')
71+
# +String+ +target_currency+:: Target currency for conversion
72+
# +Array[String]+ +symbols+:: A list of symbols
73+
# +String+ +period+:: A valid tick interval. 'M1' (one minute), 'M3', 'M5', 'M15', 'M30', 'H1' (one hour), 'H4', 'D1' (one day), 'D7', '1M' (one month).
74+
# +String+ +from+:: Optional. Initial value of the queried interval. As DateTime
75+
# +String+ +till+:: Optional. Last value of the queried interval. As DateTime
76+
# +Integer+ +limit+:: Optional. Prices per currency pair. Defaul is 100. Min is 1. Max is 1_000
77+
# +Proc+ +result_callback+:: Optional. A +Proc+ called with a list of subscribed symbols
78+
79+
def subscribe_to_converted_candles(callback:, target_currency:, symbols:, period:, limit: nil, result_callback: nil) # rubocop:disable Metrics/ParameterLists
80+
params = { 'target_currency' => target_currency, 'symbols' => symbols, 'limit' => limit }
81+
send_channel_subscription("converted/candles/#{period}", callback,
82+
intercept_result_callback(result_callback), params)
83+
end
84+
6385
# subscribe to a feed of mini tickers
6486
#
6587
# subscription is for all symbols or for the specified symbols
@@ -258,7 +280,7 @@ def subscribe_to_top_of_book_in_batches(callback:, speed:, symbols: ['*'], resul
258280
#
259281
# subscription is for all currencies or for the specified currencies
260282
#
261-
# https://api.exchange.cryptomkt.com/#subscribe-to-top-of-book-in-batches
283+
# https://api.exchange.cryptomkt.com/#subscribe-to-price-rates
262284
#
263285
# ==== Params
264286
# +Proc+ +callback+:: A +Proc+ that recieves notifications as a hash of top of orderbooks indexed by symbol, and the type of notification (only 'data')

lib/cryptomarket/websocket/trading_client.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ def build_subscription_hash
3535
'spot_balance' => [balances, Args::NotificationType::SNAPSHOT] }
3636
end
3737

38+
alias get_spot_trading_balance_of_currency get_spot_trading_balance
39+
alias get_spot_trading_balance_by_currency get_spot_trading_balance
40+
alias get_spot_commission_of_symbol get_spot_commission
41+
alias get_spot_commission_by_symbol get_spot_commission
42+
3843
# subscribe to a feed of execution reports of the user's orders
3944
#
4045
# https://api.exchange.cryptomkt.com/#socket-spot-trading

lib/cryptomarket/websocket/wallet_client.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ def build_subscription_hash
3737
'wallet_balance_update' => [balance, Args::NotificationType::UPDATE] }
3838
end
3939

40+
alias get_wallet_balance_of_currency get_wallet_balance
41+
alias get_wallet_balance_by_currency get_wallet_balance
42+
4043
# A transaction notification occurs each time a transaction has been changed, such as creating a transaction, updating the pending state (e.g., the hash assigned) or completing a transaction
4144
#
4245
# https://api.exchange.cryptomkt.com/#subscribe-to-transactions
@@ -151,8 +154,8 @@ def get_wallet_balance(currency:, callback:)
151154
# +String+ +id_till+:: Optional. Interval end value when ordering by id. Min is 0
152155
# +String+ +order_by+:: Optional. sorting parameter.'created_at' or 'id'. Default is 'created_at'
153156
# +String+ +sort+:: Optional. Sort direction. 'ASC' or 'DESC'. Default is 'DESC'
154-
# +Integer+ +limit+:: Optional. Transactions per query. Defaul is 100. Max is 1000
155-
# +Integer+ +offset+:: Optional. Default is 0. Max is 100000
157+
# +Integer+ +limit+:: Optional. Transactions per query. Defaul is 100. Max is 1_000
158+
# +Integer+ +offset+:: Optional. Default is 0. Max is 100_000
156159
# +bool+ +group_transactions+:: Optional. Flag indicating whether the returned transactions will be parts of a single operation. Default is false
157160

158161
def get_transactions( # rubocop:disable Metrics/ParameterLists

0 commit comments

Comments
 (0)