Duplicate Order Protection
Common symptoms
- same intent appears multiple times in order book
- retries after timeout create accidental duplicates
Safety checklist
- Always store
order_id from each placement.
- Pass a
tag kwarg for request correlation.
- Before retrying, check recent orders for matching intent.
- Retry only on clearly transient errors.
Basic pattern
order_id = broker.place_order(
instrument=instrument,
side=side,
qty=qty,
order_type=order_type,
product=product,
tag="strategyA-20260305-093000-01",
)
# If place call is uncertain, inspect get_orders() before re-sending
Operational controls
- keep short-term in-memory dedupe key
- alert when same symbol+side+qty repeats quickly
- use manual approval for replays in production