module Binance::Spot::Trade

This module includes all spot trading methods, including:

@see binance-docs.github.io/apidocs/spot/en/#spot-account-trade

Public Instance Methods

account(**kwargs) click to toggle source

Account Information (USER_DATA)

GET /api/v3/account

@param kwargs [Hash] @option kwargs [Integer] :recvWindow The value cannot be greater than 60000 @see binance-docs.github.io/apidocs/spot/en/#account-information-user_data

# File lib/binance/spot/trade.rb, line 261
def account(**kwargs)
  @session.sign_request(:get, '/api/v3/account', params: kwargs)
end
all_order_list(**kwargs) click to toggle source

Query all OCO (USER_DATA)

GET /api/v3/allOrderList

Retrieves all OCO based on provided optional parameters

@param kwargs [Hash] @option kwargs [Integer] :fromId @option kwargs [String] :startTime @option kwargs [String] :endTime @option kwargs [String] :limit Default 500; max 1000. @option kwargs [Integer] :recvWindow The value cannot be greater than 60000 @see binance-docs.github.io/apidocs/spot/en/#query-all-oco-user_data

# File lib/binance/spot/trade.rb, line 239
def all_order_list(**kwargs)
  @session.sign_request(:get, '/api/v3/allOrderList', params: kwargs)
end
all_orders(symbol:, **kwargs) click to toggle source

All Orders (USER_DATA)

GET /api/v3/allOrders

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

@param symbol [String] the symbol @param kwargs [Hash] @option kwargs [String] :orderId @option kwargs [String] :startTime @option kwargs [String] :endTime @option kwargs [String] :limit Default 500; max 1000. @option kwargs [Integer] :recvWindow The value cannot be greater than 60000 @see binance-docs.github.io/apidocs/spot/en/#all-orders-user_data

# File lib/binance/spot/trade.rb, line 150
def all_orders(symbol:, **kwargs)
  Binance::Utils::Validation.require_param('symbol', symbol)

  @session.sign_request(:get, '/api/v3/allOrders', params: kwargs.merge(symbol: symbol))
end
cancel_open_orders(symbol:, **kwargs) click to toggle source

Cancel all Open Orders on a Symbol (TRADE)

DELETE /api/v3/openOrders

@param symbol [String] the symbol @param kwargs [Hash] @option kwargs [Integer] :recvWindow The value cannot be greater than 60000 @see binance-docs.github.io/apidocs/spot/en/#cancel-all-open-orders-on-a-symbol-trade

# File lib/binance/spot/trade.rb, line 102
def cancel_open_orders(symbol:, **kwargs)
  Binance::Utils::Validation.require_param('symbol', symbol)

  @session.sign_request(:delete, '/api/v3/openOrders', params: kwargs.merge(symbol: symbol))
end
cancel_order(symbol:, **kwargs) click to toggle source

Cancel Order (TRADE)

DELETE /api/v3/order

@param symbol [String] the symbol @param kwargs [Hash] @option kwargs [Integer] :orderId @option kwargs [String] :origClientOrderId @option kwargs [String] :newClientOrderId @option kwargs [Integer] :recvWindow The value cannot be greater than 60000 @see binance-docs.github.io/apidocs/spot/en/#cancel-order-trade

# File lib/binance/spot/trade.rb, line 88
def cancel_order(symbol:, **kwargs)
  Binance::Utils::Validation.require_param('symbol', symbol)

  @session.sign_request(:delete, '/api/v3/order', params: kwargs.merge(symbol: symbol))
end
cancel_order_list(symbol:, **kwargs) click to toggle source

Cancel OCO (TRADE)

DELETE /api/v3/orderList

@param symbol [String] the symbol @param kwargs [Hash] @option kwargs [Integer] :orderListId @option kwargs [String] :listClientOrderId @option kwargs [String] :newClientOrderId @option kwargs [Integer] :recvWindow The value cannot be greater than 60000 @see binance-docs.github.io/apidocs/spot/en/#cancel-oco-trade

