# Execution Cost Modeling

Also known as: slippage, spread, partial fills, requotes/latency.
A Risk, Sizing & Exits concept (Orders & execution) in the LuxAlgo Library, with 1 indicator implementation.

## What is Execution Cost Modeling?

Execution cost modeling is the practice of estimating the gap between the prices a strategy assumes and the prices real orders achieve. The gap has several components: the bid-ask spread paid when crossing the book, slippage between the decision price and the fill price, commissions and exchange fees, partial fills that leave intended size unexecuted, and, in dealer-quoted markets, requotes and latency effects where the quoted price is gone by the time the order arrives. Together these are the frictions that separate a backtest from a brokerage statement.

The discipline exists because untreated costs are one of the most common ways a profitable-looking system fails live. A backtest that fills every signal at the printed close pays no spread, suffers no slippage, and never misses size. For a low-frequency system with large average wins the distortion may be tolerable; for a high-turnover strategy whose average trade earns a few ticks, realistic costs routinely erase the entire edge. Modeling costs explicitly, and stress-testing the strategy's [sensitivity to cost assumptions](https://www.luxalgo.com/library/concept/cost-sensitivity/), is therefore a core part of honest strategy evaluation rather than an accounting afterthought.

Cost models range from crude to elaborate. The simplest charge a fixed amount per trade. Better models scale costs with the instrument's spread and volatility, condition slippage on [relative volume](https://www.luxalgo.com/library/concept/relative-volume/) and time of day, and treat stop orders (which chase price) more harshly than resting limits (which risk non-fill instead). Institutional models add market impact, the adverse price movement caused by the order itself, which grows with order size relative to available liquidity. No model is exact; the practical goal is a conservative estimate that the live strategy tends to beat rather than an optimistic one it tends to miss.

## How it's calculated

There is no single canonical formula; the standard per-round-trip accounting is:

```
round_trip_cost = commissions + spread_cost + slippage_entry + slippage_exit
spread_cost = (ask - bid) / 2 per side crossed
slippage = fill_price - decision_price (signed against the trade)
cost_bps = round_trip_cost / notional * 10000
net_expectancy = gross_expectancy - expected_round_trip_cost

  commissions: broker and exchange fees for both sides of the trade
  decision_price: price at the moment the signal fired or the order was sent
  fill_price: volume-weighted average price actually received
  notional: dollar value of the position, used to normalize costs
  gross_expectancy: average profit per trade before frictions
```

Market-impact terms for large orders are often modeled as increasing with the square root of order size relative to daily volume; parameters are venue and instrument specific.

Limit-order strategies substitute a fill-probability model for spread cost, since the cost of passivity is missed trades rather than paid spread.

## How traders use it

- In backtesting, as a deduction applied to every simulated trade, ideally scaled to spread and volatility rather than fixed; this is the difference between [realistic and decorative cost assumptions](https://www.luxalgo.com/library/concept/cost-model-realism/).
- As a viability screen: computing the strategy's average gross profit per trade in ticks and comparing it to modeled round-trip cost quickly reveals whether an edge survives friction at all.
- In live monitoring, by recording decision price versus fill price on every order so the realized slippage distribution can be compared with the model and the model corrected, a feedback loop that also feeds [walk-forward evaluation](https://www.luxalgo.com/library/concept/walk-forward-analysis/).
- In execution design: modeled costs guide choices between market and limit orders, between taking liquidity and posting it, and whether large orders should be sliced algorithmically via [TWAP, VWAP, or POV schedules](https://www.luxalgo.com/library/concept/twap-vwap-pov-execution/).
- With honest limits: slippage in fast markets, around news, and at stop-loss prices is fat-tailed, so average-based models understate worst cases and should be paired with stress scenarios.

## Execution cost modeling vs adjacent concepts

- **Cost Model Realism** (https://www.luxalgo.com/library/concept/cost-model-realism/): The evaluation standard this modeling serves: whether a backtest's assumed frictions plausibly match live trading. Cost modeling supplies the numbers; realism judges them.
- **Cost Sensitivity** (https://www.luxalgo.com/library/concept/cost-sensitivity/): The stress test built on top of a cost model: re-running results across a range of cost assumptions to see how quickly the edge degrades.
- **TWAP/VWAP/POV Execution** (https://www.luxalgo.com/library/concept/twap-vwap-pov-execution/): Execution algorithms designed to reduce the very costs being modeled, chiefly market impact, by slicing large orders across time or volume.

## FAQ

### How much slippage should I assume in a backtest?

There is no universal number; it depends on instrument, order type, size, and session. A common starting point is one tick or spread per side for liquid futures market orders, then replacing assumptions with your own measured fills as soon as live data exists.

### Why did my live results underperform a backtest that already included costs?

Usual suspects are optimistic fill logic (limit orders assumed filled on a touch), costs that ignore volatility spikes, stop orders modeled at their trigger price, and partial fills reducing size on winners.

### Do costs matter for swing and position traders?

Less than for day traders, but they still compound: spread, fees, and overnight financing across dozens of trades a year can consume a meaningful share of a modest edge.

### What are requotes and why do they belong in a cost model?

In dealer-quoted markets such as retail forex, the dealer may reject your order and offer a new price when the market moves. Modeling them as extra adverse slippage during fast conditions keeps the backtest honest.

## Implementations in the Library

- Execution Cost Modeling (LuxAlgo): https://www.luxalgo.com/library/indicator/execution-cost-modeling/

## Related concepts

- Order Types: https://www.luxalgo.com/library/concept/order-types/
- Order Constructs: https://www.luxalgo.com/library/concept/order-constructs/
- TWAP/VWAP/POV Execution: https://www.luxalgo.com/library/concept/twap-vwap-pov-execution/
- Exchange Order Flags: https://www.luxalgo.com/library/concept/exchange-order-flags/

---

Source: https://www.luxalgo.com/library/concept/execution-cost-modeling/ (LuxAlgo Library, the encyclopedia of trading & technical analysis). Free to use with attribution: https://www.luxalgo.com/library/license/