Class: Honeymaker::Clients::Binance

Inherits:
Honeymaker::Client show all
Defined in:
lib/honeymaker/clients/binance.rb

Direct Known Subclasses

BinanceUs

Constant Summary collapse

URL =
"https://api.binance.com"
RATE_LIMITS =
{ default: 100, orders: 200 }.freeze

Constants inherited from Honeymaker::Client

Honeymaker::Client::OPTIONS

Instance Attribute Summary

Attributes inherited from Honeymaker::Client

#api_key, #api_secret

Instance Method Summary collapse

Methods inherited from Honeymaker::Client

#initialize, rate_limits, #validate

Constructor Details

This class inherits a constructor from Honeymaker::Client

Instance Method Details

#account_information(omit_zero_balances: false, recv_window: 5000) ⇒ Object



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/honeymaker/clients/binance.rb', line 63

def (omit_zero_balances: false, recv_window: 5000)
  with_rescue do
    response = connection.get do |req|
      req.url "/api/v3/account"
      req.headers = headers
      req.params = {
        omitZeroBalances: omit_zero_balances,
        recvWindow: recv_window,
        timestamp: timestamp_ms
      }.compact
      req.params[:signature] = sign_params(req.params)
    end
    response.body
  end
end

#account_trade_list(symbol:, order_id: nil, start_time: nil, end_time: nil, from_id: nil, limit: 500, recv_window: 5000) ⇒ Object



95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/honeymaker/clients/binance.rb', line 95

def (symbol:, order_id: nil, start_time: nil, end_time: nil, from_id: nil, limit: 500, recv_window: 5000)
  with_rescue do
    response = connection.get do |req|
      req.url "/api/v3/myTrades"
      req.headers = headers
      req.params = {
        symbol: symbol, orderId: order_id,
        startTime: start_time, endTime: end_time,
        fromId: from_id, limit: limit,
        recvWindow: recv_window, timestamp: timestamp_ms
      }.compact
      req.params[:signature] = sign_params(req.params)
    end
    response.body
  end
end

#all_orders(symbol:, order_id: nil, start_time: nil, end_time: nil, limit: 500, recv_window: 5000) ⇒ Object



129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# File 'lib/honeymaker/clients/binance.rb', line 129

def all_orders(symbol:, order_id: nil, start_time: nil, end_time: nil, limit: 500, recv_window: 5000)
  with_rescue do
    response = connection.get do |req|
      req.url "/api/v3/allOrders"
      req.headers = headers
      req.params = {
        symbol: symbol, orderId: order_id,
        startTime: start_time, endTime: end_time,
        limit: limit, recvWindow: recv_window, timestamp: timestamp_ms
      }.compact
      req.params[:signature] = sign_params(req.params)
    end
    response.body.map do |raw|
      normalize_order("#{symbol}-#{raw['orderId']}", raw)
    end
  end
end

#api_description(recv_window: 5000) ⇒ Object



373
374
375
376
377
378
379
380
381
382
383
# File 'lib/honeymaker/clients/binance.rb', line 373

def api_description(recv_window: 5000)
  with_rescue do
    response = connection.get do |req|
      req.url "/sapi/v1/account/apiRestrictions"
      req.headers = headers
      req.params = { recvWindow: recv_window, timestamp: timestamp_ms }
      req.params[:signature] = sign_params(req.params)
    end
    response.body
  end
end

#asset_dividend(asset: nil, start_time: nil, end_time: nil, limit: 500, recv_window: 5000) ⇒ Object



316
317
318
319
320
321
322
323
324
325
326
327
328
329
# File 'lib/honeymaker/clients/binance.rb', line 316

def asset_dividend(asset: nil, start_time: nil, end_time: nil, limit: 500, recv_window: 5000)
  with_rescue do
    response = connection.get do |req|
      req.url "/sapi/v1/asset/assetDividend"
      req.headers = headers
      req.params = {
        asset: asset, startTime: start_time, endTime: end_time,
        limit: limit, recvWindow: recv_window, timestamp: timestamp_ms
      }.compact
      req.params[:signature] = sign_params(req.params)
    end
    response.body
  end
