Orders
This page covers the types, parameters and rules shared by all orders. Short-term, conditional and algorithmic orders have their own pages.
Type and duration
| Parameter | Options |
|---|---|
| Type | LIMIT - at the given price or better. MARKET - immediately at the best book prices; the unfilled remainder is cancelled. |
| Time in force | GTC - rests in the book until filled or cancelled. IOC - fills immediately as much as it can; the remainder is cancelled. FOK - fills immediately in full or is cancelled. |
| Good-til-block | The block after which the order expires. 0 means no expiry. |
Flags
- Post-only. The order only adds liquidity: if it would fill immediately, it is cancelled. Works only for LIMIT with GTC.
- Reduce-only. The order only reduces a position and reserves no margin. If it is larger than the position, the quantity is trimmed to the position size.
- A reduce-only order that closes the whole position may be smaller than the minimum order size.
- For GTC this works only if the subaccount has no other reduce-only orders in this market.
Wide orders
An opening order more than 20% away from the oracle price is accepted only as post-only. Beyond 50% the order is not accepted at all.
Order number
client_id is your order number. While the order is active, the number must be unique within the subaccount and market. Once the order is filled or cancelled, the number can be reused. The network also assigns each order its own key that identifies it uniquely.
Managing orders
| Message | What it does |
|---|---|
MsgPlaceOrder | Places an order |
MsgCancelOrder | Cancels an order by its number |
MsgReplaceOrder | Cancels an order and places a new one in a single message |
MsgBatchPlaceOrders | Places up to 50 orders. If any one fails validation, none is placed |
MsgBatchCancelOrders | Cancels up to 50 orders |
Statuses and placement result
Order statuses: OPEN, PARTIALLY_FILLED, FILLED, CANCELLED, EXPIRED, REJECTED.
The placement response holds the status, the filled quantity and the reason in the placement_result field:
| Value | What happened |
|---|---|
resting | The order rests in the book, possibly partly filled |
filled | Filled in full |
ioc_remainder_cancelled | IOC: the remainder was cancelled |
fok_insufficient_liquidity | FOK: not enough liquidity; the order was cancelled |
market_remainder_cancelled | MARKET: the remainder was cancelled |
post_only_would_cross | Post-only cancelled because it would have filled immediately |
resting_rejected | The order could not rest in the book and was cancelled |
no_liquidity | A market or IOC order found no counterparty |
settlement_failed | The order's trades failed settlement |
counterparty_settlement_failed | Settlement failed on the counterparty's side |
not_in_batch | The order did not reach its block's matching |
tx_failed | The order filled in matching, but its transaction then failed; the fill stands |
Limits on the number and size of orders are in On-chain matching.