module Binance::Endpoints

Included Modules

Direct including types

Defined in:

binance/client/rest/endpoints.cr

Constant Summary

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

Instance Method Summary

Macro Summary

Instance Method Detail

def account #

def agg_trades(symbol : String, limit : Int32 = 500, from_id : Int64? = nil, start_time : Time? = nil, end_time : Time? = nil) #

Name | Type | Mandatory | Description -----------|--------|------------|------------ symbol | STRING | YES | fromId | LONG | NO | ID to get aggregate trades from INCLUSIVE. startTime | LONG | NO | Timestamp in ms to get aggregate trades from INCLUSIVE. endTime | LONG | NO | Timestamp in ms to get aggregate trades until INCLUSIVE. limit | INT | NO | Default 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.

def all_orders(symbol : String, order_id : Int64? = nil, limit : Int32 = 500, start_time : Time? = nil, end_time : Time? = 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.

def avg_price(symbol : String) #

def book_ticker(symbol : String? = nil) #

def cancel_order(symbol : String, order_id : Int32 | Int64? = nil, client_order_id : String? = 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.

def depth(symbol : String, limit : Int32 = 5) #

def exchange_info #

def get_order(symbol : String, order_id : Int32 | Int64? = nil, client_order_id : String? = 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.

def historical_trades(symbol : String, limit : Int32 = 500) #

def klines(symbol : String, interval : String, limit : Int32 = 500, start_time : Time? = nil, end_time : Time? = 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.

def my_trades(symbol : String, limit : Int32 = 500, from_id : Int64? = nil, start_time : Time? = nil, end_time : Time? = 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.

def new_order(symbol : String, side : String, order_type : String, quantity : Float64 | String, time_in_force : String? = nil, price : Float64? = nil, client_order_id : String? = nil, stop_price : Float64? = nil, iceberg_quantity : Float64? = nil, response_type : String? = 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

def new_test_order(symbol : String, side : String, order_type : String, quantity : Float64 | String, time_in_force : String? = nil, price : Float64? = nil, client_order_id : String? = nil, stop_price : Float64? = nil, iceberg_quantity : Float64? = nil, response_type : String? = nil) #

def open_orders(symbol : String) #

def optional_param(params : HTTP::Params, key : String, value : Nil) #

def optional_param(params : HTTP::Params, key : String, value : String) #

def optional_param(params : HTTP::Params, key : String, value : Float64 | Int32 | Int64) #

def optional_param(params : HTTP::Params, key : String, value : Time) #

def ping #

def price(symbol : String? = nil) #

def symbol_param(params : HTTP::Params, value : String?) #

def time #

def trades(symbol : String, limit : Int32 = 500) #

def twenty_four_hour(symbol : String? = nil) #

def user_data_stream #

Macro Detail

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