end

#cancel_order(symbol:, order_id: nil, orig_client_order_id: nil, new_client_order_id: nil, cancel_restrictions: nil, recv_window: 5000) ⇒ Object



199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
# File 'lib/honeymaker/clients/binance.rb', line 199

def cancel_order(symbol:, order_id: nil, orig_client_order_id: nil, new_client_order_id: nil,
                 cancel_restrictions: nil, recv_window: 5000)
  with_rescue do
    response = connection.delete do |req|
      req.url "/api/v3/order"
      req.headers = headers
      req.params = {
        symbol: symbol, orderId: order_id,
        origClientOrderId: orig_client_order_id,
        newClientOrderId: new_client_order_id,
        cancelRestrictions: cancel_restrictions,
        recvWindow: recv_window, timestamp: timestamp_ms
      }.compact
      req.params[:signature] = sign_params(req.params)
    end
    response.body
  end
end

#candlestick_data(symbol:, interval:, start_time: nil, end_time: nil, time_zone: 0, limit: 500) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/honeymaker/clients/binance.rb', line 48

def candlestick_data(symbol:, interval:, start_time: nil, end_time: nil, time_zone: 0, limit: 500)
  with_rescue do
    response = connection.get do |req|
      req.url "/api/v3/klines"
      req.headers = headers
      req.params = {
        symbol: symbol, interval: interval,
        startTime: start_time, endTime: end_time,
        timeZone: time_zone, limit: limit
      }.compact
    end
    response.body
  end
end

#coin_futures_income_history(symbol: nil, income_type: nil, start_time: nil, end_time: nil, page: nil, limit: 1000, recv_window: 5000) ⇒ Object



489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
# File 'lib/honeymaker/clients/binance.rb', line 489

def coin_futures_income_history(symbol: nil, income_type: nil, start_time: nil, end_time: nil,
                                page: nil, limit: 1000, recv_window: 5000)
  with_rescue do
    response = coin_futures_connection.get do |req|
      req.url "/dapi/v1/income"
      req.headers = headers
      req.params = {
        symbol: symbol, incomeType: income_type,
        startTime: start_time, endTime: end_time,
        page: page, limit: limit,
        recvWindow: recv_window, timestamp: timestamp_ms
      }.compact
      req.params[:signature] = sign_params(req.params)
    end
    response.body
  end
end

#convert_trade_flow(start_time:, end_time:, limit: 1000, recv_window: 5000) ⇒ Object



252
253
254
255
256
257
258
259
260
261
262
263
264
265
# File 'lib/honeymaker/clients/binance.rb', line 252

def convert_trade_flow(start_time:, end_time:, limit: 1000, recv_window: 5000)
  with_rescue do
    response = connection.get do |req|
      req.url "/sapi/v1/convert/tradeFlow"
      req.headers = headers
      req.params = {
        startTime: start_time, endTime: end_time,
        limit: limit, recvWindow: recv_window, timestamp: timestamp_ms
      }.compact
      req.params[:signature] = sign_params(req.params)
    end
    response.body
  end
end

#deposit_history(coin: nil, status: nil, start_time: nil, end_time: nil, offset: nil, limit: 1000, recv_window: 5000) ⇒ Object



218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
# File 'lib/honeymaker/clients/binance.rb', line 218

def deposit_history(coin: nil, status: nil, start_time: nil, end_time: nil, offset: nil, limit: 1000, recv_window: 5000)
  with_rescue do
    response = connection.get do |req|
      req.url "/sapi/v1/capital/deposit/hisrec"
      req.headers = headers
      req.params = {
        coin: coin, status: status,
        startTime: start_time, endTime: end_time,
        offset: offset, limit: limit,
        recvWindow: recv_window, timestamp: timestamp_ms
      }.compact
      req.params[:signature] = sign_params(req.params)
    end
    response.body
  end
end

#dust_log(start_time: nil, end_time: nil, recv_window: 5000) ⇒ Object



