Place, cancel, and inspect orders; fetch positions and fills.
Use staging first.env="production" trades with real balances. Every snippet on this page runs against env="staging" — flip the flag only when you’ve verified the code path end-to-end.
Preview and confirm take the same params. The SDK doesn’t auto-confirm from a preview — you have to call confirmOrder explicitly so the trade decision stays in your code.
from stx import Selectionbalance = client.userProfile(selections=Selection("balance")).balance
The default-all-fields behaviour would pull positions, fills, and the full profile graph — wasteful when you want a single scalar. Narrow the Selection.
confirmOrder is not idempotent — calling it twice with the same params places two orders. If you need retries to be safe, wrap the call yourself:
from stx._retry import RetryPolicyfrom stx.exceptions import STXException# Disable the default retry for confirmOrder specifically.try: order = client.confirmOrder(params=..., retry=RetryPolicy.DISABLED)except STXException: # Check userOrders to see if the order made it through before retrying. ...
The default retry policy (errors-and-retries) excludes confirmOrder and cancelOrder from automatic retries for exactly this reason.