Skip to content

Commit 3f443ae

Browse files
authored
Merge pull request #9 from cryptomkt/feat/update-january-2025
Feat/update january 2025
2 parents e15b030 + f21966b commit 3f443ae

File tree

13 files changed

+199
-114
lines changed

13 files changed

+199
-114
lines changed

.ruby-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.1.6

lib/cryptomarket/client.rb

Lines changed: 158 additions & 76 deletions
Large diffs are not rendered by default.

lib/cryptomarket/http_manager.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,16 @@ class HttpManager
3333

3434
def initialize(api_key:, api_secret:, window: nil)
3535
@credential_factory = Cryptomarket::CredentialsFactory.new(
36-
api_version: @@API_VERSION, api_key: api_key, api_secret: api_secret, window: window
36+
api_version: @@API_VERSION, api_key:, api_secret:, window:
3737
)
3838
end
3939

4040
def change_credentials(api_key:, api_secret:)
41-
@credential_factory.change_credentials(api_key: api_key, api_secret: api_secret)
41+
@credential_factory.change_credentials(api_key:, api_secret:)
4242
end
4343

4444
def change_window(window:)
45-
@credential_factory.change_window(window: window)
45+
@credential_factory.change_window(window:)
4646
end
4747

4848
def make_request(method:, endpoint:, params: nil, public: false)
@@ -77,7 +77,7 @@ def build_payload(params)
7777
end
7878

7979
def do_request(method, uri, payload, headers)
80-
args = { method: method.downcase.to_sym, url: uri.to_s, headers: headers }
80+
args = { method: method.downcase.to_sym, url: uri.to_s, headers: }
8181
if post?(method) || patch?(method)
8282
args[:payload] = post?(method) ? payload.to_json : payload
8383
end

lib/cryptomarket/websocket/auth_client.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def initialize(url:, api_key:, api_secret:, subscription_keys:, window: nil)
1212
@api_key = api_key
1313
@api_secret = api_secret
1414
@window = window
15-
super url: url, subscription_keys: subscription_keys
15+
super(url:, subscription_keys:)
1616
@authed = false
1717
end
1818

lib/cryptomarket/websocket/client_base.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class ClientBase
1111
def initialize(url:, subscription_keys:, on_connect: -> {}, on_error: ->(error) {}, on_close: -> {})
1212
@subscription_keys = subscription_keys
1313
@callback_cache = CallbackCache.new
14-
@ws_manager = WSManager.new self, url: url
14+
@ws_manager = WSManager.new(self, url:)
1515
@on_connect = on_connect
1616
@on_error = on_error
1717
@on_close = on_close

