Skip to content

Spot Account_Trade

Mauro Petrini edited this page Apr 17, 2021 · 22 revisions

Spot Account/Trade

Spot Account/Trade endpoints are under bnc spot group command.

Jump to:

New order

https://binance-docs.github.io/apidocs/spot/en/#new-order-trade

Different types of orders are under bnc spot new_order group command.

Jump to:

Stop Loss and Take Profit orders

At this date [April 2021], Binance doesn't support STOP_LOSS or TAKE_PROFIT orders for any of the symbols. Instead, you have to use STOP_LOSS_LIMIT or TAKE_PROFIT_LIMIT orders.

If you discovered a symbol allowed to create a STOP_LOSS or TAKE_PROFIT orders, you could fill an issue to inform this.

Limit order

Send in a new limit order

Binance CLI Command

bnc spot new_order limit

Options

  • -sy or --symbol
  • -si or --side
  • -tif or --time_in_force
  • -q or --quantity
  • -p or --price
  • -ncoid or --new_client_order_id
  • -iq or --iceberg_qty
  • -rw or --recv_window
  • -nort or --new_order_resp_type

🚨 Required options

-sy --symbol
-si --side
-tif --time_in_force
-q --quantity
-p --price

Examples

Double hyphen options

$ bnc spot new_order limit --symbol="LTCBTC" --side="BUY" --time_in_force="GTC" --quantity=1 --price=0.0033
$ bnc spot new_order limit --symbol="LTCBTC" --side="BUY" --time_in_force="GTC" --quantity=1 --price=0.0036 --new_client_order_id="custom_id"
$ bnc spot new_order limit --symbol="LTCBTC" --side="BUY" --time_in_force="GTC" --quantity=1 --price=0.0036 --iceberg_qty=0.20
$ bnc spot new_order limit --symbol="LTCBTC" --side="BUY" --time_in_force="GTC" --quantity=1 --price=0.0036 --new_order_resp_type="ACK"

Single hyphen options

$ bnc spot new_order limit -sy "LTCBTC" -si "BUY" -tif "GTC" -q 1 -p 0.0033
$ bnc spot new_order limit -sy "LTCBTC" -si "BUY" -tif "GTC" -q 1 -p 0.0033 -ncoid "custom_id"
$ bnc spot new_order limit -sy "LTCBTC" -si "BUY" -tif "GTC" -q 1 -p 0.0033 -iq 0.20
$ bnc spot new_order limit -sy "LTCBTC" -si "BUY" -tif "GTC" -q 1 -p 0.0033 -nort "ACK"

Limit maker order

Send in a new limit maker order

Binance CLI Command

bnc spot new_order limit_maker

Options

  • -sy or --symbol
  • -si or --side
  • -q or --quantity
  • -p or --price
  • -ncoid or --new_client_order_id
  • -iq or --iceberg_qty
  • -rw or --recv_window
  • -nort or --new_order_resp_type

🚨 Required options

-sy --symbol
-si --side
-q --quantity
-p --price

Examples

Double hyphen options

$ bnc spot new_order limit_maker --symbol="LTCBTC" --side="BUY" --quantity=1 --price=0.0020
$ bnc spot new_order limit_maker --symbol="LTCBTC" --side="BUY" --quantity=1 --price=0.0020 --new_client_order_id="my_custom_id"
$ bnc spot new_order limit_maker --symbol="LTCBTC" --side="BUY" --quantity=1 --price=0.0020 --iceberg_qty=0.5
$ bnc spot new_order limit_maker --symbol="LTCBTC" --side="BUY" --quantity=1 --price=0.0020 --new_order_resp_type="FULL"

Single hyphen options

$ bnc spot new_order limit_maker -sy "LTCBTC" -si "BUY" -q 1 -p 0.0020
$ bnc spot new_order limit_maker -sy "LTCBTC" -si "BUY" -q 1 -p 0.0020 -ncoid "my_custom_id"
$ bnc spot new_order limit_maker -sy "LTCBTC" -si "BUY" -q 1 -p 0.0020 -iq 0.5
$ bnc spot new_order limit_maker -sy "LTCBTC" -si "BUY" -q 1 -p 0.0020 -nort "FULL"

