Skip to content
All library documents

Modeling Trading Costs, Orders, and OHLC Limits in Strategy Backtests

Article SuperMind

Summary

This tutorial explains why backtests need to account for more than commissions. It separates costs into fees and taxes, slippage from the delay between a signal and execution, and market impact and liquidity effects, including bid-ask spreads. It compares fixed, linear, piecewise-linear, and quadratic cost models, describing the tradeoff between implementation effort and their ability to represent costs that vary with trading conditions.

The article also discusses how order choice changes simulated outcomes: market orders are more certain to fill but can incur uncertain prices, while limit orders constrain price but may receive partial or no execution. Daily OHLC data can add another source of error because composite prices may include unusual venue prints or bad ticks, and a backtest's assumed price may not be available through a particular broker. It recommends higher-frequency or venue-specific data for strategies sensitive to those prices, while noting that more accurate cost modeling is especially consequential for frequent or large-volume trading.

Key ideas

  • Trading costs include commissions and fees, slippage and latency, and liquidity-related market impact and spreads.
  • Fixed cost assumptions are simple but may misstate costs that depend on volatility, liquidity, and trade size.
  • Nonlinear cost models can better represent slippage and market impact, though they take more effort to build and run.
  • Market orders prioritize execution while limit orders control price but may not fill completely or at all.
  • Composite daily OHLC data can contain prices that do not match the executions available to a specific trader.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.