301
302
303
304
305
306
307
308
309
310
311
312
313
314
# File 'lib/honeymaker/clients/binance.rb', line 301

def dust_log(start_time: nil, end_time: nil, recv_window: 5000)
  with_rescue do
    response = connection.get do |req|
      req.url "/sapi/v1/asset/dribblet"
      req.headers = headers
      req.params = {
        startTime: start_time, endTime: end_time,
        recvWindow: recv_window, timestamp: timestamp_ms
      }.compact
      req.params[:signature] = sign_params(req.params)
    end
    response.body
  end
end

#exchange_information(symbol: nil, symbols: nil, permissions: nil, show_permission_sets: nil, symbol_status: nil) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/honeymaker/clients/binance.rb', line 9

def exchange_information(symbol: nil, symbols: nil, permissions: nil, show_permission_sets: nil, symbol_status: nil)
  with_rescue do
    response = connection.get do |req|
      req.url "/api/v3/exchangeInfo"
      req.headers = headers
      req.params = {
        symbol: symbol,
        symbols: symbols&.to_json,
        permissions: permissions&.to_json,
        showPermissionSets: show_permission_sets,
        symbolStatus: symbol_status
      }.compact
    end
    response.body
  end
end

#fiat_orders(transaction_type:, begin_time: nil, end_time: nil, page: nil, rows: nil, recv_window: 5000) ⇒ Object



284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
# File 'lib/honeymaker/clients/binance.rb', line 284

def fiat_orders(transaction_type:, begin_time: nil, end_time: nil, page: nil, rows: nil, recv_window: 5000)
  with_rescue do
    response = connection.get do |req|
      req.url "/sapi/v1/fiat/orders"
      req.headers = headers
      req.params = {
        transactionType: transaction_type,
        beginTime: begin_time, endTime: end_time,
        page: page, rows: rows,
        recvWindow: recv_window, timestamp: timestamp_ms
      }.compact
      req.params[:signature] = sign_params(req.params)
    end
    response.body
  end
end

#fiat_payments(transaction_type:, begin_time: nil, end_time: nil, page: nil, rows: nil, recv_window: 5000) ⇒ Object



267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
# File 'lib/honeymaker/clients/binance.rb', line 267

def fiat_payments(transaction_type:, begin_time: nil, end_time: nil, page: nil, rows: nil, recv_window: 5000)
  with_rescue do
    response = connection.get do |req|
      req.url "/sapi/v1/fiat/payments"
      req.headers = headers
      req.params = {
        transactionType: transaction_type,
        beginTime: begin_time, endTime: end_time,
        page: page, rows: rows,
        recvWindow: recv_window, timestamp: timestamp_ms
      }.compact
      req.params[:signature] = sign_params(req.params)
    end
    response.body
  end
end

#futures_income_history(symbol: nil, income_type: nil, start_time: nil, end_time: nil, page: nil, limit: 1000, recv_window: 5000) ⇒ Object

— Futures —



471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
# File 'lib/honeymaker/clients/binance.rb', line 471

def futures_income_history(symbol: nil, income_type: nil, start_time: nil, end_time: nil,
                           page: nil, limit: 1000, recv_window: 5000)
  with_rescue do
    response = usdt_futures_connection.get do |req|
      req.url "/fapi/v1/income"
      req.headers = headers
      req.params = {
        symbol: symbol, incomeType: income_type,
        startTime: start_time, endTime: end_time,
        page: page, limit: limit,
        recvWindow: recv_window, timestamp: timestamp_ms
      }.compact
      req.params[:signature] = sign_params(req.params)
    end
    response.body
  end
end

#get_all_coins_information(recv_window: 5000) ⇒ Object



361
362
363
364
365
366
367
368
369
370
371
# File 'lib/honeymaker/clients/binance.rb', line 361

def get_all_coins_information(recv_window: 5000)
  with_rescue do
    response = connection.get do |req|
      req.url "/sapi/v1/capital/config/getall"
      req.headers = headers
      req.params = { recvWindow: recv_window, timestamp: timestamp_ms }
      req.params[:signature] = sign_params(req.params)
    end
    response.body
  end