# File lib/binance/spot/trade.rb, line 205
def cancel_order_list(symbol:, **kwargs)
  Binance::Utils::Validation.require_param('symbol', symbol)

  @session.sign_request(:delete, '/api/v3/orderList', params: kwargs.merge(symbol: symbol))
end
get_order(symbol:, **kwargs) click to toggle source

Query Order (USER_DATA)

GET /api/v3/order

@param symbol [String] the symbol @param kwargs [Hash] @option kwargs [Integer] :orderId @option kwargs [String] :origClientOrderId @option kwargs [Integer] :recvWindow The value cannot be greater than 60000 @see binance-docs.github.io/apidocs/spot/en/#query-order-user_data

# File lib/binance/spot/trade.rb, line 118
def get_order(symbol:, **kwargs)
  Binance::Utils::Validation.require_param('symbol', symbol)

  @session.sign_request(:get, '/api/v3/order', params: kwargs.merge(symbol: symbol))
end
get_order_rate_limit(**kwargs) click to toggle source

Query Current Order Count Usage (TRADE)

GET /api/v3/rateLimit/order

@param kwargs [Hash] @option kwargs [Integer] :recvWindow The value cannot be greater than 60000 @see binance-docs.github.io/apidocs/spot/en/#query-current-order-count-usage-trade

# File lib/binance/spot/trade.rb, line 289
def get_order_rate_limit(**kwargs)
  @session.sign_request(:get, '/api/v3/rateLimit/order', params: kwargs)
end
my_trades(symbol:, **kwargs) click to toggle source

Account Trade List (USER_DATA)

GET /api/v3/myTrades

@param symbol [String] the symbol @param kwargs [Hash] @option kwargs [Integer] :orderId @option kwargs [Integer] :startTime @option kwargs [Integer] :endTime @option kwargs [Integer] :fromId TradeId to fetch from. Default gets most recent trades. @option kwargs [Integer] :limit Default 500; max 1000. @option kwargs [Integer] :recvWindow The value cannot be greater than 60000 @see binance-docs.github.io/apidocs/spot/en/#account-trade-list-user_data

# File lib/binance/spot/trade.rb, line 278
def my_trades(symbol:, **kwargs)
  @session.sign_request(:get, '/api/v3/myTrades', params: kwargs.merge(symbol: symbol))
end
new_oco_order(symbol:, side:, quantity:, price:, stopPrice:, **kwargs) click to toggle source

New OCO (TRADE)

POST /api/v3/order/oco

Send in a new OCO

@param symbol [String] the symbol @param side [String] @param quantity [Float] @param price [Float] @param stopPrice [Float] @param kwargs [Hash] @option kwargs [String] :listClientOrderId @option kwargs [String] :limitClientOrderId @option kwargs [Float] :limitIcebergQty @option kwargs [String] :stopClientOrderId @option kwargs [Float] :stopLimitPrice @option kwargs [Float] :stopIcebergQty @option kwargs [Float] :stopLimitTimeInForce GTC/ FOK/ IOC @option kwargs [String] :newOrderRespType @option kwargs [Integer] :recvWindow The value cannot be greater than 60000 @see binance-docs.github.io/apidocs/spot/en/#new-oco-trade

# File lib/binance/spot/trade.rb, line 178
def new_oco_order(symbol:, side:, quantity:, price:, stopPrice:, **kwargs)
  Binance::Utils::Validation.require_param('symbol', symbol)
  Binance::Utils::Validation.require_param('side', side)
  Binance::Utils::Validation.require_param('quantity', quantity)
  Binance::Utils::Validation.require_param('price', price)
  Binance::Utils::Validation.require_param('stopPrice', stopPrice)

  @session.sign_request(:post, '/api/v3/order/oco', params: kwargs.merge(
    symbol: symbol,
    side: side,
    quantity: quantity,
    price: price,
    stopPrice: stopPrice
  ))
end
new_order(symbol:, side:, type:, **kwargs) click to toggle source