Market order

Send in a new market order

Note:

Either --quantity (-q) or --quote_order_qty (-qoq) must be sent.

Binance CLI Command

bnc spot new_order market

Options

  • -sy or --symbol
  • -si or --side
  • -q or --quantity
  • -qoq or --quote_order_qty
  • -ncoid or --new_client_order_id
  • -rw or --recv_window
  • -nort or --new_order_resp_type

🚨 Required options

-sy --symbol
-si --side

Examples

Double hyphen options

$ bnc spot new_order market --symbol="LTCBTC" --side="BUY" --quantity=1
$ bnc spot new_order market --symbol="LTCBTC" --side="BUY" --quote_order_qty=1
$ bnc spot new_order market --symbol="LTCBTC" --side="BUY" --quantity=1 --new_client_order_id="custom_id"
$ bnc spot new_order market --symbol="LTCBTC" --side="BUY" --quantity=1 --new_order_resp_type="RESULT"

Single hyphen options

$ bnc spot new_order market -sy "LTCBTC" -si "BUY" -q 1
$ bnc spot new_order market -sy "LTCBTC" -si "BUY" -qoq 1
$ bnc spot new_order market -sy "LTCBTC" -si "BUY" -q 1 -ncoid "custom_id"
$ bnc spot new_order market -sy "LTCBTC" -si "BUY" -q 1 -nort "RESULT"

Take profit limit order

Send in a new take profit limit order

Binance CLI Command

bnc spot new_order take_profit_limit

Options

  • -sy or --symbol
  • -si or --side
  • -tif or --time_in_force
  • -q or --quantity
  • -p or --price
  • -ncoid or --new_client_order_id
  • -sp or --stop_price
  • -iq or --iceberg_qty
  • -rw or --recv_window
  • -nort or --new_order_resp_type

🚨 Required options

-sy --symbol
-si --side
-tif --time_in_force
-q --quantity
-p --price
-sp --stop_price

Examples

Double hyphen options

$ bnc spot new_order take_profit_limit --symbol="LTCBTC" --side="BUY" --time_in_force="GTC" --quantity=1 --price=0.0020 --stop_price=0.0015
$ bnc spot new_order take_profit_limit --symbol="LTCBTC" --side="BUY" --time_in_force="GTC" --quantity=1 --price=0.0020 --stop_price=0.0015 --new_client_order_id="custom_id"
$ bnc spot new_order take_profit_limit --symbol="LTCBTC" --side="BUY" --time_in_force="GTC" --quantity=1 --price=0.0020 --stop_price=0.0015 --iceberg_qty=0.5
$ bnc spot new_order take_profit_limit --symbol="LTCBTC" --side="BUY" --time_in_force="GTC" --quantity=1 --price=0.0020 --stop_price=0.0015 --new_order_resp_type="FULL"

Single hyphen options

$ bnc spot new_order take_profit_limit -sy "LTCBTC" -si "BUY" -tif "GTC" -q 1 -p 0.0020 -sp 0.0015
$ bnc spot new_order take_profit_limit -sy "LTCBTC" -si "BUY" -tif "GTC" -q 1 -p 0.0020 -sp 0.0015 -ncoid "custom_id"
$ bnc spot new_order take_profit_limit -sy "LTCBTC" -si "BUY" -tif "GTC" -q 1 -p 0.0020 -sp 0.0015 -iceberg_qty 0.5
$ bnc spot new_order take_profit_limit -sy "LTCBTC" -si "BUY" -tif "GTC" -q 1 -p 0.0020 -sp 0.0015 -nort "FULL"

Stop loss limit order

Send in a new stop loss limit order

Binance CLI Command

bnc spot new_order stoo_loss_limit

Options

  • -sy or --symbol
  • -si or --side
  • -tif or --time_in_force
  • -q or --quantity
  • -p or --price
  • -ncoid or --new_client_order_id
  • -sp or --stop_price
  • -iq or --iceberg_qty
  • -rw or --recv_window
  • -nort or --new_order_resp_type

🚨 Required options

-sy --symbol
-si --side
-tif --time_in_force
-q --quantity
-p --price
-sp --stop_price