end

#get_balancesObject



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/honeymaker/clients/binance.rb', line 79

def get_balances
  result = (omit_zero_balances: true)
  return result if result.failure?

  balances = {}
  Array(result.data["balances"]).each do |balance|
    symbol = balance["asset"]
    free = BigDecimal(balance["free"].to_s)
    locked = BigDecimal(balance["locked"].to_s)
    next if free.zero? && locked.zero?
    balances[symbol] = { free: free, locked: locked }
  end

  Result::Success.new(balances)
end

#get_withdraw_addresses(recv_window: 5000) ⇒ Object



385
386
387
388
389
390
391
392
393
394
395
# File 'lib/honeymaker/clients/binance.rb', line 385

def get_withdraw_addresses(recv_window: 5000)
  with_rescue do
    response = connection.get do |req|
      req.url "/sapi/v1/capital/withdraw/address/list"
      req.headers = headers
      req.params = { recvWindow: recv_window, timestamp: timestamp_ms }
      req.params[:signature] = sign_params(req.params)
    end
    response.body
  end
end

#margin_borrow_repay_history(type:, asset: nil, isolated_symbol: nil, start_time: nil, end_time: nil, current: nil, size: nil, recv_window: 5000) ⇒ Object

— Margin —



415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
# File 'lib/honeymaker/clients/binance.rb', line 415

def margin_borrow_repay_history(type:, asset: nil, isolated_symbol: nil, start_time: nil, end_time: nil,
                                current: nil, size: nil, recv_window: 5000)
  with_rescue do
    response = connection.get do |req|
      req.url "/sapi/v1/margin/borrow-repay"
      req.headers = headers
      req.params = {
        type: type, asset: asset, isolatedSymbol: isolated_symbol,
        startTime: start_time, endTime: end_time,
        current: current, size: size,
        recvWindow: recv_window, timestamp: timestamp_ms
      }.compact
      req.params[:signature] = sign_params(req.params)
    end
    response.body
  end
end

#margin_force_liquidation(start_time: nil, end_time: nil, isolated_symbol: nil, current: nil, size: nil, recv_window: 5000) ⇒ Object



451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
# File 'lib/honeymaker/clients/binance.rb', line 451

def margin_force_liquidation(start_time: nil, end_time: nil, isolated_symbol: nil,
                             current: nil, size: nil, recv_window: 5000)
  with_rescue do
    response = connection.get do |req|
      req.url "/sapi/v1/margin/forceLiquidationRec"
      req.headers = headers
      req.params = {
        startTime: start_time, endTime: end_time,
        isolatedSymbol: isolated_symbol,
        current: current, size: size,
        recvWindow: recv_window, timestamp: timestamp_ms
      }.compact
      req.params[:signature] = sign_params(req.params)
    end
    response.body
  end
end

#margin_interest_history(asset: nil, isolated_symbol: nil, start_time: nil, end_time: nil, current: nil, size: nil, archived: nil, recv_window: 5000) ⇒ Object



433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
# File 'lib/honeymaker/clients/binance.rb', line 433

def margin_interest_history(asset: nil, isolated_symbol: nil, start_time: nil, end_time: nil,
                            current: nil, size: nil, archived: nil, recv_window: 5000)
  with_rescue do
    response = connection.get do |req|
      req.url "/sapi/v1/margin/interestHistory"
      req.headers = headers
      req.params = {
        asset: asset, isolatedSymbol: isolated_symbol,
        startTime: start_time, endTime: end_time,
        current: current, size: size, archived: archived,
        recvWindow: recv_window, timestamp: timestamp_ms
      }.compact
      req.params[:signature] = sign_params(req.params)
    end
    response.body
  end
end

#new_order(symbol:, side:, type:, time_in_force: nil, quantity: nil, quote_order_qty: nil, price: nil, new_client_order_id: nil, strategy_id: nil, strategy_type: nil, stop_price: nil, trailing_delta: nil, iceberg_qty: nil, new_order_resp_type: nil, self_trade_prevention_mode: nil, recv_window: 5000) ⇒ Object



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
# File 'lib/honeymaker/clients/binance.rb', line 147

