Overview
TheOrderClient handles order creation, EIP-712 signing, and order management. It supports Good-Till-Cancelled (GTC), Fill-And-Kill (FAK), and Fill-or-Kill (FOK) orders.
Prerequisites
Before placing orders, you need four components:The
OrderClient constructor automatically fetches your user profile data (userData) from the API. This is used to populate the ownerId field on submitted orders.Token Approvals
Before your first trade on a given venue, you must approve the exchange contracts to spend your tokens. This is a one-time on-chain setup per venue.- Standard CLOB
- NegRisk
For standard CLOB markets, approve USDC and Conditional Tokens to the exchange contract:
GTC Orders (Good-Till-Cancelled)
GTC orders remain on the orderbook until filled or explicitly cancelled. Specifyprice (in dollars) and size (number of shares):
Post-only GTC order
Usepost_only=True to ensure your order is never filled immediately as a taker. If the order would cross the spread (i.e., match against existing orders), it is rejected instead. This guarantees you always receive maker fees.
Self-Trade Prevention
Passstp_policy to control what happens when your incoming order would match your own resting order on the same token. It is a top-level request field — not part of the EIP-712 signed order — and applies to any order type. Omit it to keep the server default, cancel_maker.
The create-order response carries an
execution object with the outcome:
Self-trade prevention blocks same-profile matches on the same token only. Orders on a different token of the same profile are unaffected. The wire field is always
stpPolicy, regardless of the SDK.FAK Orders (Fill-And-Kill)
FAK orders use the sameprice and size inputs as GTC, but they only consume immediately available liquidity and cancel any unmatched remainder.
post_only is not supported for FAK orders.
FOK Orders (Fill-or-Kill)
FOK orders execute immediately and fully, or are rejected entirely. Instead ofprice and size, you specify maker_amount:
- FOK BUY
- FOK SELL
When buying,
maker_amount is the total USDC you want to spend. The exchange fills as many shares as possible at the best available price:Cancelling Orders
- Cancel a single order
- Cancel all orders on a market
Cancel a specific order by its ID:
Enums Reference
Side
OrderType
Error Handling
The SDK raisesAPIError for non-2xx responses. Always wrap order calls in try/except:
See Error Handling & Retry for details on
APIError fields and the @retry_on_errors decorator.