lib/cryptomarket/websocket/market_data_client.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ def subscribe_to_top_of_book_in_batches(callback:, speed:, symbols: ['*'], resul
291291

292292
def subscribe_to_price_rates(callback:, speed:, target_currency:, currencies: ['*'], result_callback: nil)
293293
params = {
294-
speed: speed, target_currency: target_currency, currencies: currencies
294+
speed:, target_currency:, currencies:
295295
}
296296
send_channel_subscription("price/rate/#{speed}", callback, intercept_result_callback(result_callback), params)
297297
end
@@ -314,7 +314,7 @@ def subscribe_to_price_rates(callback:, speed:, target_currency:, currencies: ['
314314
def subscribe_to_price_rates_in_batches(callback:, speed:, target_currency:, currencies: ['*'],
315315
result_callback: nil)
316316
params = {
317-
speed: speed, target_currency: target_currency, currencies: currencies
317+
speed:, target_currency:, currencies:
318318
}
319319
send_channel_subscription("price/rate/#{speed}/batch", callback,
320320
intercept_result_callback(result_callback), params)

lib/cryptomarket/websocket/trading_client.rb

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ class TradingClient < AuthClient
1717
def initialize(api_key:, api_secret:, window: nil)
1818
super(
1919
url: 'wss://api.exchange.cryptomkt.com/api/3/ws/trading',
20-
api_key: api_key,
21-
api_secret: api_secret,
22-
window: window,
20+
api_key:,
21+
api_secret:,
22+
window:,
2323
subscription_keys: build_subscription_hash)
2424
end
2525

@@ -76,7 +76,7 @@ def subscribe_to_spot_balance(callback:, mode: nil, result_callback: nil)
7676
interceptor = lambda { |notification, _type|
7777
callback.call(notification)
7878
}
79-
send_subscription('spot_balance_subscribe', interceptor, { mode: mode }, result_callback)
79+
send_subscription('spot_balance_subscribe', interceptor, { mode: }, result_callback)
8080
end
8181

8282
# stop recieving the feed of balances changes
@@ -129,9 +129,9 @@ def create_spot_order( # rubocop:disable Metrics/ParameterLists
129129
expire_time: nil, strict_validate: nil, post_only: nil, take_rate: nil, make_rate: nil, callback: nil
130130
)
131131
request('spot_new_order', callback,
132-
{ client_order_id: client_order_id, symbol: symbol, side: side, quantity: quantity, type: type,
133-
time_in_force: time_in_force, price: price, stop_price: stop_price, expire_time: expire_time,
134-
strict_validate: strict_validate, post_only: post_only, take_rate: take_rate, make_rate: make_rate })
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: })
135135
end
136136

137137
# creates a list of spot orders
@@ -174,7 +174,7 @@ def create_spot_order_list(
174174
orders:, contingency_type:, order_list_id: nil, callback: nil
175175
)
176176
request('spot_new_order_list', callback, {
177-
orders: orders, contingency_type: contingency_type, order_list_id: order_list_id
177+
orders:, contingency_type:, order_list_id:
178178
},
179179
orders.count)
180180
end
@@ -187,7 +187,7 @@ def create_spot_order_list(
187187
# +String+ +client_order_id+:: the client order id of the order to cancel
188188
# +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
189189
def cancel_spot_order(client_order_id:, callback: nil)
190-
request('spot_cancel_order', callback, { client_order_id: client_order_id })
190+
request('spot_cancel_order', callback, { client_order_id: })
191191
end
192192

193193
# cancel all active spot orders and returns the ones that could not be canceled
@@ -222,7 +222,7 @@ def get_spot_trading_balances(callback:)
222222
# +String+ +currency+:: The currency code to query the balance
223223
# +Proc+ +callback+:: A +Proc+ of two arguments, An exception and a result, called either with the exception or with the result, a trading balance
224224
def get_spot_trading_balance(currency:, callback:)
225-
request('spot_balance', callback, { currency: currency })
225+
request('spot_balance', callback, { currency: })
226226
end
227227

228228
# changes the parameters of an existing order, quantity or price
@@ -234,14 +234,15 @@ def get_spot_trading_balance(currency:, callback:)
234234
# +String+ +new_client_order_id+:: the new client order id for the modified order. must be unique within the trading day
235235
# +String+ +quantity+:: new order quantity
236236
# +String+ +price+:: new order price
237+
# +String+ +stop_price+:: Required if order type is 'stopLimit', 'stopMarket', 'takeProfitLimit', or 'takeProfitMarket'. Order stop price
237238
# +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
238239
# +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
239240
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
241242
)
242243
request('spot_replace_order', callback, {
243-
client_order_id: client_order_id, new_client_order_id: new_client_order_id, quantity: quantity,
244-
price: price, strict_validate: strict_validate
244+
client_order_id:, new_client_order_id:, quantity:,
245+
price:, stop_price:, strict_validate:
245246
})
246247
end
247248

@@ -267,7 +268,7 @@ def get_spot_commissions(callback:)
267268
# +String+ +symbol+:: The symbol of the commission rate
268269
# +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
269270
def get_spot_commission(symbol:, callback:)
270-
request('spot_fee', callback, { symbol: symbol })
271+
request('spot_fee', callback, { symbol: })
271272
end
272273

273274
alias get_spot_trading_balance_of_currency get_spot_trading_balance

lib/cryptomarket/websocket/wallet_client.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ class WalletClient < AuthClient
1818
def initialize(api_key:, api_secret:, window: nil)
1919
super(
2020
url: 'wss://api.exchange.cryptomkt.com/api/3/ws/wallet',
21-
api_key: api_key,
22-
api_secret: api_secret,
23-
window: window,
21+
api_key:,
22+
api_secret:,
23+
window:,
2424
subscription_keys: build_subscription_hash)
2525
end
2626

@@ -125,7 +125,7 @@ def get_wallet_balance(currency:, callback:)
125125
balance['currency'] = currency
126126
callback.call(err, balance)
127127
}
128-
request('wallet_balance', interceptor, { currency: currency })
128+
request('wallet_balance', interceptor, { currency: })
129129
end
130130

131131
# Get the transaction history of the account
@@ -160,9 +160,9 @@ def get_transactions( # rubocop:disable Metrics/ParameterLists
160160
id_from: nil, id_till: nil, order_by: nil, sort: nil, limit: nil, offset: nil, group_transactions: nil
161161
)
162162
request('get_transactions', callback, {
163-
tx_ids: tx_ids, types: types, subtypes: subtypes, statuses: statuses, currencies: currencies,
164-
from: from, till: till, id_from: id_from, id_till: id_till, order_by: order_by, sort: sort,
165-
limit: limit, offset: offset, group_transactions: group_transactions
163+
tx_ids:, types:, subtypes:, statuses:, currencies:,
164+
from:, till:, id_from:, id_till:, order_by:, sort:,
165+
limit:, offset:, group_transactions:
166166
})
167167
end
168168

tests/checks.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,9 @@ def self.good_ws_mini_ticker
145145
end
146146

147147
def self.good_ticker
148-
->(ticker) { good_params(ticker, %w[t o c h l v q p P L]) } # missing a A b B in some responses
148+
lambda { |ticker|
149+
good_params(ticker, %w[t h l v q L])
150+
} # missing a A b B o c p P in some responses
149151
end
150152

151153
def self.good_orderbook

tests/rest/market_data.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def test_get_candles_by_symbol
130130

131131
def test_get_converted_candles
132132
symbols = %w[EOSETH BTCUSDT]
133-
result = @client.get_converted_candles(symbols: symbols, limit: 2, target_currency: 'usdt')
133+
result = @client.get_converted_candles(symbols:, limit: 2, target_currency: 'usdt')
134134
result['data'].each do |symbol, candles|
135135
assert(symbols.include?(symbol))
136136
candles.each { |val| assert(Check.good_candle(val)) }

0 commit comments

Comments
 (0)