TradeViora AcademyLearn. Analyze. Practice. Trade Smarter.
Menu

FREE FINANCIAL EDUCATION

Execution modeling

Model spread and slippage consistently for buys and sells.

0%

What you will learn

Prerequisites: Bid and ask, order types, OHLC ambiguity and position accounting.

Mechanism and decision rules

A backtest execution model maps orders to possible fills. A market buy typically interacts with available offers and a market sell with bids, so buying and selling at the same midpoint omits spread cost. Additional impact or slippage depends on size, liquidity, volatility and latency. A limit order caps price but introduces nonexecution risk; a bar touching the limit is insufficient evidence that the order reached the front of the queue.

The model should state order submission time, eligible prices, quantity constraints, partial-fill behavior and cancellation timing. If a stop and target are both touched in one bar, the bar does not identify which happened first. Use finer event data or a declared conservative rule. Do not choose the favorable ordering separately for every trade.

Worked example · synthetic data

A synthetic book shows bid ₹99.90 and ask ₹100.10. Buying 100 shares at the ask and immediately selling at the bid loses 100 × ₹0.20 = ₹20 before fees, although the midpoint never moved. A midpoint-only simulation reports zero and misses the spread.

Suppose a buy limit at ₹99.80 is submitted after the bar opens and the bar low is ₹99.80. The low could have occurred before submission, or available sell quantity could have filled earlier queue orders only. Counting a full fill solely from that low is optimistic.

Failure modes and limits

Historical top-of-book data does not reveal every queue position or hidden order. Large orders can move prices, so fixed slippage may understate impact. Exchange halts and broker rejects need explicit treatment. Paper fills often differ from live routing, and calibration should not be tuned only to successful live executions.

Practice case

Bid is ₹250.00 and ask ₹250.40. A market buy of 50 units fills at the ask, and a later market sale occurs at an unchanged bid. Calculate spread loss before fees. Why would a midpoint model miss it?

Reveal the worked answer

The buy costs ₹12,520 and the sale returns ₹12,500, losing ₹20. Both midpoint marks are ₹250.20, so a midpoint fill assumption would show no change. The actual transaction crossed the spread twice around that midpoint.

Check your understanding

A bar low touching a buy limit proves what?


Explanation

Timing and queue position remain unknown from the bar alone.

Bid 99.90 and ask 100.10 imply what immediate 100-share round-trip spread loss?


Explanation

The buy–sell difference is ₹0.20 per share times 100.

What is defensible when stop and target are both inside one bar?


Explanation

The missing sequence should be resolved consistently without favorable hindsight.

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