FREE FINANCIAL EDUCATION
End-of-test open-position accounting
Include open positions when measuring terminal portfolio value.
What you will learn
Prerequisites: Track cash, cost basis, remaining quantity and marked equity.
- Include open positions when measuring terminal portfolio value.
- Separate a mark-to-market endpoint from an explicitly modeled liquidation.
- Reconcile realized and unrealized P&L without inventing a future exit.
Mechanism and decision rules
A backtest’s last date is an accounting boundary, not evidence that every position has closed. A mark-to-market endpoint values remaining holdings at a documented contemporaneous mark and includes cash and liabilities. A liquidation endpoint instead simulates an executable exit under specified price and cost assumptions. Report which convention is used, because the difference can materially affect a short test or an illiquid strategy.
Closed-trade P&L alone omits unrealized gains and losses. Reconcile initial equity plus realized P&L, unrealized P&L and other net flows to terminal equity. The examples use a single purchase basis, no external cash flows and no charges on earlier fills; a separate final liquidation fee is introduced explicitly. A later favorable price cannot be substituted for the endpoint merely because the position would eventually have recovered.
Worked example · synthetic data
Begin a hypothetical account with 10,000. Buy 50 units at 100, then sell 20 at 110. Cash is 7,200 and 30 units remain. At a terminal mark of 108, holdings are worth 3,240 and equity is 10,440, for P&L 440. Realized profit is 200 and unrealized profit 240, which reconcile. If instead the stipulated endpoint liquidates at bid 107.5 with fee 0.1 per remaining unit, sale proceeds after fees are 3,222 and final equity 10,422. The liquidation result is 18 below marked equity, reflecting the bid difference and fee rather than another trading signal.
Failure modes and limits
Last trade, midpoint, bid and settlement price can represent different marks. Stale prices or halted instruments may require a disclosed valuation method rather than a convenient last quote. Forced liquidation can be infeasible within the test horizon, so do not imply it occurred if only a valuation is available. Canceled orders are separate from holdings; the endpoint should disclose remaining live instructions and liabilities as well as the position value.
Practice case
A new account starts at 5,000, buys 40 units at 50 and sells ten at 48. At the endpoint, the remaining units are marked at 49. Calculate cash, marked equity, realized and unrealized P&L. Then calculate liquidation equity at 48.8 with a fee of 0.05 per remaining unit, under otherwise identical assumptions.
Reveal the worked answer
Cash is 3,480 and 30 units remain, worth 1,470 at the mark. Equity is 4,950 and total P&L −50, split into realized −20 and unrealized −30. Liquidation produces 30×48.8−1.5=1,462.5, giving equity 4,942.5 and P&L −57.5. The 7.5 difference from marked equity is the exit-price difference plus the explicit liquidation fee.
Check your understanding
Sources and next steps
The lesson, calculations and synthetic cases are original educational material. References explain underlying contract or chart conventions; none validates the profitability of a trading rule. Actual contract specifications, settlement obligations and charges must be checked before trading.
Explore OHLCV data in the chart lab · Explore volume-at-price and TPO data · Practice library
