BinanceTrading: Spot Order Management
BinanceTrading: Spot Order Management
Details
Provides methods for placing, cancelling, and querying spot orders on Binance. Inherits from BinanceBase.
Purpose and Scope
Order Placement: Place limit/market orders with full parameter control.
Order Testing: Validate order parameters without execution via the test endpoint.
Order Cancellation: Cancel by order ID, client order ID, or all open orders on a symbol.
Order Queries: Retrieve order details, open orders, and all orders.
Endpoints Covered
| Method | Endpoint | HTTP |
| add_order | POST /api/v3/order | POST |
| add_order_test | POST /api/v3/order/test | POST |
| cancel_order | DELETE /api/v3/order | DELETE |
| cancel_all_orders | DELETE /api/v3/openOrders | DELETE |
| get_order | GET /api/v3/order | GET |
| get_open_orders | GET /api/v3/openOrders | GET |
| get_all_orders | GET /api/v3/allOrders | GET |
Order Types
"LIMIT": requiresprice,quantity,timeInForce."MARKET": requires eitherquantityorquoteOrderQty."STOP_LOSS","STOP_LOSS_LIMIT","TAKE_PROFIT","TAKE_PROFIT_LIMIT": conditional."LIMIT_MAKER": like LIMIT but rejected if it would immediately match.
Time-In-Force Options
"GTC"(Good Till Cancelled): Remains until filled or cancelled. Default."IOC"(Immediate Or Cancel): Fill immediately or cancel remainder."FOK"(Fill Or Kill): Fill entirely or cancel completely.
Super class
binance::BinanceBase -> BinanceTrading
Methods
Inherited methods
Method add_order()
Place an Order
Places a new spot order on Binance.
Official Documentation
Binance New Order Verified: 2026-03-10
Automated Trading Usage
Limit Orders: Set specific entry/exit prices for strategy execution.
Market Orders: Execute immediately at best available price.
Response Type: Use
newOrderRespType = "FULL"to get fill details in the response.
JSON Response (FULL)
{
"symbol": "BTCUSDT",
"orderId": 28,
"orderListId": -1,
"clientOrderId": "6gCrw2kRUAF9CvJDGP16IP",
"transactTime": 1507725176595,
"price": "50000.00000000",
"origQty": "0.00010000",
"executedQty": "0.00000000",
"cummulativeQuoteQty": "0.00000000",
"status": "NEW",
"timeInForce": "GTC",
"type": "LIMIT",
"side": "BUY",
"fills": []
}Usage
BinanceTrading$add_order(
type,
symbol,
side,
quantity = NULL,
quoteOrderQty = NULL,
price = NULL,
timeInForce = NULL,
newClientOrderId = NULL,
stopPrice = NULL,
icebergQty = NULL,
newOrderRespType = NULL,
selfTradePreventionMode = NULL,
recvWindow = NULL
)Arguments
typeCharacter;
"LIMIT"or"MARKET"(and stop/take-profit variants).symbolCharacter; trading pair (e.g.,
"BTCUSDT").sideCharacter;
"BUY"or"SELL".quantityNumeric or NULL; base asset quantity.
quoteOrderQtyNumeric or NULL; quote asset quantity (market orders only).
priceNumeric or NULL; price for limit orders.
timeInForceCharacter or NULL;
"GTC","IOC","FOK".newClientOrderIdCharacter or NULL; unique client order ID.
stopPriceNumeric or NULL; trigger price for stop orders.
icebergQtyNumeric or NULL; iceberg quantity.
newOrderRespTypeCharacter or NULL;
"ACK","RESULT", or"FULL".selfTradePreventionModeCharacter or NULL.
recvWindowInteger or NULL; max 60000.
Returns
data.table with one row and the following columns:
symbol(character): Trading pair (e.g.,"BTCUSDT").order_id(integer): Unique order identifier assigned by Binance.order_list_id(integer): OCO order list ID;-1if not an OCO.client_order_id(character): Client-assigned order ID.price(character): Order price.orig_qty(character): Original requested quantity.executed_qty(character): Quantity filled so far.cummulative_quote_qty(character): Cumulative quote asset transacted.status(character): Order status ("NEW","FILLED","CANCELED", etc.).time_in_force(character): Time-in-force policy ("GTC","IOC","FOK").type(character): Order type ("LIMIT","MARKET", etc.).side(character):"BUY"or"SELL".working_time(numeric): Timestamp when the order started working.self_trade_prevention_mode(character): STP mode applied.transact_time(POSIXct): Transaction time converted fromtransactTime.fill_price(character): Fill execution price (one row per fill whennewOrderRespType = "FULL").fill_qty(character): Fill quantity.fill_commission(character): Commission charged for this fill.fill_commission_asset(character): Asset used for commission (e.g.,"BNB").
When the order has multiple fills, parent order fields are repeated on each row. When there are no fills, a single row is returned without fill columns.
Method add_order_test()
Test Order Placement
Simulates placing an order without execution. Validates all parameters
and authentication exactly as add_order(), but no order is actually created.
Returns {} on success.
Official Documentation
Binance Test New Order Verified: 2026-03-10
Automated Trading Usage
Parameter Validation: Verify order parameters are correct before live submission.
Auth Testing: Confirm API credentials work for order placement.
Integration Testing: Test your trading pipeline end-to-end without risk.
Usage
BinanceTrading$add_order_test(
type,
symbol,
side,
quantity = NULL,
quoteOrderQty = NULL,
price = NULL,
timeInForce = NULL,
newClientOrderId = NULL,
stopPrice = NULL,
icebergQty = NULL,
newOrderRespType = NULL,
selfTradePreventionMode = NULL,
recvWindow = NULL
)Arguments
typeCharacter;
"LIMIT"or"MARKET"(and stop/take-profit variants).symbolCharacter; trading pair (e.g.,
"BTCUSDT").sideCharacter;
"BUY"or"SELL".quantityNumeric or NULL; base asset quantity.
quoteOrderQtyNumeric or NULL; quote asset quantity (market orders only).
priceNumeric or NULL; price for limit orders.
timeInForceCharacter or NULL;
"GTC","IOC","FOK".newClientOrderIdCharacter or NULL; unique client order ID.
stopPriceNumeric or NULL; trigger price for stop orders.
icebergQtyNumeric or NULL; iceberg quantity.
newOrderRespTypeCharacter or NULL;
"ACK","RESULT", or"FULL".selfTradePreventionModeCharacter or NULL.
recvWindowInteger or NULL; max 60000.
Method cancel_order()
Cancel an Order
Cancels an active order by order ID or client order ID.
Official Documentation
Binance Cancel Order Verified: 2026-03-10
JSON Response
{
"symbol": "BTCUSDT",
"origClientOrderId": "msXkySR3u5uYwpvRMFsi3u",
"orderId": 4293153,
"orderListId": -1,
"clientOrderId": "6gCrw2kRUAF9CvJDGP16IP",
"transactTime": 1507725176595,
"price": "50000.00000000",
"origQty": "0.00010000",
"executedQty": "0.00000000",
"cummulativeQuoteQty": "0.00000000",
"status": "CANCELED",
"timeInForce": "GTC",
"type": "LIMIT",
"side": "BUY",
"selfTradePreventionMode": "NONE"
}Usage
BinanceTrading$cancel_order(
symbol,
orderId = NULL,
origClientOrderId = NULL,
recvWindow = NULL
)Arguments
symbolCharacter; trading pair (e.g.,
"BTCUSDT").orderIdInteger or NULL; the order ID to cancel.
origClientOrderIdCharacter or NULL; the client order ID to cancel.
recvWindowInteger or NULL; max 60000.
Returns
data.table with one row and the following columns:
symbol(character): Trading pair.orig_client_order_id(character): Original client order ID.order_id(integer): Unique order identifier.order_list_id(integer): OCO order list ID;-1if not an OCO.client_order_id(character): New client order ID after cancellation.price(character): Order price.orig_qty(character): Original requested quantity.executed_qty(character): Quantity filled before cancellation.cummulative_quote_qty(character): Cumulative quote asset transacted.status(character): Order status (typically"CANCELED").time_in_force(character): Time-in-force policy.type(character): Order type.side(character):"BUY"or"SELL".self_trade_prevention_mode(character): STP mode applied.transact_time(POSIXct): Cancellation time converted fromtransactTime.
Method cancel_all_orders()
Cancel All Open Orders on a Symbol
Cancels all active orders on a trading pair.
Official Documentation
Binance Cancel All Open Orders Verified: 2026-03-10
JSON Response
[
{
"symbol": "BTCUSDT",
"origClientOrderId": "E6APeyTJvkMvLMYMqu1KQ4",
"orderId": 11,
"orderListId": -1,
"clientOrderId": "pXLV6Hz6mprAcVYpVMTGgx",
"transactTime": 1684804350068,
"price": "50000.00000000",
"origQty": "0.00010000",
"executedQty": "0.00000000",
"cummulativeQuoteQty": "0.00000000",
"status": "CANCELED",
"timeInForce": "GTC",
"type": "LIMIT",
"side": "BUY",
"selfTradePreventionMode": "NONE"
},
{
"symbol": "BTCUSDT",
"origClientOrderId": "A3EF2HCwxgZPFMrfwbgrhv",
"orderId": 13,
"orderListId": -1,
"clientOrderId": "pXLV6Hz6mprAcVYpVMTGgx",
"transactTime": 1684804350068,
"price": "48000.00000000",
"origQty": "0.00020000",
"executedQty": "0.00000000",
"cummulativeQuoteQty": "0.00000000",
"status": "CANCELED",
"timeInForce": "GTC",
"type": "LIMIT",
"side": "BUY",
"selfTradePreventionMode": "NONE"
}
]Returns
data.table (or promise<data.table> if async = TRUE).
When orders are cancelled, one row per order with columns:
symbol(character): Trading pair.orig_client_order_id(character): Original client order ID.order_id(integer): Unique order identifier.order_list_id(integer): OCO order list ID;-1if not an OCO.client_order_id(character): New client order ID after cancellation.price(character): Order price.orig_qty(character): Original requested quantity.executed_qty(character): Quantity filled before cancellation.cummulative_quote_qty(character): Cumulative quote asset transacted.status(character): Order status (typically"CANCELED").time_in_force(character): Time-in-force policy.type(character): Order type.side(character):"BUY"or"SELL".self_trade_prevention_mode(character): STP mode applied.transact_time(POSIXct): Cancellation time.
When no open orders exist, a single confirmation row with columns:
symbol(character): The requested trading pair.status(character):"cancelled".
Method get_order()
Query Order
Retrieves details for a specific order by order ID or client order ID.
Official Documentation
Binance Query Order Verified: 2026-03-10
JSON Response
{
"symbol": "BTCUSDT",
"orderId": 4293153,
"orderListId": -1,
"clientOrderId": "6gCrw2kRUAF9CvJDGP16IP",
"price": "50000.00000000",
"origQty": "0.00010000",
"executedQty": "0.00010000",
"cummulativeQuoteQty": "5.00000000",
"status": "FILLED",
"timeInForce": "GTC",
"type": "LIMIT",
"side": "BUY",
"stopPrice": "0.00000000",
"icebergQty": "0.00000000",
"time": 1507725176595,
"updateTime": 1507725176595,
"isWorking": true,
"workingTime": 1507725176595,
"origQuoteOrderQty": "0.00000000",
"selfTradePreventionMode": "NONE"
}Usage
BinanceTrading$get_order(
symbol,
orderId = NULL,
origClientOrderId = NULL,
recvWindow = NULL
)Arguments
symbolCharacter; trading pair (e.g.,
"BTCUSDT").orderIdInteger or NULL; the order ID.
origClientOrderIdCharacter or NULL; the client order ID.
recvWindowInteger or NULL; max 60000.
Returns
data.table with one row and the following columns:
symbol(character): Trading pair.order_id(integer): Unique order identifier.order_list_id(integer): OCO order list ID;-1if not an OCO.client_order_id(character): Client-assigned order ID.price(character): Order price.orig_qty(character): Original requested quantity.executed_qty(character): Quantity filled so far.cummulative_quote_qty(character): Cumulative quote asset transacted.status(character): Order status ("NEW","FILLED","CANCELED", etc.).time_in_force(character): Time-in-force policy.type(character): Order type.side(character):"BUY"or"SELL".stop_price(character): Trigger price for stop orders.iceberg_qty(character): Iceberg quantity.is_working(logical): Whether the order is on the order book.orig_quote_order_qty(character): Original quote order quantity.working_time(numeric): Timestamp when the order started working.self_trade_prevention_mode(character): STP mode applied.time(POSIXct): Order creation time converted fromtime.update_time(POSIXct): Last update time converted fromupdateTime.
Method get_open_orders()
Get Open Orders
Retrieves all currently open orders, optionally filtered by symbol.
Official Documentation
Binance Current Open Orders Verified: 2026-03-10
JSON Response
[
{
"symbol": "BTCUSDT",
"orderId": 4293153,
"orderListId": -1,
"clientOrderId": "6gCrw2kRUAF9CvJDGP16IP",
"price": "50000.00000000",
"origQty": "0.00010000",
"executedQty": "0.00000000",
"cummulativeQuoteQty": "0.00000000",
"status": "NEW",
"timeInForce": "GTC",
"type": "LIMIT",
"side": "BUY",
"stopPrice": "0.00000000",
"icebergQty": "0.00000000",
"time": 1507725176595,
"updateTime": 1507725176595,
"isWorking": true,
"workingTime": 1507725176595,
"origQuoteOrderQty": "0.00000000",
"selfTradePreventionMode": "NONE"
}
]Arguments
symbolCharacter or NULL; trading pair (e.g.,
"BTCUSDT"). If NULL, returns open orders for all symbols (weight 80).recvWindowInteger or NULL; max 60000.
Returns
data.table with one row per open order and the following columns:
symbol(character): Trading pair.order_id(integer): Unique order identifier.order_list_id(integer): OCO order list ID;-1if not an OCO.client_order_id(character): Client-assigned order ID.price(character): Order price.orig_qty(character): Original requested quantity.executed_qty(character): Quantity filled so far.cummulative_quote_qty(character): Cumulative quote asset transacted.status(character): Order status (typically"NEW"or"PARTIALLY_FILLED").time_in_force(character): Time-in-force policy.type(character): Order type.side(character):"BUY"or"SELL".stop_price(character): Trigger price for stop orders.iceberg_qty(character): Iceberg quantity.is_working(logical): Whether the order is on the order book.orig_quote_order_qty(character): Original quote order quantity.working_time(numeric): Timestamp when the order started working.self_trade_prevention_mode(character): STP mode applied.time(POSIXct): Order creation time converted fromtime.update_time(POSIXct): Last update time converted fromupdateTime.
Method get_all_orders()
Get All Orders
Retrieves all orders for a symbol (open, cancelled, filled).
If orderId is set, orders >= that ID are returned. Otherwise
the most recent orders are returned.
Official Documentation
Binance All Orders Verified: 2026-03-10
JSON Response
[
{
"symbol": "BTCUSDT",
"orderId": 4293153,
"orderListId": -1,
"clientOrderId": "6gCrw2kRUAF9CvJDGP16IP",
"price": "50000.00000000",
"origQty": "0.00010000",
"executedQty": "0.00010000",
"cummulativeQuoteQty": "5.00000000",
"status": "FILLED",
"timeInForce": "GTC",
"type": "LIMIT",
"side": "BUY",
"stopPrice": "0.00000000",
"icebergQty": "0.00000000",
"time": 1507725176595,
"updateTime": 1507725176595,
"isWorking": true,
"workingTime": 1507725176595,
"origQuoteOrderQty": "0.00000000",
"selfTradePreventionMode": "NONE"
},
{
"symbol": "BTCUSDT",
"orderId": 4293154,
"orderListId": -1,
"clientOrderId": "x]]C3kvs44T7fYqJ09VBfg",
"price": "0.00000000",
"origQty": "0.00010000",
"executedQty": "0.00010000",
"cummulativeQuoteQty": "5.10230000",
"status": "FILLED",
"timeInForce": "GTC",
"type": "MARKET",
"side": "SELL",
"stopPrice": "0.00000000",
"icebergQty": "0.00000000",
"time": 1507725276595,
"updateTime": 1507725276595,
"isWorking": true,
"workingTime": 1507725276595,
"origQuoteOrderQty": "0.00000000",
"selfTradePreventionMode": "NONE"
}
]Usage
BinanceTrading$get_all_orders(
symbol,
orderId = NULL,
startTime = NULL,
endTime = NULL,
limit = NULL,
recvWindow = NULL
)Arguments
symbolCharacter; trading pair (e.g.,
"BTCUSDT").orderIdInteger or NULL; pagination cursor.
startTimeInteger or NULL; start timestamp in milliseconds.
endTimeInteger or NULL; end timestamp in milliseconds.
limitInteger or NULL; max results (default 500, max 1000).
recvWindowInteger or NULL; max 60000.
Returns
data.table with one row per order and the following columns:
symbol(character): Trading pair.order_id(integer): Unique order identifier.order_list_id(integer): OCO order list ID;-1if not an OCO.client_order_id(character): Client-assigned order ID.price(character): Order price.orig_qty(character): Original requested quantity.executed_qty(character): Quantity filled so far.cummulative_quote_qty(character): Cumulative quote asset transacted.status(character): Order status ("NEW","FILLED","CANCELED", etc.).time_in_force(character): Time-in-force policy.type(character): Order type.side(character):"BUY"or"SELL".stop_price(character): Trigger price for stop orders.iceberg_qty(character): Iceberg quantity.is_working(logical): Whether the order is on the order book.orig_quote_order_qty(character): Original quote order quantity.working_time(numeric): Timestamp when the order started working.self_trade_prevention_mode(character): STP mode applied.time(POSIXct): Order creation time converted fromtime.update_time(POSIXct): Last update time converted fromupdateTime.
Examples
if (FALSE) { # \dontrun{
# Synchronous
trading <- BinanceTrading$new()
order <- trading$add_order_test(type = "LIMIT", symbol = "BTCUSDT",
side = "BUY", price = 50000, quantity = 0.0001)
print(order)
# Asynchronous
trading_async <- BinanceTrading$new(async = TRUE)
main <- coro::async(function() {
order <- await(trading_async$add_order_test(
type = "LIMIT", symbol = "BTCUSDT", side = "BUY",
price = 50000, quantity = 0.0001
))
print(order)
})
main()
while (!later::loop_empty()) later::run_now()
} # }
## ------------------------------------------------
## Method `BinanceTrading$add_order`
## ------------------------------------------------
if (FALSE) { # \dontrun{
trading <- BinanceTrading$new()
order <- trading$add_order(
type = "LIMIT", symbol = "BTCUSDT", side = "BUY",
price = 50000, quantity = 0.0001
)
print(order)
} # }
## ------------------------------------------------
## Method `BinanceTrading$add_order_test`
## ------------------------------------------------
if (FALSE) { # \dontrun{
trading <- BinanceTrading$new()
test <- trading$add_order_test(
type = "LIMIT", symbol = "BTCUSDT", side = "BUY",
price = 50000, quantity = 0.0001
)
print(test)
} # }
## ------------------------------------------------
## Method `BinanceTrading$cancel_order`
## ------------------------------------------------
if (FALSE) { # \dontrun{
trading <- BinanceTrading$new()
cancelled <- trading$cancel_order("BTCUSDT", orderId = 12345)
print(cancelled)
} # }
## ------------------------------------------------
## Method `BinanceTrading$cancel_all_orders`
## ------------------------------------------------
if (FALSE) { # \dontrun{
trading <- BinanceTrading$new()
cancelled <- trading$cancel_all_orders("BTCUSDT")
print(cancelled)
} # }
## ------------------------------------------------
## Method `BinanceTrading$get_order`
## ------------------------------------------------
if (FALSE) { # \dontrun{
trading <- BinanceTrading$new()
order <- trading$get_order("BTCUSDT", orderId = 12345)
print(order)
} # }
## ------------------------------------------------
## Method `BinanceTrading$get_open_orders`
## ------------------------------------------------
if (FALSE) { # \dontrun{
trading <- BinanceTrading$new()
open <- trading$get_open_orders("BTCUSDT")
print(open)
} # }
## ------------------------------------------------
## Method `BinanceTrading$get_all_orders`
## ------------------------------------------------
if (FALSE) { # \dontrun{
trading <- BinanceTrading$new()
all <- trading$get_all_orders("BTCUSDT", limit = 50)
print(all[, .(order_id, side, price, status, time)])
} # }