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

@option recvWindow [Integer] 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 248
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

@option fromId [Integer] @option startTime [String] @option endTime [String] @option limit [String] Default 500; max 1000. @option recvWindow [Integer] 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 228
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 @option orderId [String] @option startTime [String] @option endTime [String] @option limit [String] Default 500; max 1000. @option recvWindow [Integer] 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 143
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 @option recvWindow [Integer] 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 98
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 @option orderId [Integer] @option origClientOrderId [String] @option newClientOrderId [String] @option recvWindow [Integer] 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 85
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 @option orderListId [Integer] @option listClientOrderId [String] @option newClientOrderId [String] @option recvWindow [Integer] 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 196
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 @option orderId [Integer] @option origClientOrderId [String] @option recvWindow [Integer] 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 113
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
my_trades(symbol:, **kwargs) click to toggle source

Account Trade List (USER_DATA)

GET /api/v3/myTrades

@param symbol [String] the symbol @option startTime [Integer] @option endTime [Integer] @option fromId [Integer] TradeId to fetch from. Default gets most recent trades. @option limit [Integer] Default 500; max 1000. @option recvWindow [Integer] 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 263
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] @option listClientOrderId [String] @option limitClientOrderId [String] @option limitIcebergQty [Float] @option stopClientOrderId [String] @option stopLimitPrice [Float] @option stopIcebergQty [Float] @option stopLimitTimeInForce @option newOrderRespType [String] @option recvWindow [Integer] 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 170
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] @option timeInForce [String] @option quantity [Float] @option quoteOrderQty [Float] @option price [Float] @option newClientOrderId [String] @option stopPrice [Float] @option icebergeQty [Float] @option newOrderRespType [String] @option recvWindow [Integer] 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 63
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] @option timeInForce [String] @option quantity [Float] @option quoteOrderQty [Float] @option price [Float] @option newClientOrderId [String] @option stopPrice [Float] @option icebergeQty [Float] @option newOrderRespType [String] @option recvWindow [Integer] 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 32
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

@option recvWindow [Integer] 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 238
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

@option symbol [String] the symbol @option recvWindow [Integer] 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 126
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

@option orderListId [String] @option orgClientOrderId [String] @option recvWindow [Integer] 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 212
def order_list(**kwargs)
  @session.sign_request(:get, '/api/v3/orderList', params: kwargs)
end