def new_order(symbol:, side:, type:, time_in_force: nil, quantity: nil, quote_order_qty: nil,
              price: nil, new_client_order_id: nil, strategy_id: nil, strategy_type: nil,
              stop_price: nil, trailing_delta: nil, iceberg_qty: nil, new_order_resp_type: nil,
              self_trade_prevention_mode: nil, recv_window: 5000)
  with_rescue do
    response = connection.post do |req|
      req.url "/api/v3/order"
      req.headers = headers
      req.params = {
        symbol: symbol, side: side, type: type,
        timeInForce: time_in_force, quantity: quantity,
        quoteOrderQty: quote_order_qty, price: price,
        newClientOrderId: new_client_order_id,
        strategyId: strategy_id, strategyType: strategy_type,
        stopPrice: stop_price, trailingDelta: trailing_delta,
        icebergQty: iceberg_qty, newOrderRespType: new_order_resp_type,
        selfTradePreventionMode: self_trade_prevention_mode,
        recvWindow: recv_window, timestamp: timestamp_ms
      }.compact
      req.params[:signature] = sign_params(req.params)
    end
    raw = response.body
    { order_id: "#{symbol}-#{raw['orderId']}", raw: raw }
  end
end

#query_order(symbol:, order_id: nil, orig_client_order_id: nil, recv_window: 5000) ⇒ Object



112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/honeymaker/clients/binance.rb', line 112

def query_order(symbol:, order_id: nil, orig_client_order_id: nil, recv_window: 5000)
  with_rescue do
    response = connection.get do |req|
      req.url "/api/v3/order"
      req.headers = headers
      req.params = {
        symbol: symbol, orderId: order_id,
        origClientOrderId: orig_client_order_id,
        recvWindow: recv_window, timestamp: timestamp_ms
      }.compact
      req.params[:signature] = sign_params(req.params)
    end
    raw = response.body
    normalize_order("#{symbol}-#{raw['orderId']}", raw)
  end
end

#simple_earn_flexible_redemptions(product_id: nil, redeem_id: nil, asset: nil, start_time: nil, end_time: nil, current: nil, size: nil) ⇒ Object



526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
# File 'lib/honeymaker/clients/binance.rb', line 526

def simple_earn_flexible_redemptions(product_id: nil, redeem_id: nil, asset: nil,
                                     start_time: nil, end_time: nil, current: nil, size: nil)
  with_rescue do
    response = connection.get do |req|
      req.url "/sapi/v1/simple-earn/flexible/history/redemptionRecord"
      req.headers = headers
      req.params = {
        productId: product_id, redeemId: redeem_id, asset: asset,
        startTime: start_time, endTime: end_time,
        current: current, size: size, timestamp: timestamp_ms
      }.compact
      req.params[:signature] = sign_params(req.params)
    end
    response.body
  end
end

#simple_earn_flexible_rewards(asset: nil, start_time: nil, end_time: nil, current: nil, size: nil) ⇒ Object



331
332
333
334
335
336
337
338
339
340
341
342
343
344
# File 'lib/honeymaker/clients/binance.rb', line 331

def simple_earn_flexible_rewards(asset: nil, start_time: nil, end_time: nil, current: nil, size: nil)
  with_rescue do
    response = connection.get do |req|
      req.url "/sapi/v1/simple-earn/flexible/history/rewardsRecord"
      req.headers = headers
      req.params = {
        asset: asset, startTime: start_time, endTime: end_time,
        current: current, size: size, timestamp: timestamp_ms
      }.compact
      req.params[:signature] = sign_params(req.params)
    end
    response.body
  end
end

#simple_earn_flexible_subscriptions(product_id: nil, purchase_id: nil, asset: nil, start_time: nil, end_time: nil, current: nil, size: nil) ⇒ Object

— Simple Earn —



509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
# File 'lib/honeymaker/clients/binance.rb', line 509

