How to Track an Order Through Its Full Lifecycle
Understand how trading orders move from submission through pending, open, partial fill, filled, cancelled or rejected states. Learn why accurate lifecycle tracking and reconciliation matter in automated trading software.
Why Order Lifecycle Tracking Matters
In automated trading, sending an order is only the beginning. A reliable trading application must know what happened after the request was submitted, whether the order is still waiting, partially executed, completed, cancelled or rejected.
This is known as order lifecycle tracking. It gives a trading system a consistent view of order status and helps it make correct decisions when market conditions, broker responses or network conditions change. Without proper lifecycle tracking, software can mistakenly place duplicate orders, show incorrect positions or assume that an order was executed when it was not.
For traders and businesses building automated trading software, understanding order states is therefore an important part of system design.
What Is an Order Lifecycle?
An order lifecycle is the sequence of states an order can move through from creation to its final outcome.
The exact names and available statuses can differ between trading platforms, brokers and APIs, so software should use the status definitions provided by the relevant trading system rather than assuming that every broker behaves identically.
A simplified lifecycle may look like this:
- The strategy creates an order request.
- The application sends the request to the broker or trading venue.
- The order becomes pending or is accepted for processing.
- The order may become open or active in the market.
- It may be partially filled or completely filled.
- It may instead be cancelled or rejected.
- The application records the final result and updates its internal state.
The important point is that an order request and an executed trade are not the same thing.
Understanding Common Order States
Pending
A pending state generally means the order has been submitted or is waiting for a further event before it reaches a later state.
For example, a trading application may submit a limit order to buy an instrument at a specified price. If the market has not reached that price, the order may remain pending or active depending on the platform's terminology.
The software should not treat a pending order as a filled position.
Open or Active
An open or active order is an order that remains in the market and can potentially be executed.
For example, a limit order may be accepted by the trading system and remain active until its price condition is met, it expires, or it is cancelled.
This distinction matters because an active order represents an outstanding instruction, while a filled order represents an execution.
Partially Filled
A partial fill occurs when only part of the requested quantity has been executed.
Suppose an application submits an order for 1,000 units and 400 units are executed. The order is not fully complete. The remaining quantity is still outstanding unless the platform reports another final status.
A robust system should track at least:
- Original quantity
- Filled quantity
- Remaining quantity
- Average execution price where available
- Current order status
- Broker or exchange order identifier
Partial fills are particularly important in systems that calculate positions, exposure or risk from executed quantity.
Filled
A filled order means the requested quantity has been executed according to the trading platform's reported status.
The application should update its position and execution records based on confirmed execution information rather than simply assuming success because an order request was accepted.
For example, if a buy order for 100 units is completely filled, the trading application can use the confirmed fill information to update the relevant position.
Cancelled
A cancelled order will not continue waiting for execution.
Cancellation can occur because the user or strategy explicitly requested it, or because of other conditions defined by the trading system, such as an order's validity period ending.
A cancelled order should not be counted as an executed position unless there are separate execution records showing that some quantity had already been filled.
Rejected
A rejected order was not accepted for execution by the relevant trading system.
Possible reasons depend on the broker, venue and order type. Examples can include invalid parameters, insufficient available funds or margin, market restrictions, instrument restrictions, or other validation failures.
The application should capture the rejection status and available error information rather than repeatedly submitting the same request without understanding why it failed.
How States Transition
Order states are easier to manage when the software treats them as a state machine.
A simplified example is:
- Created → the strategy decides that an order is required.
- Submitted → the application sends the order request.
- Pending/Open → the order is accepted and waiting for execution or another event.
- Partially Filled → some quantity has executed.
- Filled → the complete required quantity has executed.
- Cancelled → the remaining order is cancelled.
- Rejected → the order request is rejected.
Not every order follows every state.
For example:
- Created → Rejected
- Created → Filled
- Open → Cancelled
- Open → Partially Filled → Filled
- Partially Filled → Cancelled
The actual transition rules must be based on the broker or trading API documentation.
Why Partial Fills Need Special Handling
Partial execution is one of the easiest cases to overlook when designing trading software.
Imagine a strategy wants to buy 500 shares. The order is accepted, but only 200 shares are filled. If the application immediately marks the entire 500-share position as active, its internal position will be wrong.
A better design separates order quantity from executed quantity.
The system should be able to answer:
- How much did the strategy request?
- How much has actually been executed?
- How much remains?
- Is the remaining quantity still active?
- Has the order been cancelled?
- Which executions belong to this order?
This information is useful for position tracking, risk calculations, reporting and reconciliation.
Order Status and Position Status Are Different
Another common mistake is treating an order status as a direct representation of a position.
An order is an instruction to buy or sell. A position represents the resulting exposure after executions.
For example, an application may submit a sell order and receive an accepted or open status. At that point, it should not automatically assume that the position has changed by the full order quantity.
Only confirmed execution information should be used to determine the executed quantity.
This separation becomes even more important when a strategy manages multiple orders, partial fills or multiple symbols.
Tracking Orders Reliably
Store a Unique Order Identifier
Every order should be associated with a unique identifier supplied by the trading system or generated by the application where appropriate.
The identifier allows the application to match later updates to the original order.
Useful fields may include:
- Internal strategy ID
- Broker or venue order ID
- Symbol or instrument
- Side
- Requested quantity
- Filled quantity
- Order type
- Price information
- Current status
- Timestamps
- Error or rejection details
The exact fields depend on the platform and business requirements.
Record Status Changes
Do not only store the latest status.
Maintaining a history of important order events can help developers understand what happened when something goes wrong.
For example:
- Order created.
- Request submitted.
- Broker acknowledged request.
- Order became active.
- Partial execution received.
- Remaining quantity cancelled.
This event history can be valuable for debugging and reconciliation.
Handle Delayed or Repeated Updates
Network communication is not always perfectly predictable. An application may receive updates later than expected, and an integration may need to handle repeated notifications safely.
The system should therefore avoid assuming that every message arrives exactly once or in the expected sequence.
Using order IDs, execution IDs, timestamps and carefully designed state transitions can reduce the risk of inconsistent internal records.
Reconciliation: The Safety Check
Reconciliation means comparing the application's internal records with the broker or trading platform's current records.
This is especially important after:
- Application restarts
- Network interruptions
- Deployment
- API connection failures
- Missed events
- Unexpected broker responses
For example, the application may believe an order is still open while the broker reports that it has already been filled. A reconciliation process can identify the difference and update internal state.
A trading system should not blindly trust its previous in-memory state after a serious interruption. The external trading account or broker system may have changed while the application was disconnected.
Common Order Lifecycle Mistakes
Treating Submission as Execution
An accepted request does not necessarily mean the order was filled.
Better approach: update positions using confirmed execution information.
Ignoring Partial Fills
Assuming every order is either completely filled or completely unfilled can produce incorrect exposure calculations.
Better approach: track requested, filled and remaining quantities separately.
Overwriting History
Keeping only the latest status makes it harder to understand how the order reached its current state.
Better approach: maintain an event or status history where appropriate.
Repeating Orders After a Timeout
A timeout does not automatically prove that an order was never accepted.
If the request reached the broker but the response was lost, blindly sending the same order again can create a duplicate.
Better approach: reconcile the order using identifiers and external account information before retrying.
Assuming Every Broker Uses the Same States
Different APIs can expose different terminology, transitions and event models.
Better approach: design the integration around the actual API documentation and map external statuses into a clear internal model.
Designing for Reliable Automation
A good order lifecycle design should separate several responsibilities:
- Strategy layer: decides whether an order is required.
- Order manager: creates and tracks order requests.
- Broker integration: communicates with the trading API.
- Execution tracker: records fills and execution details.
- Position manager: calculates current exposure from executions.
- Reconciliation process: checks internal state against external state.
- Logging system: records important events and errors.
This separation makes the system easier to test and maintain.
It also helps prevent a strategy from making assumptions about broker responses. The strategy should receive a clear internal status instead of depending directly on every detail of a particular API.
Practical Example
Consider a strategy that generates a buy signal for 1,000 units.
The application creates the order and sends it to the broker. The broker accepts it and reports the order as active.
Later, 600 units are executed. The system changes the order to partially filled and records the executed quantity as 600.
The strategy now knows that 400 units remain, subject to the broker's current order status.
If the remaining quantity is cancelled, the final order state becomes cancelled, while the application still retains the 600-unit execution record.
This example shows why an order's final status alone may not describe everything that happened. Execution history and order state need to work together.
How Suyotech Approaches Trading Software
Suyotech Solutions develops trading software and automation systems where order lifecycle handling, execution tracking, state management and broker integration can be designed around the specific business and strategy requirements.
The exact architecture depends on the trading platform, order types, instruments, execution model and operational requirements. A reliable system should be designed around confirmed events and clear state transitions rather than assumptions.
Conclusion
Tracking an order through its full lifecycle is a fundamental part of reliable automated trading software. Pending, open, partially filled, filled, cancelled and rejected states each represent different conditions and should not be treated as interchangeable.
A well-designed system tracks order identifiers, execution quantities, status changes and errors while separating orders from positions. Reconciliation is also important when applications restart or lose communication with external trading systems.
Automation can reduce manual work, but it does not remove market, execution, technology or integration risks. Backtests and software performance cannot guarantee future trading results.
For businesses planning a trading application or broker-integrated automation system, clear lifecycle tracking should be part of the technical specification from the beginning. Contact Suyotech Solutions to discuss trading software development and integration requirements.
