module

Binance::Endpoints

Inherits Binance::Responses

Constants

ENDPOINTS = { ping: "api/v3/ping", time: "api/v3/time", exchange_info: "api/v3/exchangeInfo", depth: "api/v3/depth", trades: "api/v3/trades", historical_trades: "api/v3/historicalTrades", agg_trades: "api/v3/aggTrades", klines: "api/v3/klines", twenty_four_hour: "api/v3/ticker/24hr", price: "api/v3/ticker/price", avg_price: "api/v3/avgPrice", book_ticker: "api/v3/ticker/bookTicker", new_order: "api/v3/order", get_order: "api/v3/order", cancel_order: "api/v3/order", new_test_order: "api/v3/order/test", open_orders: "api/v3/openOrders", all_orders: "api/v3/allOrders", account: "api/v3/account", my_trades: "api/v3/myTrades", new_oco_order: "api/v3/order/oco", get_oco_order: "api/v3/orderList", cancel_oco_order: "api/v3/orderList", user_data_stream: "api/v3/userDataStream", withdraw: "api/v3/withdraw.html", deposit_history: "api/v3/depositHistory.html", withdraw_history: "api/v3/withdrawHistory.html", deposit_address: "api/v3/depositAddress.html", account_status: "api/v3/accountStatus.html", system_status: "api/v3/systemStatus.html", withdraw_fee: "api/v3/withdrawFee.html", dust_log: "api/v3/userAssetDribbletLog.html", margin_new_order: "sapi/v1/margin/order", margin_cancel_order: "sapi/v1/margin/order", }

Instance methods

account
Source
agg_trades(symbol : String, limit : Int32 = 500, from_id : Int64 | Nil = nil, start_time : Time | Nil = nil, end_time : Time | Nil = nil)
NameTypeMandatoryDescription
symbolSTRINGYES
fromIdLONGNOID to get aggregate trades from INCLUSIVE.
startTimeLONGNOTimestamp in ms to get aggregate trades from INCLUSIVE.
endTimeLONGNOTimestamp in ms to get aggregate trades until INCLUSIVE.
limitINTNODefault 500; max 1000.
  • If both startTime and endTime are sent, time between startTime and endTime must be less than 1 hour.
  • If fromId, startTime, and endTime are not sent, the most recent aggregate trades will be returned.
Source
all_orders(symbol : String, order_id : Int64 | Nil = nil, limit : Int32 = 500, start_time : Time | Nil = nil, end_time : Time | Nil = nil)

Get all account orders; active, canceled, or filled.

Name Type Mandatory Description symbol STRING YES orderId LONG NO startTime LONG NO endTime LONG NO limit INT NO Default 500; max 1000. recvWindow LONG NO timestamp LONG YES

Notes:

  • If orderId is set, it will get orders >= that orderId. Otherwise most recent orders are returned.
  • For some historical orders cummulativeQuoteQty will be < 0, meaning the data is not available at this time.
Source
avg_price(symbol : String)
Source
book_ticker(symbol : String | Nil = nil)
Source
cancel_oco_order(symbol : String, order_list_id : Int32 | Int64 | Nil = nil, list_client_order_id : String | Nil = nil, client_order_id : String | Nil = nil)
Source
cancel_order(symbol : String, order_id : Int32 | Int64 | Nil = nil, client_order_id : String | Nil = nil)

Cancel an active order

Name Type Mandatory Description symbol STRING YES orderId LONG NO origClientOrderId STRING NO recvWindow LONG NO timestamp LONG YES

  • Either orderId or origClientOrderId must be sent.
Source
depth(symbol : String, limit : Int32 = 5)
Source
exchange_info
Source
get_oco_order(order_list_id : Int32 | Int64 | Nil = nil, list_client_order_id : String | Nil = nil)
Source
get_order(symbol : String, order_id : Int32 | Int64 | Nil = nil, client_order_id : String | Nil = nil)

Check an order's status

Name Type Mandatory Description symbol STRING YES orderId LONG NO origClientOrderId STRING NO recvWindow LONG NO timestamp LONG YES

  • Either orderId or origClientOrderId must be sent.
  • For some historical orders cummulativeQuoteQty will be < 0, meaning the data is not available at this time.
Source
historical_trades(symbol : String, limit : Int32 = 500)
Source
klines(symbol : String, interval : String, limit : Int32 = 500, start_time : Time | Nil = nil, end_time : Time | Nil = nil)

Name Type Mandatory Description symbol STRING YES interval ENUM YES startTime LONG NO endTime LONG NO limit INT NO Default 500; max 1000.

  • If startTime and endTime are not sent, the most recent klines are returned.
