Class: Honeymaker::Clients::Mexc
- Inherits:
-
Honeymaker::Client
- Object
- Honeymaker::Client
- Honeymaker::Clients::Mexc
- Defined in:
- lib/honeymaker/clients/mexc.rb
Constant Summary collapse
- URL =
"https://api.mexc.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:, order_id: nil, start_time: nil, end_time: nil, limit: 500, recv_window: 5000) ⇒ Object
- #cancel_order(symbol:, order_id: nil, orig_client_order_id: nil, new_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, limit: 1000, recv_window: 5000) ⇒ Object
-
#dust_conversion_history(recv_window: 5000) ⇒ Object
— Other —.
- #exchange_information ⇒ Object
- #get_all_coins_information ⇒ Object
- #get_balances ⇒ Object
- #get_withdraw_addresses(recv_window: 5000) ⇒ 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
- #universal_transfer_history(type:, start_time: nil, end_time: nil, page: nil, size: nil, recv_window: 5000) ⇒ Object
- #withdraw(coin:, address:, amount:, network: nil, memo: nil, recv_window: 5000) ⇒ Object
- #withdraw_history(coin: nil, status: nil, start_time: nil, end_time: 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
32 33 34 |
# File 'lib/honeymaker/clients/mexc.rb', line 32 def account_information(recv_window: 5000) get_signed("/api/v3/account", { recvWindow: recv_window }) end |
#account_trade_list(symbol:, order_id: nil, start_time: nil, end_time: nil, limit: 500, recv_window: 5000) ⇒ Object
86 87 88 89 90 91 |
# File 'lib/honeymaker/clients/mexc.rb', line 86 def account_trade_list(symbol:, order_id: nil, start_time: nil, end_time: nil, limit: 500, recv_window: 5000) get_signed("/api/v3/myTrades", { symbol: symbol, orderId: order_id, startTime: start_time, endTime: end_time, limit: limit, recvWindow: recv_window }) end |
#cancel_order(symbol:, order_id: nil, orig_client_order_id: nil, new_client_order_id: nil, recv_window: 5000) ⇒ Object
77 78 79 80 81 82 83 84 |
# File 'lib/honeymaker/clients/mexc.rb', line 77 def cancel_order(symbol:, order_id: nil, orig_client_order_id: nil, new_client_order_id: nil, recv_window: 5000) delete_signed("/api/v3/order", { symbol: symbol, orderId: order_id, origClientOrderId: orig_client_order_id, newClientOrderId: new_client_order_id, recvWindow: recv_window }) end |
#candlestick_data(symbol:, interval:, start_time: nil, end_time: nil, limit: 500) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/honeymaker/clients/mexc.rb', line 25 def candlestick_data(symbol:, interval:, start_time: nil, end_time: nil, limit: 500) get_public("/api/v3/klines", { symbol: symbol, interval: interval, startTime: start_time, endTime: end_time, limit: limit }) end |
#deposit_history(coin: nil, status: nil, start_time: nil, end_time: nil, limit: 1000, recv_window: 5000) ⇒ Object
93 94 95 96 97 98 |
# File 'lib/honeymaker/clients/mexc.rb', line 93 def deposit_history(coin: nil, status: nil, start_time: nil, end_time: nil, limit: 1000, recv_window: 5000) get_signed("/api/v3/capital/deposit/hisrec", { coin: coin, status: status, startTime: start_time, endTime: end_time, limit: limit, recvWindow: recv_window }) end |
#dust_conversion_history(recv_window: 5000) ⇒ Object
— Other —
120 121 122 |
# File 'lib/honeymaker/clients/mexc.rb', line 120 def dust_conversion_history(recv_window: 5000) get_signed("/api/v3/capital/convert", { recvWindow: recv_window }) end |
#exchange_information ⇒ Object
13 14 15 |
# File 'lib/honeymaker/clients/mexc.rb', line 13 def exchange_information get_public("/api/v3/exchangeInfo") end |
#get_all_coins_information ⇒ Object
9 10 11 |
# File 'lib/honeymaker/clients/mexc.rb', line 9 def get_all_coins_information get_public("/api/v3/capital/config/getall") end |
#get_balances ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/honeymaker/clients/mexc.rb', line 36 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 |
#get_withdraw_addresses(recv_window: 5000) ⇒ Object
107 108 109 |
# File 'lib/honeymaker/clients/mexc.rb', line 107 def get_withdraw_addresses(recv_window: 5000) get_signed("/api/v3/capital/withdraw/address", { recvWindow: recv_window }) 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
63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/honeymaker/clients/mexc.rb', line 63 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/v3/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
52 53 54 55 56 57 58 59 60 61 |
# File 'lib/honeymaker/clients/mexc.rb', line 52 def query_order(symbol:, order_id: nil, orig_client_order_id: nil, recv_window: 5000) result = get_signed("/api/v3/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
21 22 23 |
# File 'lib/honeymaker/clients/mexc.rb', line 21 def symbol_order_book_ticker(symbol: nil) get_public("/api/v3/ticker/bookTicker", { symbol: symbol }) end |
#symbol_price_ticker(symbol: nil) ⇒ Object
17 18 19 |
# File 'lib/honeymaker/clients/mexc.rb', line 17 def symbol_price_ticker(symbol: nil) get_public("/api/v3/ticker/price", { symbol: symbol }) end |
#universal_transfer_history(type:, start_time: nil, end_time: nil, page: nil, size: nil, recv_window: 5000) ⇒ Object
124 125 126 127 128 129 |
# File 'lib/honeymaker/clients/mexc.rb', line 124 def universal_transfer_history(type:, start_time: nil, end_time: nil, page: nil, size: nil, recv_window: 5000) get_signed("/api/v3/capital/transfer", { type: type, startTime: start_time, endTime: end_time, page: page, size: size, recvWindow: recv_window }) end |
#withdraw(coin:, address:, amount:, network: nil, memo: nil, recv_window: 5000) ⇒ Object
111 112 113 114 115 116 |
# File 'lib/honeymaker/clients/mexc.rb', line 111 def withdraw(coin:, address:, amount:, network: nil, memo: nil, recv_window: 5000) post_signed("/api/v3/capital/withdraw/apply", { coin: coin, address: address, amount: amount, network: network, memo: memo, recvWindow: recv_window }) end |
#withdraw_history(coin: nil, status: nil, start_time: nil, end_time: nil, limit: 1000, recv_window: 5000) ⇒ Object
100 101 102 103 104 105 |
# File 'lib/honeymaker/clients/mexc.rb', line 100 def withdraw_history(coin: nil, status: nil, start_time: nil, end_time: nil, limit: 1000, recv_window: 5000) get_signed("/api/v3/capital/withdraw/history", { coin: coin, status: status, startTime: start_time, endTime: end_time, limit: limit, recvWindow: recv_window }) end |