Examples

Double hyphen options

$ bnc spot new_order stop_loss_limit --symbol="LTCBTC" --side="BUY" --time_in_force="GTC" --quantity=1 --price=0.0060 --stop_price=0.0050
$ bnc spot new_order stop_loss_limit --symbol="LTCBTC" --side="BUY" --time_in_force="GTC" --quantity=1 --price=0.0060 --stop_price=0.0050 --new_client_order_id="custom_id"
$ bnc spot new_order stop_loss_limit --symbol="LTCBTC" --side="BUY" --time_in_force="GTC" --quantity=1 --price=0.0060 --stop_price=0.0050 --iceberg_qty=0.5--iceberg_qty=0.5
$ bnc spot new_order stop_loss_limit --symbol="LTCBTC" --side="BUY" --time_in_force="GTC" --quantity=1 --price=0.0060 --stop_price=0.0050 --new_order_resp_type="FULL"

Single hyphen options

$ bnc spot new_order stop_loss_limit -sy "LTCBTC" -si "BUY" -tif "GTC" -q 1 -p 0.0060 -sp 0.0050
$ bnc spot new_order stop_loss_limit -sy "LTCBTC" -si "BUY" -tif "GTC" -q 1 -p 0.0060 -sp 0.0050 -ncoid "custom_id"
$ bnc spot new_order stop_loss_limit -sy "LTCBTC" -si "BUY" -tif "GTC" -q 1 -p 0.0060 -sp 0.0050 -iceberg_qty 0.5
$ bnc spot new_order stop_loss_limit -sy "LTCBTC" -si "BUY" -tif "GTC" -q 1 -p 0.0060 -sp 0.0050 -nort "FULL"

Cancel Order

https://binance-docs.github.io/apidocs/spot/en/#cancel-order-trade

Cancel an active order.

Weight:

  • 1

Binance CLI Command

bnc spot cancel_order [options]

Options

  • -sy or --symbol
  • -oid or--order_id
  • -ocoid or--orig_client_order_id
  • -ncoid or --new_client_order_id
  • -rw or--recv_window

🚨 Required options

-sy --symbol

Examples

Double hyphen options

$ bnc spot cancel_order --symbol="LTCBTC" --order_id=136
$ bnc spot cancel_order --symbol="LTCBTC" --orig_client_order_id="FNgPVZtPCUP9Uw0zMBGofl"
$ bnc spot cancel_order --symbol="LTCBTC" --order_id=138 --orig_client_order_id="R0h99zavwIbthu5Tb7QVOh"
$ bnc spot cancel_order --symbol="LTCBTC" --order_id=141 --orig_client_order_id="9d8SDJbefO9D593XuGa3SZ" --new_client_order_id="my_custom_id"

Single hyphen options

$ bnc spot cancel_order -sy "LTCBTC" -oid 6
$ bnc spot cancel_order -sy "LTCBTC" -ocoid "FNgPVZtPCUP9Uw0zMBGofl"
$ bnc spot cancel_order -sy "LTCBTC" -oid 138 -ocoid "R0h99zavwIbthu5Tb7QVOh"
$ bnc spot cancel_order -sy "LTCBTC" -oid 141 -ocoid "9d8SDJbefO9D593XuGa3SZ" -ncoid "my_custom_id"

Cancel all open orders on a symbol

https://binance-docs.github.io/apidocs/spot/en/#cancel-all-open-orders-on-a-symbol-trade

Cancels all active orders on a symbol. This includes OCO orders.

Weight:

  • 1

Binance CLI Command

bnc spot cancel_all_orders [options]

Options

  • -sy or --symbol
  • -rw or--recv_window

🚨 Required options

-sy --symbol

Examples

Double hyphen options

$ bnc spot cancel_all_orders --symbol="LTCBTC"

Single hyphen options

$ bnc spot cancel_all_orders -sy "LTCBTC"

Query Order (Order status)

https://binance-docs.github.io/apidocs/spot/en/#query-order-user_data

Check an order's status.

Weight:

  • 1

Binance CLI Command

bnc spot order_status [options]

