How does PropExecutor handle orders that arrive at the same time?
Quick answer
Each order takes a per-account lock and is checked and written inside one database transaction, with open positions read from the database in that transaction. Simultaneous orders on the same account are therefore processed one after another, and limits such as maximum positions hold, even across server instances.
Detailed answer
Concurrency bugs are a classic way for rule limits to fail silently.
The problem
Two orders placed at the same moment can both be checked against the same state. If each sees four open positions under a limit of five, both pass, and the account ends with six.
PropExecutor's approach
- Take an advisory lock for the account inside the transaction.
- Read open positions and equity from the database.
- Run every order-time rule and the margin check.
- Write the order, or refuse it.
- Commit, releasing the lock.
Every path
Market orders, pending order placement and changes, stop changes and pending orders triggering all use this order gate. The gate fails closed: a path that cannot be checked is refused.
Across instances
Because the lock is in the database, it works whichever server instance receives each order.
Effect on traders
Traders see consistent results: an order is either accepted within the limits or refused with a reason. Under normal conditions the lock is held for a very short time, so it does not slow trading noticeably.
PropExecutor team · Updated
Related questions
- The PropExecutor rule engineAre pre-order checks enforced when orders arrive at the same time?
- The PropExecutor rule engineCan I limit the number of open positions?
- What happens if a PropExecutor server goes down?
- Challenge design and trading rulesWhat is a maximum open positions rule?
- The PropExecutor rule engineWhat is the PropExecutor rule engine?
All 11 questions in Security, data and reliability · Every category