Source
margin_cancel_order(symbol : String, order_id : Int32 | Int64 | Nil = nil, client_order_id : String | Nil = nil, is_isolated : String | Nil = nil)
Source
margin_new_order(symbol : String, side : String, order_type : String, quantity : Float64 | String, time_in_force : String | Nil = nil, price : Float64 | Nil = nil, client_order_id : String | Nil = nil, stop_price : Float64 | Nil = nil, iceberg_quantity : Float64 | Nil = nil, response_type : String | Nil = nil, is_isolated : String | Nil = nil, side_effect_type : String | Nil = nil)
Source
my_trades(symbol : String, limit : Int32 = 500, from_id : Int64 | Nil = nil, start_time : Time | Nil = nil, end_time : Time | Nil = nil)

Get trades for a specific account and symbol.

Name Type Mandatory Description symbol STRING YES startTime LONG NO endTime LONG NO fromId LONG NO TradeId to fetch from. Default gets most recent trades. limit INT NO Default 500; max 1000. recvWindow LONG NO timestamp LONG YES Notes:

  • If fromId is set, it will get orders >= that fromId. Otherwise most recent orders are returned.
Source
new_oco_order(symbol : String, side : String, quantity : Float64 | String, price : Float64, stop_price : Float64, stop_limit_price : Float64 | Nil = nil, stop_limit_time_in_force : String | Nil = nil, response_type : String | Nil = nil, limit_iceberg_quantity : Float64 | Nil = nil, list_client_order_id : String | Nil = nil, limit_client_order_id : String | Nil = nil, stop_client_order_id : String | Nil = nil)
Source
new_order(symbol : String, side : String, order_type : String, quantity : Float64 | String, time_in_force : String | Nil = nil, price : Float64 | Nil = nil, client_order_id : String | Nil = nil, stop_price : Float64 | Nil = nil, iceberg_quantity : Float64 | Nil = nil, response_type : String | Nil = nil)

Send in a new order.

Parameters:

  • Name Type Mandatory Description
  • symbol STRING YES
  • side ENUM YES
  • type ENUM YES
  • timeInForce ENUM NO
  • quantity DECIMAL YES
  • price DECIMAL NO
  • newClientOrderId STRING NO A unique id for the order. Automatically generated if not sent.
  • stopPrice DECIMAL NO Used with STOP_LOSS, STOP_LOSS_LIMIT, TAKE_PROFIT, and TAKE_PROFIT_LIMIT orders.
  • icebergQty DECIMAL NO Used with LIMIT, STOP_LOSS_LIMIT, and TAKE_PROFIT_LIMIT to create an iceberg order.
  • newOrderRespType ENUM NO Set the response JSON. ACK, RESULT, or FULL; MARKET and LIMIT order types default to FULL, all other orders default to ACK.
  • recvWindow LONG NO
  • timestamp LONG YES

Additional mandatory parameters based on type:

  • Type Additional mandatory parameters
  • LIMIT timeInForce, quantity, price
  • MARKET quantity
  • STOP_LOSS quantity, stopPrice
  • STOP_LOSS_LIMIT timeInForce, quantity, price, stopPrice
  • TAKE_PROFIT quantity, stopPrice
  • TAKE_PROFIT_LIMIT timeInForce, quantity, price, stopPrice
  • LIMIT_MAKER quantity, price

Other info:

  • LIMIT_MAKER are LIMIT orders that will be rejected if they would immediately match and trade as a taker.

  • STOP_LOSS and TAKE_PROFIT will execute a MARKET order when the stopPrice is reached.

  • Any LIMIT or LIMIT_MAKER type order can be made an iceberg order by sending an icebergQty.

  • Any order with an icebergQty MUST have timeInForce set to GTC.

  • Trigger order price rules against market price for both MARKET and LIMIT versions:

  • Price above market price: STOP_LOSS BUY, TAKE_PROFIT SELL

  • Price below market price: STOP_LOSS SELL, TAKE_PROFIT BUY

Source
new_test_order(symbol : String, side : String, order_type : String, quantity : Float64 | String, time_in_force : String | Nil = nil, price : Float64 | Nil = nil, client_order_id : String | Nil = nil, stop_price : Float64 | Nil = nil, iceberg_quantity : Float64 | Nil = nil, response_type : String | Nil = nil)
Source
open_orders(symbol : String)
Source
optional_param(params : HTTP::Params, key : String, value : Nil)
Source
optional_param(params : HTTP::Params, key : String, value : String)
Source
optional_param(params : HTTP::Params, key : String, value : Float64 | Int32 | Int64)
Source
optional_param(params : HTTP::Params, key : String, value : Time)
Source
ping
Source
price(symbol : String | Nil = nil)
Source
symbol_param(params : HTTP::Params, value : String | Nil)
Source
time
Source
trades(symbol : String, limit : Int32 = 500)
Source
twenty_four_hour(symbol : String | Nil = nil)
Source
user_data_stream
Source

Macros

fetch(action, client, endpoint, response_klass, params = HTTP::Params.new)
Source