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

ParameterOptions
TypeLIMIT - at the given price or better. MARKET - immediately at the best book prices; the unfilled remainder is cancelled.
Time in forceGTC - 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-blockThe 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

MessageWhat it does
MsgPlaceOrderPlaces an order
MsgCancelOrderCancels an order by its number
MsgReplaceOrderCancels an order and places a new one in a single message
MsgBatchPlaceOrdersPlaces up to 50 orders. If any one fails validation, none is placed
MsgBatchCancelOrdersCancels 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:

ValueWhat happened
restingThe order rests in the book, possibly partly filled
filledFilled in full
ioc_remainder_cancelledIOC: the remainder was cancelled
fok_insufficient_liquidityFOK: not enough liquidity; the order was cancelled
market_remainder_cancelledMARKET: the remainder was cancelled
post_only_would_crossPost-only cancelled because it would have filled immediately
resting_rejectedThe order could not rest in the book and was cancelled
no_liquidityA market or IOC order found no counterparty
settlement_failedThe order's trades failed settlement
counterparty_settlement_failedSettlement failed on the counterparty's side
not_in_batchThe order did not reach its block's matching
tx_failedThe 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.