Options

  • -sy or --symbol
  • -oid or--order_id
  • -ocoid or--orig_client_order_id
  • -rw or--recv_window

🚨 Required options

-sy --symbol

Examples

Double hyphen options

$ bnc spot order_status --symbol="LTCBTC" --order_id=6
$ bnc spot order_status --symbol="LTCBTC" --orig_client_order_id="OryHfXeB5m6T1sVe5cC289"
$ bnc spot order_status --symbol="LTCBTC" --order_id=6 --orig_client_order_id="OryHfXeB5m6T1sVe5cC289"

Single hyphen options

$ bnc spot order_status -sy "LTCBTC" -oid 6
$ bnc spot order_status -sy "LTCBTC" -ocoid "OryHfXeB5m6T1sVe5cC289"
$ bnc spot order_status -sy "LTCBTC" -oid 6 -ocoid "OryHfXeB5m6T1sVe5cC289"

Current Open Orders

https://binance-docs.github.io/apidocs/spot/en/#current-open-orders-user_data

Get all open orders on a symbol. Careful when accessing this with no symbol.

Weight:

  • 1 for a single symbol.
  • 40 when the symbol parameter is omitted.

Binance CLI Command

bnc spot open_orders [options]

Options

  • -sy or --symbol
  • -rw or--recv_window

Examples

Without options

$ bnc spot open_orders

Double hyphen options

$ bnc spot open_orders --symbol="LTCBTC"

Single hyphen options

$ bnc spot open_orders -sy "LTCBTC"

All Orders

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

Weight:

  • 5 with symbol.

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.

Binance CLI Command

bnc spot all_orders [options]

Options

  • -sy or --symbol
  • -oid or --order_id
  • -st or --start_time
  • -et or --end_time
  • -l or --limit
  • -rw or --recv_window
  • --query

🚨 Required options

-sy --symbol

Examples

Double hyphen options

$ bnc spot all_orders --symbol="LTCBTC"
$ bnc spot all_orders --symbol="LTCBTC" --order_id=497
$ bnc spot all_orders --symbol="LTCBTC" --start_time=1617896183262
$ bnc spot all_orders --symbol="LTCBTC" --start_time=1617896183262 --end_time=1617896193262
$ bnc spot all_orders --symbol="LTCBTC" --limit=1

Single hyphen options

$ bnc spot all_orders -sy "LTCBTC"
$ bnc spot all_orders -sy "LTCBTC" -oid 497
$ bnc spot all_orders -sy "LTCBTC" -st 1617896183262
$ bnc spot all_orders -sy "LTCBTC" -st 1617896183262 -et 1617896193262
$ bnc spot all_orders -sy "LTCBTC" -l 1

Get TAKE_PROFIT_LIMIT orders.

$ bnc spot all_orders --symbol="LTCBTC" --query="[?type=='TAKE_PROFIT_LIMIT']"

Get all orders except CANCELED and EXPIRED.

$ bnc spot all_orders --symbol="LTCBTC" --query="[?status!='CANCELED' && status != 'EXPIRED']"
$ bnc spot all_orders --symbol="LTCBTC" --query="[?status!='CANCELED' && status != 'EXPIRED']" --limit=2

New OCO Order

Send in a new OCO order

Weight:

  • 1

Other Info:

  • Price Restrictions:
    • SELL: Limit Price > Last Price > Stop Price
    • BUY: Limit Price < Last Price < Stop Price
  • Quantity Restrictions:
    • Both legs must have the same quantity
    • ICEBERG quantities however do not have to be the same.
  • Order Rate Limit
    • OCO counts as 2 orders against the order rate limit.

Binance CLI Command

bnc spot new_oco_order [options]

Options

  • -sy or --symbol
  • -lcoid or --list_client_order_id
  • -si or --side
  • -q or --quantity
  • -limcoid or --limit_client_order_id
  • -p or --price
  • -liq or --limit_iceberg_qty
  • -scoid or --stop_client_order_id
  • -sp or --stop_price
  • -slp or --stop_limit_price
  • -siq or --stop_iceberg_qty
  • -sltif or --stop_limit_time_in_force
  • -nort or --new_order_resp_type
  • -rw or --recv_window

🚨 Required options

