Trading
Tools to place, edit, and cancel orders and manage brackets, leverage, margin, and positions. Registered with any API key; a Trading key is what lets them execute.
These tools place and change real orders and positions. They register whenever credentials are present, alongside the account tools. Whether a call executes is decided by your key: Delta accepts what a Trading key sends and rejects what a Read Data key sends (see Authentication).
These tools move real money
There is no rehearsal step. A call with a Trading key goes to Delta as sent, with
no size cap and no confirmation prompt, sized in contracts rather than coins.
Prices are sent exactly as typed, and Delta moves an off-tick price onto the
product's tick. Mutations are never auto-retried, because re-sending an order
can place it twice. Rehearse on india_testnet.
What the server still checks
Three request-shape checks remain, and they fail before anything is sent:
- Exactly one of
product_id/product_symbolon every tool that names a product. - Exactly one of
id/client_order_idoncancel_order. - At least one leg on
place_bracket_order.
Everything else is Delta's answer, returned as given.
place_order
Place a single limit, market, or stop order. Supports attached brackets.
Auth: API key; a Trading key to execute
| Param | Type | Required | Notes |
|---|---|---|---|
size | int | yes | order size in contracts (positive) |
side | string | yes | buy or sell |
order_type | string | yes | limit_order or market_order |
product_id | int | no | pass exactly one of product_id / product_symbol |
product_symbol | string | no | e.g. BTCUSD |
limit_price | string | no | required for limit_order; ignored on market_order |
stop_order_type | string | no | stop_loss_order or take_profit_order |
stop_price | string | no | trigger price for stop orders |
trail_amount | string | no | trailing-stop amount |
stop_trigger_method | string | no | mark_price, last_traded_price, spot_price |
time_in_force | string | no | gtc or ioc |
post_only | bool | no | reject if it would take liquidity |
reduce_only | bool | no | only reduce an existing position |
client_order_id | string | no | your id, max 32 chars |
bracket_stop_loss_price | string | no | attached-bracket SL trigger |
bracket_stop_loss_limit_price | string | no | attached-bracket SL limit |
bracket_take_profit_price | string | no | attached-bracket TP trigger |
bracket_take_profit_limit_price | string | no | attached-bracket TP limit |
bracket_trail_amount | string | no | attached-bracket trailing amount |
bracket_stop_trigger_method | string | no | trigger method for the bracket |
Passing the bracket_* params here creates an entry-order bracket whose id
(the returned order id) is what edit_bracket_order later expects. (That differs
from place_bracket_order, which attaches a bracket to an open position.)
Prices are sent exactly as given. Delta moves an off-tick price onto the
product's tick, so the limit_price in the response is the one that applies.
Place a GTC limit buy of 5 ETHUSD at 3400 with a take-profit at 3600 and a
stop-loss at 3250.edit_order
Edit an open order's size or price.
Auth: API key; a Trading key to execute
| Param | Type | Required | Notes |
|---|---|---|---|
id | int | yes | order id to edit |
size | int | yes | total size after the edit |
product_id | int | no | pass exactly one of product_id / product_symbol |
product_symbol | string | no | e.g. BTCUSD |
limit_price | string | no | new limit price |
stop_price | string | no | new stop trigger price |
trail_amount | string | no | new trailing-stop amount |
post_only | bool | no | reject if it would take liquidity |
Prices are sent exactly as given. Delta moves an off-tick price onto the product's
tick, so the limit_price in the response is the one that applies.
Move my open BTCUSD order 123456789 to a limit price of 71500.cancel_order
Cancel a single order by id or client order id.
Auth: API key; a Trading key to execute
| Param | Type | Required | Notes |
|---|---|---|---|
product_id | int | yes | product the order belongs to |
id | int | no | order id to cancel |
client_order_id | string | no | your client order id |
Pass exactly one of id or client_order_id.
Cancel my open BTCUSD order 123456789.cancel_all_orders
Cancel open orders, optionally scoped by product or contract type.
Auth: API key; a Trading key to execute
| Param | Type | Required | Notes |
|---|---|---|---|
product_id | int | no | limit to one product |
contract_types | string[] | no | limit to contract types (ignored if product_id set) |
Limit orders, stop orders and reduce-only orders are all cancelled. There is no flag to exclude a kind.
With no filters this cancels everything
Called bare, this cancels every open order on the account. product_id and
contract_types are the only way to narrow it.
Cancel all my open orders on BTCUSD.place_batch_orders
Place several orders on one contract in a single request.
Auth: API key; a Trading key to execute
| Param | Type | Required | Notes |
|---|---|---|---|
orders | object[] | yes | each {size, side, order_type, limit_price?, time_in_force?, post_only?, client_order_id?}. Same contract. No IOC/stop. |
product_id | int | no | pass exactly one of product_id / product_symbol |
product_symbol | string | no | e.g. BTCUSD |
client_order_id must be unique within the batch. Delta's response is returned
as given, and nothing annotates it. When it comes back with fewer orders than you
sent, the missing ones were not accepted: compare the two lists before you resend
anything, because resending a leg that did go live places it twice.
Place a ladder of 5 BTCUSD limit buys: 2 contracts each at 70000, 69500, 69000,
68500, 68000.edit_batch_orders
Edit several orders on one contract in a single request.
Auth: API key; a Trading key to execute
| Param | Type | Required | Notes |
|---|---|---|---|
orders | object[] | yes | each {id, size, order_type, limit_price?, post_only?} |
product_id | int | no | pass exactly one of product_id / product_symbol |
product_symbol | string | no | e.g. BTCUSD |
Reprice all my open ETHUSD ladder orders down by 50.cancel_batch_orders
Cancel several orders on one contract in a single request.
Auth: API key; a Trading key to execute
| Param | Type | Required | Notes |
|---|---|---|---|
orders | object[] | yes | each {id} or {client_order_id} |
product_id | int | no | pass exactly one of product_id / product_symbol |
product_symbol | string | no | e.g. BTCUSD |
Cancel orders 111, 222, and 333 on BTCUSD in one request.place_bracket_order
Attach a take-profit / stop-loss bracket to an open position. Provide at least one leg.
Auth: API key; a Trading key to execute
| Param | Type | Required | Notes |
|---|---|---|---|
product_id | int | no | pass exactly one of product_id / product_symbol |
product_symbol | string | no | e.g. BTCUSD |
stop_loss_order | object | no | {order_type, stop_price, limit_price?, trail_amount?} |
take_profit_order | object | no | {order_type, stop_price, limit_price?} |
bracket_stop_trigger_method | string | no | mark_price, last_traded_price, spot_price |
These position-bracket legs are not editable via edit_bracket_order — cancel
and re-place to change them. (edit_bracket_order only edits entry-order brackets
created through place_order.)
On my open BTCUSD position, attach a stop-loss at 68000 and a take-profit at
75000.edit_bracket_order
Edit the bracket (TP/SL) params on an existing entry order.
Auth: API key; a Trading key to execute
| Param | Type | Required | Notes |
|---|---|---|---|
id | int | yes | entry-order id whose bracket to update |
product_id | int | no | pass exactly one of product_id / product_symbol |
product_symbol | string | no | e.g. BTCUSD |
bracket_stop_loss_price | string | no | stop-loss trigger price |
bracket_stop_loss_limit_price | string | no | stop-loss limit price |
bracket_take_profit_price | string | no | take-profit trigger price |
bracket_take_profit_limit_price | string | no | take-profit limit price |
bracket_trail_amount | string | no | trailing-stop amount |
bracket_stop_trigger_method | string | no | mark_price, last_traded_price, spot_price |
id is the entry-order id (an order created with bracket_* params via
place_order). It does not accept the leg ids of a position bracket from
place_bracket_order.
On entry order 123456789, raise the take-profit to 76000.set_product_leverage
Set order leverage for a product.
Auth: API key; a Trading key to execute
| Param | Type | Required | Notes |
|---|---|---|---|
product_id | int | yes | product to set leverage for |
leverage | string | yes | leverage multiplier, e.g. '10' |
Set my BTCUSD order leverage to 10x.adjust_position_margin
Add or remove isolated margin on a position.
Auth: API key; a Trading key to execute
| Param | Type | Required | Notes |
|---|---|---|---|
product_id | int | yes | product id of the position |
delta_margin | string | yes | margin to add (positive) or remove (negative), e.g. '5.0' |
Add 5 USDT of isolated margin to my BTCUSD position.close_all_positions
Close every open position on the account, both cross / portfolio-margined and isolated.
Auth: API key; a Trading key to execute
No parameters.
This closes your entire account
There is no narrower call. Both margin scopes are closed, and there is no flag
that limits it to a product or a scope. The server looks up your user_id
itself. To close less than everything, cancel and close by product instead.
Close every open position on my account.configure_auto_topup
Override auto top-up for a single position.
Auth: API key; a Trading key to execute
| Param | Type | Required | Notes |
|---|---|---|---|
product_id | int | yes | product id of the position |
auto_topup | bool | yes | enable or disable auto top-up for this position |
Turn on auto top-up for my BTCUSD position.