Hello. In the previous lesson, you learned how an order interacts with available liquidity: market orders seek immediacy, limits impose a price boundary, stops activate conditionally, and time-in-force determines what happens to any unfilled quantity.
Now we widen the lens. A fill on an exchange is important, but it is not the end of the trade. An algorithmic trading system must turn a prediction into a controlled portfolio decision, submit and monitor an order, record every execution, and then allow the market’s clearing and settlement infrastructure to complete the transfer of cash and securities. By the end of this lesson, you should be able to distinguish these stages and trace what happens to one order on its trade date and afterward.
A “trade” is several different events
In casual language, “we traded” might mean anything from “the model issued a buy signal” to “the shares arrived in the account.” Operationally, those are different state changes, usually recorded by different systems.
A useful distinction is:
| Stage | Central question | Typical output |
|---|---|---|
| Signal generation | What does the model predict? | A directional forecast or insight |
| Portfolio construction | Given all forecasts and constraints, what should we hold? | Target positions |
| Risk control | Are those targets and proposed trades permitted? | Approved, resized, or rejected targets/orders |
| Execution | How do we move toward the target in the market? | Orders and fills |
| Trade capture and accounting | What actually happened, and what do we now own or owe? | Execution ledger, positions, cash records, P&L inputs |
| Clearing | Can obligations be matched, netted, and risk-managed? | Cleared settlement obligations |
| Settlement | Have cash and ownership been finally transferred? | Final ledger entries for cash and securities |
The terms order, execution, and settlement therefore should never be used interchangeably:
- An order is an instruction. It can be rejected, cancelled, unfilled, partly filled, or fully filled.
- An execution occurs when a buyer and seller agree on a quantity and price. A partially filled order can produce several executions at different prices.
- Settlement occurs later, when the required cash and securities are exchanged and final ownership records are updated.
The QuantConnect architecture is a helpful abstraction for the first half of the lifecycle. It separates the model’s opinion from the portfolio decision and from the mechanics of trading.

