STXOrderService handles order placement, cancellation, and order history. STXTradeService handles fills (trades). Both services support real-time counterparts via WebSocket channels for latency-sensitive workflows.
Place an order
Order parameters
| Parameter | Notes |
|---|---|
price | Integer cents. 50 = 50¢. Ignored for market orders. |
quantity | Number of contracts. |
marketId | From STXMarketService.GetMarketInfosAsync. |
action | STXOrderAction.buy or STXOrderAction.sell. |
orderType | STXOrderType.limit or STXOrderType.market. |
clientOrderId | Your idempotency key. If the call retries, you won’t receive a duplicate fill. |
cancelOnDisconnect | When true, the exchange cancels this order if the WebSocket drops. Requires STXActiveOrdersChannel to be joined first. |
Cancel-on-disconnect
If you passcancelOnDisconnect: true without having joined STXActiveOrdersChannel, the call throws STXCancelOnDisconnectNotEnabledException. For a market-maker workflow, join the channel before placing any orders:
cancelOnDisconnect: false.
Batch orders
Placing multiple orders in one call reduces round-trips and is the preferred approach for market makers quoting several markets simultaneously:Cancel orders
CancelAllOrdersAsync returns every order it cancelled, which is useful for reconciling your local state after a strategy reset.
Query order history
Query trades (fills)
Each matched order generates one or more trade records. ResolveSTXTradeService to query them:
Real-time order and trade updates
Polling the HTTP endpoints works but adds unnecessary latency. The WebSocket channels push updates as they happen:STXActiveOrdersChannel— every state transition on an open order (open→partially_filled→filledorcancelled).STXActiveTradesChannel— each new fill as it lands.
A canonical market-maker loop
The pattern below is adapted fromcssdk-console’s STXWorker.cs. It shows the full lifecycle: connect channels, subscribe to price ticks, and requote on each tick:
See also
- WebSockets — real-time order, trade, and balance streams
- Errors & retries — common order errors and how to handle them