# The Backtest Filled at a Price the Market Never Offered

> A historical trade can look profitable on screen while remaining impossible to execute once queue position, cancellations and stressed liquidity enter the model.

- **Author:** Uğur Akçıl (https://softwaredeveloper.biz/author/ugur-akcil)
- **Topic:** systems-architecture
- **Published:** 2026-09-20T14:41:13+00:00
- **Canonical URL:** https://softwaredeveloper.biz/p/the-backtest-filled-at-a-price-the-market-never-offered

## Key Thesis

A backtest can mistake observed prices for executable liquidity, especially when market conditions change and historical averages hide tail events. Model queue position and regime uncertainty, then protect the system with limits, replayable decisions and ledger invariants.

---

## A price on the screen is not a promise

A backtest can show a strategy buying at 100 and selling at 101, then report a clean profit. Yet the historical record may only show that the market touched those prices. It does not prove the strategy could have joined the queue, received a fill, or traded enough size before conditions changed.

That gap is easy to miss because most backtests begin with prices and returns, while execution happens through orders, cancellations and competing participants. A displayed bid is an invitation to trade, not a reserved quantity. By the time an order reaches the exchange, the visible depth may have moved or disappeared.

The mathematical trap is treating liquidity as a fixed property of a price series. In reality, it is a stochastic process: orders arrive, resting orders cancel, and trades consume depth. These events depend on each other. A large price move can trigger cancellations, which thin the book and make the next trade more disruptive.

This is why a strategy tested against daily bars or midpoint prices can look robust and fail at production scale. Its simulated trades may assume a market that was never available to it.

## Liquidity has memory

One practical way to model this is to treat order arrivals and cancellations as event processes whose rates respond to conditions. A simple model might estimate the chance of a fill from displayed depth, queue position, order size, volatility and recent cancellation activity. More advanced models can let one event raise the short-term likelihood of related events, as in self-exciting point processes.

The important idea is not the model’s complexity. It is that the probability of a fill changes with the state of the market. A quiet book and a book reacting to a sudden imbalance may show similar top-of-book prices, but they do not offer the same execution odds.

A regime-switching model makes this difference explicit. It assumes the market can move among states, such as calm, stressed and recovering, with different distributions for volatility, depth and order flow in each. The state is not always directly observable. A system estimates it from signals such as spread, cancellations and short-horizon volatility.

That estimate is uncertain, and the model should preserve that uncertainty rather than output one confident fill price. In production, a 70 percent chance of a partial fill is more useful than a precise-looking average that conceals the remaining 30 percent.

<svg class="acad-diagram" viewBox="0 0 680 180" xmlns="http://www.w3.org/2000/svg">
<rect x="20" y="55" width="145" height="60" stroke="currentColor" fill="none"/>
<text x="36" y="80" font-family="monospace" font-size="12" fill="currentColor">Market regime</text>
<text x="36" y="99" font-family="monospace" font-size="12" fill="currentColor">estimated state</text>
<line x1="165" y1="85" x2="205" y2="85" stroke="currentColor"/>
<rect x="205" y="55" width="145" height="60" stroke="currentColor" fill="none"/>
<text x="223" y="80" font-family="monospace" font-size="12" fill="currentColor">Queue and</text>
<text x="223" y="99" font-family="monospace" font-size="12" fill="currentColor">fill model</text>
<line x1="350" y1="85" x2="390" y2="85" stroke="currentColor"/>
<rect x="390" y="55" width="125" height="60" stroke="currentColor" fill="none"/>
<text x="410" y="80" font-family="monospace" font-size="12" fill="currentColor">Execution</text>
<text x="410" y="99" font-family="monospace" font-size="12" fill="currentColor">limits</text>
<line x1="515" y1="85" x2="555" y2="85" stroke="currentColor"/>
<rect x="555" y="55" width="105" height="60" stroke="currentColor" fill="none"/>
<text x="570" y="80" font-family="monospace" font-size="12" fill="currentColor">Ledger</text>
<text x="570" y="99" font-family="monospace" font-size="12" fill="currentColor">invariants</text>
<text x="20" y="145" font-family="monospace" font-size="12" fill="currentColor">Uncertain conditions must flow through every execution decision</text>
</svg>

## Backtests need an execution model

A useful backtest asks not only whether a signal predicted a price move, but whether its orders could have participated in that move. That means modeling latency, queue priority, partial fills, fees, market impact and cancellations. It also means testing different assumptions instead of selecting the one that makes the strategy look best.

| Dimension | Simplified backtest | Production-aware test |
|---|---|---|
| Price | Trade at observed price | Estimate executable price and slippage |
| Liquidity | Treat displayed depth as available | Model queue position and cancellations |
| Market state | Use one average distribution | Test calm, stressed and transition states |
| Outcome | Count expected fills | Track partial fills, rejected orders and exposure |

A model can still be wrong. The goal is not to predict every order-book event. It is to expose where performance depends on fragile assumptions. Run sensitivity tests across fill rates, latency and depth, then report how results change when the worst plausible conditions arrive together.

This is especially important for tail regimes. Historical data contains only the events that happened, not all the events that could have happened. If a strategy has only a few stress episodes in its sample, a high average return may tell us little about its behavior during the next one. Stress tests should therefore combine observed episodes with carefully bounded scenarios, such as depth collapsing while cancellations accelerate.

## Invariants survive the forecast

Market models shape decisions, but exchange and payment systems also need rules that remain true when the model is wrong. A trading system should enforce limits on order size, exposure and stale data before a forecast reaches the venue. It should be able to stop or reduce activity when uncertainty exceeds a defined threshold.

A payment core has a related but stricter requirement: money movement must reconcile. Double-entry accounting means every accepted movement has corresponding debits and credits, and the ledger records the committed result rather than a prediction of what should have happened. Retries, timeouts and partial failures must not create or erase value.

This distinction matters under stress. A risk estimate might change when a regime classifier updates, but an already committed ledger entry cannot be quietly revised to make the estimate fit. Systems need idempotent commands, explicit transaction states and replayable event histories so operators can distinguish a delayed confirmation from a duplicate action.

The research mechanism is useful when it changes what engineers measure. Track realized fill probability against the model, compare predictions by regime, and monitor slippage and reconciliation errors as first-class operational signals. When the model drifts, constrain the execution path and preserve the evidence needed to understand why.

A backtest is not a rehearsal of the market. It is a conditional argument about what might have been executable, given assumptions that must be tested again when the market changes.

## References

- [CTO Field Agenda: Stochastic Systems in Real Markets: Why Backtests Lie About Liquidity and Tail Regime...](https://arxiv.org/list/q-fin.TR/recent)
- [Ugur Akcil (ugur.io)](https://ugur.io)

---

## Discussion (3 notes)

- **Jonah Halpern** (Bootstrapped SaaS Founder · Denver, CO · 2026-09-20): Backtests on daily bars miss queue position entirely. I've seen this same mistake when SaaS founders model revenue on signups, ignoring churn's impact on cash flow. Both confuse observed signals for executable reality. The ledger invariants advice maps directly to always verifying billing system ledgers against actual bank deposits.
  - **Ugur Akcil** (Technology Executive · Systems & AI Architecture · ORZED · 2026-09-20): You've nailed the cross-domain pattern: mistaking a leading indicator for a settled outcome. The parallel to churn and cash flow is precise, it’s the same error of assuming a process is static. The ledger invariant discipline is the key. It forces you to validate that the simulated path was actually traversable, in both trading and SaaS.
  - **Ugur Akcil** (Technology Executive · Systems & AI Architecture · ORZED · 2026-09-21): That’s a sharp parallel. You’re right, both cases mistake a recorded signal for an available state. The signup count is the daily closing price. The cash flow ledger is the actual fills. The invariant check you described, matching the ledger to bank deposits, is the exact discipline: never let the derived metric (signups, mid-price) disconnect from the real system of record (cash, executed trades).
