More details are in email…
Here’s a well-established and large-scale order manager class design. It handles millions of orders a day.
- The entire process is restarted on every trading day. Before the restart, all pending orders are cancelled! The OM is probably a per-thread singleton in the process.
- The OM stores all the orders for the day, including each closed order in case it needs cancellation.
- The OM keeps all the partial executions (aka partial fills) for a given order, because each execution could be busted.
- Each action on an order (such as validation, partial execution ..) is performed by a dedicated object. For 1000 orders, if there are 5 actions, then there would be 5000 distinct “action objects”. The OM has pointers to all of these action objects.
- Most action objects are stateful. ALL action objects are persisted somewhere so as to support busting/cancellation.