Skip to main content
The client.orders namespace lets you submit orders to any live venue, amend or cancel them individually or in bulk, poll for status updates, and retrieve your fill history. Routing decisions — whether to target a specific venue instrument or to let Molecule find the best available price — are controlled per order through the routing field.

Creating an Order

Submit a single order with client.orders.create() or the top-level shortcut client.create_order(). Both call POST /v1/orders.

Order parameters

string
required
The subaccount to trade from. All risk checks and fill attribution apply to this subaccount.
integer
Venue-specific instrument identifier. Required when routing.mode is DIRECT. Obtain this from client.markets.get() or client.markets.search().
integer
Cross-venue asset identifier. Required when routing.mode is BEST_PRICE or SPLIT.
"BUY" | "SELL"
required
Order direction.
"YES" | "NO"
Outcome side for binary markets. Specifies which contract you are buying or selling.
"LIMIT" | "MARKET"
required
Order type. LIMIT requires a price. MARKET fills at the best available price.
"GTC" | "IOC" | "FOK" | "GTD"
Time-in-force policy.
  • GTC — Good Till Cancelled. Rests on the book until filled or explicitly cancelled.
  • IOC — Immediate Or Cancel. Fills whatever is available immediately; cancels the remainder.
  • FOK — Fill Or Kill. Must fill in full immediately, or the entire order is cancelled.
  • GTD — Good Till Date. Rests until a specified expiry.
string
Limit price expressed as a decimal string (e.g., "0.62"). Required for LIMIT orders.
string
required
Order quantity expressed as a decimal string (e.g., "100").
object
Routing configuration object.
string
Your reference ID for this order. Sent as the Idempotency-Key header — use it to safely retry order submission. See Idempotency.

Routing Modes

Every order declares how Molecule should route it to execution venues.

DIRECT

Routes to a single venue-specific instrument. Requires instrument_id. Use this when you have a strong venue preference or are responding to a specific market condition on one venue.

BEST_PRICE

Finds the best available price across all live venues for the given generic_asset_id. Molecule selects the optimal venue at execution time.

SPLIT

Splits the order quantity across multiple live venues using generic_asset_id, improving fill probability for larger sizes.
DIRECT routing requires instrument_id. BEST_PRICE and SPLIT routing require generic_asset_id. Passing the wrong identifier for the routing mode results in a ValidationError.

Idempotency

The client_order_id field doubles as an idempotency key. The SDK sends it as an Idempotency-Key HTTP header on every POST /v1/orders call.
  • Same key, same body — safe to retry after a network timeout. The API returns the original order response without creating a duplicate.
  • Same key, different body — the API raises a ConflictError with error="idempotency_conflict".
Generate a fresh client_order_id for each logically distinct order. Reusing the same key with different parameters raises ConflictError and the order will not be submitted.

Order Lifecycle

Orders move through a defined sequence of states:
Fetch a single order by ID, or list all orders for a subaccount:
For real-time order updates without polling, subscribe to the WebSocket stream at /v1/ws/orders using client.iter_ws("/v1/ws/orders").

Amending an Order

Modify the price or quantity of a resting order with client.orders.amend(). Only open or partially filled orders can be amended.
Not all venues support in-flight amends. If the venue requires a cancel-replace, Molecule handles this transparently. Check the returned order object for the current state.

Cancelling Orders

Cancel a single order or all open orders for a subaccount.
cancel_all() cancels every open and partially filled order for the specified subaccount across all venues simultaneously. Use client.risk.kill_switch(enabled=True) to halt all activity at the account level.

Batch Orders

Submit multiple orders in a single request to reduce round trips and ensure consistent timing.
Each order in the batch is subject to the same validation and risk checks as individual orders. The response includes one entry per submitted order. A validation failure on one leg does not necessarily cancel the rest — inspect each entry’s status independently.

Fills

Retrieve the fill history for a subaccount. Fills represent confirmed executions and are the source of truth for realized P&L.
Fills are also available via client.portfolio.fills(), which calls the same /v1/fills endpoint. The client.orders.fills() shortcut is provided for convenience when working primarily in the orders namespace.