def simple_earn_flexible_subscriptions(product_id: nil, purchase_id: nil, asset: nil,
                                       start_time: nil, end_time: nil, current: nil, size: nil)
  with_rescue do
    response = connection.get do |req|
      req.url "/sapi/v1/simple-earn/flexible/history/subscriptionRecord"
      req.headers = headers
      req.params = {
        productId: product_id, purchaseId: purchase_id, asset: asset,
        startTime: start_time, endTime: end_time,
        current: current, size: size, timestamp: timestamp_ms
      }.compact
      req.params[:signature] = sign_params(req.params)
    end
    response.body
  end
end

#simple_earn_locked_redemptions(product_id: nil, redeem_id: nil, asset: nil, start_time: nil, end_time: nil, current: nil, size: nil) ⇒ Object



560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
# File 'lib/honeymaker/clients/binance.rb', line 560

def simple_earn_locked_redemptions(product_id: nil, redeem_id: nil, asset: nil,
                                   start_time: nil, end_time: nil, current: nil, size: nil)
  with_rescue do
    response = connection.get do |req|
      req.url "/sapi/v1/simple-earn/locked/history/redemptionRecord"
      req.headers = headers
      req.params = {
        productId: product_id, redeemId: redeem_id, asset: asset,
        startTime: start_time, endTime: end_time,
        current: current, size: size, timestamp: timestamp_ms
      }.compact
      req.params[:signature] = sign_params(req.params)
    end
    response.body
  end
end

#simple_earn_locked_rewards(asset: nil, start_time: nil, end_time: nil, current: nil, size: nil) ⇒ Object



346
347
348
349
350
351
352
353
354
355
356
357
358
359
# File 'lib/honeymaker/clients/binance.rb', line 346

def simple_earn_locked_rewards(asset: nil, start_time: nil, end_time: nil, current: nil, size: nil)
  with_rescue do
    response = connection.get do |req|
      req.url "/sapi/v1/simple-earn/locked/history/rewardsRecord"
      req.headers = headers
      req.params = {
        asset: asset, startTime: start_time, endTime: end_time,
        current: current, size: size, timestamp: timestamp_ms
      }.compact
      req.params[:signature] = sign_params(req.params)
    end
    response.body
  end
end

#simple_earn_locked_subscriptions(product_id: nil, purchase_id: nil, asset: nil, start_time: nil, end_time: nil, current: nil, size: nil) ⇒ Object



543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
# File 'lib/honeymaker/clients/binance.rb', line 543

def simple_earn_locked_subscriptions(product_id: nil, purchase_id: nil, asset: nil,
                                     start_time: nil, end_time: nil, current: nil, size: nil)
  with_rescue do
    response = connection.get do |req|
      req.url "/sapi/v1/simple-earn/locked/history/subscriptionRecord"
      req.headers = headers
      req.params = {
        productId: product_id, purchaseId: purchase_id, asset: asset,
        startTime: start_time, endTime: end_time,
        current: current, size: size, timestamp: timestamp_ms
      }.compact
      req.params[:signature] = sign_params(req.params)
    end
    response.body
  end
end

#symbol_order_book_ticker(symbol: nil, symbols: nil) ⇒ Object



37
38
39
40
41
42
43
44
45
46
# File 'lib/honeymaker/clients/binance.rb', line 37

def symbol_order_book_ticker(symbol: nil, symbols: nil)
  with_rescue do
    response = connection.get do |req|
      req.url "/api/v3/ticker/bookTicker"
      req.headers = headers
      req.params = { symbol: symbol, symbols: symbols&.to_json }.compact
    end
    response.body
  end
end

#symbol_price_ticker(symbol: nil, symbols: nil) ⇒ Object



26
27
28
29
30
31
32
33
34
35
# File 'lib/honeymaker/clients/binance.rb', line 26

def symbol_price_ticker(symbol: nil, symbols: nil)
  with_rescue do
    response = connection.get do |req|
      req.url "/api/v3/ticker/price"
      req.headers = headers
      req.params = { symbol: symbol, symbols: symbols&.to_json }.compact
    end
    response.body
  end
