Are pre-order checks enforced when orders arrive at the same time?
Quick answer
Yes. Every order path takes a per-account lock and runs the rule checks inside the same database transaction that writes the order, counting open positions from the database in that transaction. Two orders arriving at the same instant are therefore processed one after the other, and limits hold, even across server instances.
Detailed answer
Concurrency is where many rule engines fail.
The problem it solves
A naive engine checks a limit, then writes the order. If two orders arrive together, both checks see the same state, both pass, and the account ends up over the limit. For a maximum of 5 positions, a trader with 4 could open 6.
How PropExecutor handles it
- The order takes a lock specific to that account.
- Open positions are read from the database inside the transaction.
- The order gate checks every order-time rule.
- The order is written in the same transaction, with any breach or flag it caused, or refused if the instrument is not allowed or margin is short.
- The lock is released.
Every path is covered
Market orders, placing and modifying pending orders, changing stops, and a resting order triggering all go through the same gate. A new order path cannot be added without it.
Why it matters to firms
Exposure and count limits such as maximum open positions, maximum total lots, hedging bans and orders per day hold exactly as written, so traders cannot exploit timing to exceed them.
PropExecutor team · Updated
Related questions
All 30 questions in The PropExecutor rule engine · Every category