Flow
- Authenticate:
GET /nonce/{user_id}, sign the nonce value,POST /auth. - Discover the market on OMS:
GET /marketsorGET /market/{asset_id}for book decimals and fees. - Sign the action-specific object: order create signs
orderand replace signsrequest. Cancels are not signed. - Submit over REST or the
/controlWebSocket. - Treat the REST response as acceptance, not as a finalized fill. Confirm over the orders and trades streams or by refetching orders.
book_price_decimals = 2, 250000 means 2500.00. With book_quantity_decimals = 8, 125000000 means 1.25000000.
Raw REST
create-order.json contains the signed body from Signing. Replace:
timestamp_ns < max_ts; if max_ts is omitted, it uses server time:
DELETE /orders/cancel-all/{asset_id} to scope to one market. Use DELETE /orders/cancel-batch with order IDs for a selected subset; IDs not owned by the caller are ignored.
tpluspy
tpluspy takes prices and quantities asDecimal whole units and scales them by the market’s book decimals. Any other type, or a value that does not scale to a whole u64, raises OrderScaleError before anything is sent.
use_ws_control=True to OrderBookClient to send create, replace, and cancel over /control instead of REST. The control channel accepts v0 raw action wrappers or v1 envelopes with request_id.
Replace semantics
Replace preserves the order ID. The mutable fields are price, quantity, and trigger. Every replace signs the effective price, lifetime-total quantity (including fills), trigger state and both book decimals. Fill state of a partially filled enabled order is preserved. A replace with an oldertimestamp_ns than a newer applied replace is rejected by the orderbook.
REST replace and REST cancel first look up the current OMS order and return not found if absent. On REST and /control, OMS looks up the order and checks the market decimals, resulting trigger and remaining size before forwarding a replace. A cancel that reaches the fast queue before its create can reject the later create.
Sub-accounts, transfers, and close-all
There is no standalone “create sub-account” call. Transfer a balance from a trading account into an unusedtarget_index and include target_account_type.
Raw transfer:
Populate signature with the Ed25519 signature bytes over compact inner before sending.
0) into a trading account, make a Funding account transfer: name the token instead of an asset index, as "transfer_asset": "<32-byte hex token address>@<9-byte hex chain id>".
tpluspy-assisted transfer, using the SDK user signer and the raw request path:
/account/events/{user_id} and /inventory/user/{user_id} before sending a new nonce.
Clearing a position (POST /account/transfer/clear-position) settles the whole quote once the base leg is zero. It folds the remaining quote credits into spot USD, or repays quote liabilities from spot USD, and emits PositionCleared; if a quote liability remains, the spot USD balance must cover it. While a long is open, it moves only a quote profit to spot USD, keeps the base and emits PositionCleared. If a short has no quote leg, clearing repays its base liability using spot of the same asset, up to the smaller of the spot balance and the liability. Other open positions with no settled profit or repayable base are rejected with No settled PnL while the long is open or No settled PnL while the short is open.
GET /positions/close-all/{user_id}/{sub_account}returns close-order suggestions.- Sign each suggested order.
- Submit with
POST /orders/batch-create. - Watch fills, then call clear-position for each flattened asset.
- Re-run the preview after partial fills or price movement.