end

#test_new_order(symbol:, side:, type:, time_in_force: nil, quantity: nil, quote_order_qty: nil, price: nil, new_client_order_id: nil, strategy_id: nil, strategy_type: nil, stop_price: nil, trailing_delta: nil, iceberg_qty: nil, new_order_resp_type: nil, self_trade_prevention_mode: nil, recv_window: 5000, compute_commission_rates: false) ⇒ Object



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
# File 'lib/honeymaker/clients/binance.rb', line 173

def test_new_order(symbol:, side:, type:, time_in_force: nil, quantity: nil, quote_order_qty: nil,
                  price: nil, new_client_order_id: nil, strategy_id: nil, strategy_type: nil,
                  stop_price: nil, trailing_delta: nil, iceberg_qty: nil, new_order_resp_type: nil,
                  self_trade_prevention_mode: nil, recv_window: 5000, compute_commission_rates: false)
  with_rescue do
    response = connection.post do |req|
      req.url "/api/v3/order/test"
      req.headers = headers
      req.params = {
        symbol: symbol, side: side, type: type,
        timeInForce: time_in_force, quantity: quantity,
        quoteOrderQty: quote_order_qty, price: price,
        newClientOrderId: new_client_order_id,
        strategyId: strategy_id, strategyType: strategy_type,
        stopPrice: stop_price, trailingDelta: trailing_delta,
        icebergQty: iceberg_qty, newOrderRespType: new_order_resp_type,
        selfTradePreventionMode: self_trade_prevention_mode,
        computeCommissionRates: compute_commission_rates,
        recvWindow: recv_window, timestamp: timestamp_ms
      }.compact
      req.params[:signature] = sign_params(req.params)
    end
    response.body
  end
end

#universal_transfer_history(type:, start_time: nil, end_time: nil, current: nil, size: nil, recv_window: 5000) ⇒ Object

— Transfers —



579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
# File 'lib/honeymaker/clients/binance.rb', line 579

def universal_transfer_history(type:, start_time: nil, end_time: nil, current: nil, size: nil, recv_window: 5000)
  with_rescue do
    response = connection.get do |req|
      req.url "/sapi/v1/asset/transfer"
      req.headers = headers
      req.params = {
        type: type, startTime: start_time, endTime: end_time,
        current: current, size: size,
        recvWindow: recv_window, timestamp: timestamp_ms
      }.compact
      req.params[:signature] = sign_params(req.params)
    end
    response.body
  end
end

#withdraw(coin:, address:, amount:, network: nil, address_tag: nil, recv_window: 5000) ⇒ Object



397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
# File 'lib/honeymaker/clients/binance.rb', line 397

def withdraw(coin:, address:, amount:, network: nil, address_tag: nil, recv_window: 5000)
  with_rescue do
    response = connection.post do |req|
      req.url "/sapi/v1/capital/withdraw/apply"
      req.headers = headers
      req.params = {
        coin: coin, address: address, amount: amount,
        network: network, addressTag: address_tag,
        recvWindow: recv_window, timestamp: timestamp_ms
      }.compact
      req.params[:signature] = sign_params(req.params)
    end
    response.body
  end
end

#withdraw_history(coin: nil, status: nil, start_time: nil, end_time: nil, offset: nil, limit: 1000, recv_window: 5000) ⇒ Object



235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
# File 'lib/honeymaker/clients/binance.rb', line 235

def withdraw_history(coin: nil, status: nil, start_time: nil, end_time: nil, offset: nil, limit: 1000, recv_window: 5000)
  with_rescue do
    response = connection.get do |req|
      req.url "/sapi/v1/capital/withdraw/history"
      req.headers = headers
      req.params = {
        coin: coin, status: status,
        startTime: start_time, endTime: end_time,
        offset: offset, limit: limit,
        recvWindow: recv_window, timestamp: timestamp_ms
      }.compact
      req.params[:signature] = sign_params(req.params)
    end
    response.body
  end
end