Documentation - Algorithm Framework - Overview - QuantConnect.com
Read QuantConnect’s “Algorithm Framework Overview” to establish the crucial distinction between a signal, a portfolio target, an execution decision, and ongoing risk control.
In the “Important Terminology” table, read from the component definitions. Then read the “System Architecture” discussion, beginning with “The Algorithm Framework is built into the QCAlgorithm class” and ending with the paragraph explaining that the Risk Management Model may adjust portfolio targets. Focus on the changing object at each stage: assets, insights, targets, and trades.
The framework is not a claim that every broker or fund uses QuantConnect. Rather, it expresses a sound design principle: keep the question “Should we own this?” separate from “How do we trade it?”
For example, a model may forecast that a stock will rise over the next day. That is an alpha signal. It is not yet an instruction to buy 1,000 shares. Portfolio construction might decide that the appropriate exposure is 300 shares because other signals already make the portfolio long the market. Risk control might reduce that to 200 because of a single-name limit. Execution must then decide whether to buy 200 shares immediately, work a passive limit order, or delay because liquidity is poor.
From a signal to a live order
Consider a simplified intraday example. At 10:00:00, an algorithm receives a new data event and calculates a positive short-horizon forecast for a liquid stock.
1. The alpha model creates a time-stamped signal
The signal should contain more than “buy.” At a minimum, a usable signal has:
- the instrument identifier;
- a timestamp and data cutoff time;
- direction and perhaps expected magnitude;
- a forecast horizon;
- confidence or uncertainty information;
- a reason or model version for later diagnosis.
The timestamp matters because it establishes what information the system was allowed to use. If the signal was computed from data available at 10:00:00, the system may act only after that point. This simple discipline becomes central when you later backtest and validate strategies.
2. Portfolio construction converts the signal into a target
Suppose the system currently owns no shares, and portfolio construction decides that the correct position is long 500 shares.
A target is a desired inventory level, not an order. To determine the needed trade, the system compares the target with its current position and any quantity already committed in open orders:
If the current position is zero and there are no working orders, the new trade quantity is 500 shares. But if a prior order to buy 300 shares is still active, submitting another 500-share buy order would risk an unintended 800-share position. A robust system includes working orders in its decision.
3. Pre-trade controls approve, resize, or reject the order
Before sending anything to a broker, the risk layer and order-management system should test whether the proposed trade is allowed. Typical checks include:
- Is the market-data feed current, or has it become stale?
- Is the instrument tradeable at this time?
- Would the proposed trade breach a position, notional, leverage, or concentration limit?
- Does the account have enough buying power or margin?
- Is the quantity plausible relative to recent volume and the strategy’s usual order size?
- Is there already a duplicate or conflicting live order?
- Is the intended limit price within a sensible collar around the current market?
These checks are not merely administrative. A predictive model can be correct while the trade is still unsafe or operationally invalid. Conversely, a risk model may reduce exposure even when the alpha signal remains positive.
4. The execution module chooses an instruction
The approved desired trade is still not necessarily a single order. The execution module chooses an order type, quantity, and timing based on urgency and liquidity.
For a highly liquid stock, it might submit a 500-share marketable limit IOC order. For a less urgent strategy, it might submit 100 shares at a passive limit price, monitor the queue and price movement, then reassess the remaining quantity.
The order-management system should create a unique internal order identifier and retain the exact submitted instruction: symbol, side, quantity, order type, limit or stop price if applicable, time in force, timestamp, and strategy identifier.
5. The broker validates and routes the order
The broker receives the order through an API or another electronic connection. It commonly performs additional checks, such as account permissions, margin, market-session validity, and price-band controls. It may then route the order to an exchange, an alternative trading venue, or another eligible execution destination, according to its routing logic and regulatory obligations.
A broker acknowledgement means something limited: the broker has received or accepted the instruction. It does not mean that the trade has executed.
The order may progress through statuses such as:
| Status | Meaning |
|---|---|
| New | Created internally but not yet sent |
| Submitted | Sent to the broker |
| Accepted / working | Broker or venue has accepted it and it can trade |
| Partially filled | Some, but not all, quantity has executed |
| Filled | The entire order quantity has executed |
| Cancelled | Remaining quantity is no longer active |
| Rejected | The order was not accepted, often because of a rule or validation failure |
These states matter in live software. A cancel request is not proof of cancellation: a fill can occur while the cancellation message is in transit. The only safe state is the broker’s confirmed cancellation or final execution report.
6. The venue matches the order and reports fills
If the order reaches an exchange and finds eligible opposite-side liquidity, matching produces executions. In the previous lesson, you saw that one order can consume multiple price levels. This means a 500-share buy order might receive:
- 200 shares at 100.00;
- 150 shares at 100.01;
- 150 shares at 100.03.
These are distinct fills, even if the broker presents them as one combined execution summary. The system should retain the individual fill records, including execution timestamp, quantity, price, venue when available, and any fees.
The volume-weighted average execution price would be:
At this point the strategy has market exposure. It should treat its position as long 500 shares for risk monitoring, even though the eventual exchange of cash and legal ownership has not yet settled.
Execution is not the end: capture, confirmation, clearing, and settlement
The post-trade process exists because a matched trade must become a reliable, final transfer between financial institutions. It also makes the system auditable: later, you need to know exactly what the strategy ordered, what it actually received, what it paid, and whether the broker’s record agrees.
21. Post Trade Clearing, Settlement & Processing
Watch MIT OpenCourseWare’s “Post Trade Clearing, Settlement & Processing” for a concise explanation of why execution, clearing, and settlement are separate events, and why netting is economically useful.
Watch the definitions for the distinction between execution, clearing, and settlement, especially the idea of delivery versus payment. Then watch the netting example to see why a clearing arrangement can reduce gross obligations without discarding the records of individual trades.
Trade capture: the internal record of what happened
Immediately after fills arrive, the broker and the trading firm record them in trade-capture and accounting systems. For an algorithmic trader, this begins with an immutable execution ledger or trade blotter.
A fill record typically includes:
- internal order and execution identifiers;
- broker identifiers;
- instrument, side, quantity, and execution price;
- trade date and execution time;
- commissions, exchange fees, or rebates;
- currency;
- strategy, model, and account allocation tags.
From these records, the system updates:
- Position: shares or contracts held.
- Cash: actual and projected cash movements.
- Cost basis and realized/unrealized P&L inputs: needed for accounting and performance measurement.
- Risk exposure: market value, sector exposure, beta, leverage, and other limits.
The internal position should be based on confirmed fills, not on the requested quantity. If a 500-share order receives only 300 shares and its remaining 200 shares are cancelled, the system owns 300 shares. Treating the target as though it were the actual position is a fundamental operational error.
Trade Lifecycle: The Process of Buying and Selling Securities
Read this Corporate Finance Institute overview for the institutional post-trade vocabulary: trade capture, confirmation, affirmation, custodian instructions, clearing, and settlement.
Begin at “Stage 3: Trade Capture.” Read the trade-capture passage, noting the fields that must become part of a reliable execution record. Continue through “Risk Management and Compliance” and “Stage 4: Trade Confirmation and Affirmation”; read the validation and matching discussion. Finally, in “Stage 6: Clearing and Settlement,” read the core definition. Stop before “Settlement Timelines”: settlement conventions vary by market, and the U.S. equity cycle has changed since the article’s stated T+2 convention.
Confirmation and affirmation: do both sides agree?
A broker’s execution report tells you what it believes happened. In institutional trading, both sides’ records must also match: same security, side, quantity, price, trade date, and settlement instructions.
- Confirmation is the communication of trade details.
- Affirmation is agreement that those details are correct.
A retail brokerage account hides most of this machinery, but it still occurs in the infrastructure behind the interface. For a systematic strategy, the equivalent operational responsibility is reconciliation: compare internal fills, positions, cash, and fees with the broker’s official records. A discrepancy is not a cosmetic issue; it can cause an algorithm to place the wrong next order or misstate its risk.
Clearing: making obligations manageable and reliable
Clearing is the set of processes that prepares executed trades for settlement. Its precise legal structure differs across markets, but it commonly includes trade matching, risk controls, calculation of obligations, and netting.
A clearinghouse may act as a central counterparty: rather than each broker remaining directly exposed to every other broker, the clearinghouse becomes the buyer to every seller and the seller to every buyer. This structure concentrates risk management in a specialized institution.
Netting is particularly important. Suppose that over a day a broker’s clients buy 1,000 shares of a stock and sell 800 shares of the same stock for the same settlement date. The individual executions remain in the client and audit records. But the broker may have a net obligation to receive only 200 shares through the clearing system. Netting can reduce the number and size of settlement transfers while preserving every trade’s economic record.
Clearing does not mean that a pending order has been cancelled or that a strategy’s P&L has been “cleared.” In this context, it means that post-trade obligations have been validated, risk-managed, and organized for final delivery.
Settlement: final delivery versus payment
Settlement is the final transfer of securities and cash. In a conventional cash-equity purchase:
- the buyer’s side delivers cash;
- the seller’s side delivers securities;
- ownership records are updated.
When the asset delivery and cash payment occur together, the process is called delivery versus payment. This reduces the risk of one side delivering while the other side fails to perform.
The notation means the trade date. A settlement convention such as means settlement on the next business day after the trade date. As of 2024, the standard cycle for most U.S. brokered equities is , though the applicable cycle depends on the instrument, market, country, and special circumstances. Weekends and market holidays do not count as business days.
This produces an important practical distinction:
- On trade date, your broker will generally show the executed position promptly, and it may adjust available buying power or projected cash.
- On settlement date, the final cash and securities transfer is completed in the settlement system.
Your algorithm should use the broker’s defined position and buying-power fields rather than inventing its own assumptions about which cash is available. That becomes especially important when trading actively, using margin, or mixing instruments with different settlement conventions.
A brief futures contrast
For a futures contract, the economic lifecycle differs from buying a share. A futures fill establishes or changes a standardized contract position through a clearinghouse. The contract is generally marked to market, with variation margin flows reflecting daily gains and losses; traders commonly close or roll positions before any physical-delivery process applies.
So “settlement” does not always mean “shares move from one investor to another.” The unifying principle is that post-trade infrastructure determines and finalizes the obligations created by execution.
The operational mental model
For a live algorithm, maintain separate records for four related but distinct facts:
| Record | What it answers | Source of truth |
|---|---|---|
| Signal log | Why did the model want exposure? | Research/forecasting system |
| Order ledger | What instruction did we send, alter, or cancel? | Order-management system and broker acknowledgements |
| Fill ledger | What quantity actually executed, when, and at what price? | Broker and venue execution reports |
| Position, cash, and settlement records | What exposure and obligations do we have now, and what has finally settled? | Internal accounting reconciled with broker/custodian records |
This separation is a programming discipline as much as a financial one. An order record should not be overwritten to pretend it was a fill. A fill record should not disappear when clearing nets settlement obligations. And a target position should never be treated as proof that the market has delivered that exposure.
When something goes wrong, these records let you locate the fault:
- The signal was correct but the order was rejected.
- The order was accepted but only partially filled.
- The fills were correct but the internal position was miscomputed.
- The internal records were correct but did not reconcile with the broker.
- The trade executed normally, but a settlement exception later required attention.
That traceability is the foundation for both robust backtesting and safe deployment.
Key takeaways
An algorithmic order begins as a time-stamped signal, becomes a constrained target position, and then becomes one or more concrete orders chosen by the execution module.
A broker acknowledgement is not a fill; a fill is not settlement. Execution establishes the agreed price and quantity, while post-trade systems capture the result, validate records, calculate and net obligations, and eventually settle cash and ownership.
Treat signals, targets, orders, fills, positions, and settled balances as distinct objects. In particular, base market exposure and risk checks on confirmed fills, not on requested order quantities or desired targets.
Next, you will calculate long- and short-position P&L, including commissions, spread costs, financing, and futures variation margin.
Can't find a good explanation? Sign up and we'll make it for you
Sign up