clientOrderId you choose,
and retrying with the same id can never create a second order. Keep that habit from your first call.
1
Check the risk state first
An account that is risk-locked answers
423 to every order. Read the state before you trade,
and treat 423 as a state to display, not an error to retry.2
Place a market order with exits attached
stopLoss and takeProfit ride along with the order. Atomic: the exits are placed with the
order as one unit or not at all.price and the tick
offset from the entry.A saved exit plan can stand in for the two legs: send exitPlan (the plan, the revision you
previewed, and the token you were given) instead of stopLoss/takeProfit — sending both
answers 400.3
Confirm what the account now holds
The snapshot returns the summary, positions, and working orders at a single consistent
revision — read it rather than stitching the one-shot reads together.
4
Move or cancel the resting orders
Replace an order moves one resting order to a new
price — one operation under one idempotency claim. Cancel an
order removes it by its broker order id.
5
Know the way out
Flatten a position cancels the instrument’s
working orders, then closes its position at market. It is the guide rail for every demo and
the last step of every test run.
Where to go deeper
- Idempotency — why retries are safe, and what a claim is.
- Set position exits — change a position’s stop and target after entry.
- Errors — what
423,429, and the refusal shapes mean.