Class: Honeymaker::Clients::Bitrue
- Inherits:
-
Honeymaker::Client
- Object
- Honeymaker::Client
- Honeymaker::Clients::Bitrue
- Defined in:
- lib/honeymaker/clients/bitrue.rb
Constant Summary collapse
- URL =
"https://openapi.bitrue.com"- RATE_LIMITS =
{ default: 100, orders: 200 }.freeze
Constants inherited from Honeymaker::Client
Instance Attribute Summary
Attributes inherited from Honeymaker::Client
Instance Method Summary collapse
- #account_information(recv_window: 5000) ⇒ Object
- #account_trade_list(symbol:, start_time: nil, end_time: nil, from_id: nil, limit: 500, recv_window: 5000) ⇒ Object
- #cancel_order(symbol:, order_id: nil, orig_client_order_id: nil, recv_window: 5000) ⇒ Object
- #candlestick_data(symbol:, interval:, start_time: nil, end_time: nil, limit: 500) ⇒ Object
- #deposit_history(coin: nil, status: nil, start_time: nil, end_time: nil, offset: nil, limit: 1000, recv_window: 5000) ⇒ Object
- #exchange_information ⇒ Object
-
#futures_account(recv_window: 5000) ⇒ Object
— Futures —.
- #get_all_coins_information(recv_window: 5000) ⇒ Object
- #get_balances ⇒ Object
- #new_order(symbol:, side:, type:, time_in_force: nil, quantity: nil, quote_order_qty: nil, price: nil, new_client_order_id: nil, recv_window: 5000) ⇒ Object
- #query_order(symbol:, order_id: nil, orig_client_order_id: nil, recv_window: 5000) ⇒ Object
- #symbol_order_book_ticker(symbol: nil) ⇒ Object
- #symbol_price_ticker(symbol: nil) ⇒ Object
- #withdraw(coin:, address:, amount:, network: nil, address_tag: nil, recv_window: 5000) ⇒ Object
- #withdraw_history(coin: nil, status: nil, start_time: nil, end_time: nil, offset: nil, limit: 1000, recv_window: 5000) ⇒ Object
Methods inherited from Honeymaker::Client
#initialize, rate_limits, #validate
Constructor Details
This class inherits a constructor from Honeymaker::Client
Instance Method Details
#account_information(recv_window: 5000) ⇒ Object
28 29 30 |
# File 'lib/honeymaker/clients/bitrue.rb', line 28 def account_information(recv_window: 5000) get_signed("/api/v1/account", { recvWindow: recv_window }) end |
#account_trade_list(symbol:, start_time: nil, end_time: nil, from_id: nil, limit: 500, recv_window: 5000) ⇒ Object
91 92 93 94 95 96 |
# File 'lib/honeymaker/clients/bitrue.rb', line 91 def account_trade_list(symbol:, start_time: nil, end_time: nil, from_id: nil, limit: 500, recv_window: 5000) get_signed("/api/v1/myTrades", { symbol: symbol, startTime: start_time, endTime: end_time, fromId: from_id, limit: limit, recvWindow: recv_window }) end |
#cancel_order(symbol:, order_id: nil, orig_client_order_id: nil, recv_window: 5000) ⇒ Object
73 74 75 76 77 78 |
# File 'lib/honeymaker/clients/bitrue.rb', line 73 def cancel_order(symbol:, order_id: nil, orig_client_order_id: nil, recv_window: 5000) delete_signed("/api/v1/order", { symbol: symbol, orderId: order_id, origClientOrderId: orig_client_order_id, recvWindow: recv_window }) end |
#candlestick_data(symbol:, interval:, start_time: nil, end_time: nil, limit: 500) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/honeymaker/clients/bitrue.rb', line 21 def candlestick_data(symbol:, interval:, start_time: nil, end_time: nil, limit: 500) get_public("/api/v1/market/kline", { symbol: symbol, scale: interval, startTime: start_time, endTime: end_time, limit: limit }) end |
#deposit_history(coin: nil, status: nil, start_time: nil, end_time: nil, offset: nil, limit: 1000, recv_window: 5000) ⇒ Object
98 99 100 101 102 103 104 |
# File 'lib/honeymaker/clients/bitrue.rb', line 98 def deposit_history(coin: nil, status: nil, start_time: nil, end_time: nil, offset: nil, limit: 1000, recv_window: 5000) get_signed("/api/v1/capital/deposit/hisrec", { coin: coin, status: status, startTime: start_time, endTime: end_time, offset: offset, limit: limit, recvWindow: recv_window }) end |
#exchange_information ⇒ Object
9 10 11 |
# File 'lib/honeymaker/clients/bitrue.rb', line 9 def exchange_information get_public("/api/v1/exchangeInfo") end |
#futures_account(recv_window: 5000) ⇒ Object
— Futures —
116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/honeymaker/clients/bitrue.rb', line 116 def futures_account(recv_window: 5000) with_rescue do response = futures_connection.get do |req| req.url "/fapi/v1/account" req.headers = auth_headers req.params = { recvWindow: recv_window, timestamp: }.compact req.params[:signature] = sign_params(req.params) end response.body end end |
#get_all_coins_information(recv_window: 5000) ⇒ Object
80 81 82 |
# File 'lib/honeymaker/clients/bitrue.rb', line 80 def get_all_coins_information(recv_window: 5000) get_signed("/api/v1/capital/config/getall", { recvWindow: recv_window }) end |
#get_balances ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/honeymaker/clients/bitrue.rb', line 32 def get_balances result = account_information 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 |
#new_order(symbol:, side:, type:, time_in_force: nil, quantity: nil, quote_order_qty: nil, price: nil, new_client_order_id: nil, recv_window: 5000) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/honeymaker/clients/bitrue.rb', line 59 def new_order(symbol:, side:, type:, time_in_force: nil, quantity: nil, quote_order_qty: nil, price: nil, new_client_order_id: nil, recv_window: 5000) result = post_signed("/api/v1/order", { symbol: symbol, side: side, type: type, timeInForce: time_in_force, quantity: quantity, quoteOrderQty: quote_order_qty, price: price, newClientOrderId: new_client_order_id, recvWindow: recv_window }) return result if result.failure? raw = result.data Result::Success.new({ order_id: "#{symbol}-#{raw['orderId']}", raw: raw }) end |
#query_order(symbol:, order_id: nil, orig_client_order_id: nil, recv_window: 5000) ⇒ Object
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/honeymaker/clients/bitrue.rb', line 48 def query_order(symbol:, order_id: nil, orig_client_order_id: nil, recv_window: 5000) result = get_signed("/api/v1/order", { symbol: symbol, orderId: order_id, origClientOrderId: orig_client_order_id, recvWindow: recv_window }) return result if result.failure? raw = result.data Result::Success.new(normalize_order("#{symbol}-#{raw['orderId']}", raw)) end |
#symbol_order_book_ticker(symbol: nil) ⇒ Object
17 18 19 |
# File 'lib/honeymaker/clients/bitrue.rb', line 17 def symbol_order_book_ticker(symbol: nil) get_public("/api/v1/ticker/bookTicker", { symbol: symbol }) end |
#symbol_price_ticker(symbol: nil) ⇒ Object
13 14 15 |
# File 'lib/honeymaker/clients/bitrue.rb', line 13 def symbol_price_ticker(symbol: nil) get_public("/api/v1/ticker/price", { symbol: symbol }) end |
#withdraw(coin:, address:, amount:, network: nil, address_tag: nil, recv_window: 5000) ⇒ Object
84 85 86 87 88 89 |
# File 'lib/honeymaker/clients/bitrue.rb', line 84 def withdraw(coin:, address:, amount:, network: nil, address_tag: nil, recv_window: 5000) post_signed("/api/v1/capital/withdraw/apply", { coin: coin, address: address, amount: amount, network: network, addressTag: address_tag, recvWindow: recv_window }) end |
#withdraw_history(coin: nil, status: nil, start_time: nil, end_time: nil, offset: nil, limit: 1000, recv_window: 5000) ⇒ Object
106 107 108 109 110 111 112 |
# File 'lib/honeymaker/clients/bitrue.rb', line 106 def withdraw_history(coin: nil, status: nil, start_time: nil, end_time: nil, offset: nil, limit: 1000, recv_window: 5000) get_signed("/api/v1/capital/withdraw/history", { coin: coin, status: status, startTime: start_time, endTime: end_time, offset: offset, limit: limit, recvWindow: recv_window }) end |