-sy --symbol
-si --side
-q --quantity
-p --price
-sp --stop_price

Examples

At this date [April 2021], Binance doesn't support STOP_LOSS orders for any of the symbols, so if you only use all required options for this command, you are going to receive the following message:

$ bnc spot new_oco_order --symbol="LTCBTC" --side="SELL" --quantity=1 --price=0.0036 --stop_price=0.0020

> Stop loss orders are not supported for this symbol.

The solution is to create a STOP_LOSS_LIMIT order using optional options.

Double hyphen options

$ bnc spot new_oco_order --symbol="LTCBTC" --side="SELL" --quantity=1 --price=0.015 --stop_price=0.008 --stop_limit_price=0.0075 --stop_limit_time_in_force="GTC"

$ bnc spot new_oco_order --symbol="LTCBTC" --side="SELL" --quantity=1 --price=0.015 --stop_price=0.008 \
    --stop_limit_price=0.0075 --stop_limit_time_in_force="GTC" \
    --list_client_order_id="custom1_list_client_order_id" \
    --limit_client_order_id="custom_limit_client_order_id" \
    --stop_client_order_id="custom_stop_client_order_id"
    
$ bnc spot new_oco_order --symbol="LTCBTC" --side="SELL" --quantity=1 --price=0.015 --stop_price=0.008 --stop_limit_price=0.0075 --stop_limit_time_in_force="GTC" --limit_iceberg_qty=0.5
$ bnc spot new_oco_order --symbol="LTCBTC" --side="SELL" --quantity=1 --price=0.015 --stop_price=0.008 --stop_limit_price=0.0075 --stop_limit_time_in_force="GTC" --stop_iceberg_qty=0.5
$ bnc spot new_oco_order --symbol="LTCBTC" --side="SELL" --quantity=1 --price=0.015 --stop_price=0.008 --stop_limit_price=0.0075 --stop_limit_time_in_force="GTC" --new_order_resp_type="ACK"

Single hyphen options

$ bnc spot new_oco_order -sy "LTCBTC" -si "SELL" -q 1 -p 0.015 -sp 0.008 -slp 0.0075 -sltif "GTC"

$ bnc spot new_oco_order -sy "LTCBTC" -si "SELL" -q 1 -p 0.015 -sp 0.008 -slp 0.0075 -sltif "GTC" \
    -lcoid "custom1_list_client_order_id" \
    -limcoid "custom_limit_client_order_id" \
    -scoid "custom_stop_client_order_id"
    
$ bnc spot new_oco_order -sy "LTCBTC" -si "SELL" -q 1 -p 0.015 -sp 0.008 -slp 0.0075 -sltif "GTC" -liq 0.5
$ bnc spot new_oco_order -sy "LTCBTC" -si "SELL" -q 1 -p 0.015 -sp 0.008 -slp 0.0075 -sltif "GTC" -siq 0.5
$ bnc spot new_oco_order -sy "LTCBTC" -si "SELL" -q 1 -p 0.015 -sp 0.008 -slp 0.0075 -sltif "GTC" -nort "ACK"

Cancel OCO Order

Cancel an entire Order List.

Weight:

  • 1

Additional notes:

  • Canceling an individual leg will cancel the entire OCO

Binance CLI Command

bnc spot cancel_oco_order [options]

Options

  • -sy or --symbol
  • -olid or --order_list_id
  • -lcoid or --list_client_order_id
  • -ncoid or --new_client_order_id
  • -rw or --recv_window

🚨 Required options

-sy --symbol
-olid --order_list_id or -lcoid --list_client_order_id

Examples

Double hyphen options

$ bnc spot cancel_oco_order --symbol="LTCBTC" --order_list_id=578
$ bnc spot cancel_oco_order --symbol="LTCBTC" --list_client_order_id="QEOBf6o3NyCf2w6jfj1mrP"
$ bnc spot cancel_oco_order --symbol="LTCBTC" --order_list_id=578 --new_client_order_id="tKTpu9lI1BjNq8vmnNjtsM"

Single hyphen options

