Skip to main content
Complex orders are parent orders that Molecule manages on your behalf, spawning and cancelling child orders automatically according to the order type’s logic. Use them when you need execution strategies beyond a single resting or market order — for example, splitting a large position into hidden slices (ICEBERG), pegging to the best available price (PEG), or triggering on a price condition (STOP, TP_SL). Call client.complex_orders.create() or the top-level shortcut client.create_complex_order() to submit a complex order to POST /v1/complex-orders.

Method

Endpoint: POST /v1/complex-orders

Parameters

"ICEBERG" | "PEG" | "STOP" | "TP_SL" | "SMART_ROUTE"
required
The complex order type that determines execution behaviour.
string
required
The subaccount from which to manage child orders.
integer
Venue-specific instrument ID. Required when using DIRECT routing.
integer
Cross-venue asset ID. Required when using BEST_PRICE or SPLIT routing.
"BUY" | "SELL"
Direction of child orders. Required for most complex order types.
"YES" | "NO"
Binary outcome leg. Required for binary markets where the instrument tracks a specific resolution outcome.
string
Total quantity as a decimal string. For ICEBERG, this is the full hidden quantity.
string
Reference price as a decimal string. Interpretation varies by type: limit price for STOP child orders, initial peg price for PEG, and so on.
object
Type-specific configuration parameters. The fields accepted here depend on type.
object
Routing configuration object.
string
Idempotency key for this complex order. Unlike simple orders (which use client_order_id), complex orders use this dedicated field. Retrying with the same key and body is safe; retrying with the same key and a different body raises ConflictError.

Examples

ICEBERG order

An ICEBERG order hides the full quantity and exposes only a slice_qty at a time. As each slice fills, a new child order is automatically placed until the total quantity is exhausted.

STOP order

A STOP order watches the market and submits a child order when the price crosses trigger_price.

TP_SL order

A TP_SL order places a take-profit and stop-loss simultaneously, managing both legs until one triggers and the other is cancelled.

Managing complex orders

Use client.complex_orders to retrieve, list, and cancel complex orders:
Cancelling a parent complex order immediately cancels all child orders it has spawned. There is no partial-cancel option at the parent level.

Idempotency

Complex orders use the idempotency_key field — not client_order_id. Sending the same idempotency_key with the same body is safe to retry and returns the original response. Sending the same key with a different body raises ConflictError with error code idempotency_conflict.

Error reference