New Order

POST /api/v3/order

send in a new order

@param symbol [String] the symbol @param side [String] @param type [String] @param kwargs [Hash] @option kwargs [String] :timeInForce @option kwargs [Float] :quantity @option kwargs [Float] :quoteOrderQty @option kwargs [Float] :price @option kwargs [String] :newClientOrderId @option kwargs [Float] :stopPrice @option kwargs [Float] :icebergeQty @option kwargs [String] :newOrderRespType Set the response JSON. ACK, RESULT, or FULL. @option kwargs [Integer] :recvWindow The value cannot be greater than 60000 @see binance-docs.github.io/apidocs/spot/en/#new-order-trade

# File lib/binance/spot/trade.rb, line 65
def new_order(symbol:, side:, type:, **kwargs)
  Binance::Utils::Validation.require_param('symbol', symbol)
  Binance::Utils::Validation.require_param('side', side)
  Binance::Utils::Validation.require_param('type', type)

  @session.sign_request(:post, '/api/v3/order', params: kwargs.merge(
    symbol: symbol,
    side: side,
    type: type
  ))
end
new_order_test(symbol:, side:, type:, **kwargs) click to toggle source

TestNew Order

POST /api/v3/order/test

send in a new order to test the request, no order is really generated.

@param symbol [String] the symbol @param side [String] @param type [String] @param kwargs [Hash] @option kwargs [String] :timeInForce @option kwargs [Float] :quantity @option kwargs [Float] :quoteOrderQty @option kwargs [Float] :price @option kwargs [String] :newClientOrderId @option kwargs [Float] :stopPrice @option kwargs [Float] :icebergeQty @option kwargs [String] :newOrderRespType Set the response JSON. ACK, RESULT, or FULL. @option kwargs [Integer] :recvWindow The value cannot be greater than 60000 @see binance-docs.github.io/apidocs/spot/en/#test-new-order-trade

# File lib/binance/spot/trade.rb, line 33
def new_order_test(symbol:, side:, type:, **kwargs)
  Binance::Utils::Validation.require_param('symbol', symbol)
  Binance::Utils::Validation.require_param('side', side)
  Binance::Utils::Validation.require_param('type', type)

  @session.sign_request(:post, '/api/v3/order/test', params: kwargs.merge(
    symbol: symbol,
    side: side,
    type: type
  ))
end
open_order_list(**kwargs) click to toggle source

Query Open OCO (USER_DATA)

GET /api/v3/openOrderList

@param kwargs [Hash] @option kwargs [Integer] :recvWindow The value cannot be greater than 60000 @see binance-docs.github.io/apidocs/spot/en/#query-open-oco-user_data

# File lib/binance/spot/trade.rb, line 250
def open_order_list(**kwargs)
  @session.sign_request(:get, '/api/v3/openOrderList', params: kwargs)
end
open_orders(**kwargs) click to toggle source

Current Open Orders (USER_DATA)

GET /api/v3/openOrders

@param kwargs [Hash] @option kwargs [String] :symbol the symbol @option kwargs [Integer] :recvWindow The value cannot be greater than 60000 @see binance-docs.github.io/apidocs/spot/en/#current-open-orders-user_data

# File lib/binance/spot/trade.rb, line 132
def open_orders(**kwargs)
  @session.sign_request(:get, '/api/v3/openOrders', params: kwargs)
end
order_list(**kwargs) click to toggle source

Query OCO (USER_DATA)

GET /api/v3/orderList

Retrieves a specific OCO based on provided optional parameters

@param kwargs [Hash] @option kwargs [Integer] :orderListId @option kwargs [String] :orgClientOrderId @option kwargs [Integer] :recvWindow The value cannot be greater than 60000 @see binance-docs.github.io/apidocs/spot/en/#query-oco-user_data

# File lib/binance/spot/trade.rb, line 222
def order_list(**kwargs)
  @session.sign_request(:get, '/api/v3/orderList', params: kwargs)
end