$ bnc spot cancel_oco_order -sy "LTCBTC" -olid 578
$ bnc spot cancel_oco_order -sy "LTCBTC" -lcoid "QEOBf6o3NyCf2w6jfj1mrP"
$ bnc spot cancel_oco_order -sy "LTCBTC" -olid 578 -ncoid "tKTpu9lI1BjNq8vmnNjtsM"

Query OCO Order

Retrieves a specific OCO based on provided optional parameters

Weight:

  • 1

Binance CLI Command

bnc spot oco_order [options]

Options

  • -olid or --order_list_id
  • -lcoid or --list_client_order_id
  • -rw or --recv_window

🚨 Required options

-olid --order_list_id or -lcoid --list_client_order_id

Examples

Double hyphen options

$ bnc spot oco_order --order_list_id=592 
$ bnc spot oco_order --list_client_order_id="ykprg1hXtgmNjHVcZ3YKNM"
$ bnc spot oco_order --order_list_id=592 --list_client_order_id="ykprg1hXtgmNjHVcZ3YKNM"

Single hyphen options

$ bnc spot oco_order -olid 592 
$ bnc spot oco_order -lcoid "ykprg1hXtgmNjHVcZ3YKNM"
$ bnc spot oco_order -olid 592 -lcoid "ykprg1hXtgmNjHVcZ3YKNM"

Query all OCO Order

Retrieves all OCO based on provided optional parameters

Weight:

  • 10

Binance CLI Command

bnc spot all_oco_orders [options]

Options

  • -fid or --from_id
  • -st or --start_time
  • -et or --end_time
  • -l or --limit
  • -rw or --recv_window

Examples

$ bnc spot all_oco_orders

Double hyphen options

$ bnc spot all_oco_orders --from_id=590
$ bnc spot all_oco_orders --start_time=1618359398560 --end_time=1618359398567
$ bnc spot all_oco_orders --limit=2

Single hyphen options

$ bnc spot all_oco_orders -fid 590
$ bnc spot all_oco_orders -st 1618359398560 -et 1618359398567
$ bnc spot all_oco_orders -l 2

Query open OCO Orders

Weight:

  • 2

Binance CLI Command

bnc spot open_oco_orders [options]

Options

  • -rw or --recv_window

Examples

$ bnc spot open_oco_orders

Account Information

https://binance-docs.github.io/apidocs/spot/en/#account-information-user_data

Get current account information.

Weight:

  • 5

Binance CLI Command

bnc spot account_info [options]

Options

  • -q or --query

Examples

Without options

$ bnc spot account_info

Free balances greater than 0

$ bnc spot account_info --query='balances[?to_number(free)>`0`] | { balances: @ }'

Locked balances greater than 0

$ bnc spot account_info --query='balances[?to_number(locked)>`0`] | { balances: @ }'

Account trade list

Get trades for a specific account and symbol.

Weight:

  • 5

Notes:

If fromId is set, it will get id >= that fromId. Otherwise most recent trades are returned.

Binance CLI Command

bnc spot my_trades [options]

Options

  • -sy or --symbol
  • -st or --start_time
  • -et or --end_time
  • -fid or --from_id
  • -l or --limit
  • -rw or --recv_window
  • --query

🚨 Required options

-sy --symbol

Examples

Double hyphen options

$ bnc spot my_trades --symbol="LTCBTC"
$ bnc spot my_trades --symbol="LTCBTC" --start_time=1617896183262
$ bnc spot my_trades --symbol="LTCBTC" --start_time=1617896183262 --end_time=1617896193262
$ bnc spot my_trades --symbol="LTCBTC" --from_id=497
$ bnc spot my_trades --symbol="LTCBTC" --limit=1

Single hyphen options

$ bnc spot my_trades -sy "LTCBTC"
$ bnc spot my_trades -sy "LTCBTC" -st 1617896183262
$ bnc spot my_trades -sy "LTCBTC" -st 1617896183262 -et 1617896193262
$ bnc spot my_trades -sy "LTCBTC" -fid 497
$ bnc spot my_trades -sy "LTCBTC" -l 1

Trades with price less or equal than certain value.

$ bnc spot my_trades --symbol="LTCBTC" --query='[?to_number(price)<=`0.0030`]'
Clone this wiki locally