# Transaction costs in backtests: basis points, turnover and drag

Canonical URL: https://marketheist.io/portfolio/learn/transaction-costs
By Jeffrey Lin · Published 2026-11-17 · Updated 2026-11-17 · Data through Sep 2026
Category: Validation

## Key takeaways

- A basis point is one hundredth of a percent. A one-way cost is paid on each side of a trade, so a round trip, in and back out, pays it twice.
- Costs grow with turnover. A rule that trades once a year hardly notices them; a rule that trades every week can lose most of what it earned to them.
- A quick check before any backtest: every round trip pays the one-way cost twice, so the yearly drag rises in step with the number of trades.
- Commissions are the visible part. The bid-ask spread, slippage between the signal's price and the fill, market impact and taxes on realised gains are often larger, and a backtest that charges nothing ignores all of them.
- MarketHeist charges the cost on every day the position changes, in proportion to the size of the change, and only to the strategy: buy-and-hold is never charged.

## Definition

Transaction costs are what a strategy pays each time it buys or sells: commissions, the bid-ask spread and the price impact of the trade. Backtests usually express them as a one-way cost in basis points, hundredths of a percent of the amount traded, charged on every entry and every exit, so their total grows with how often the strategy trades.

Also known as: trading costs, basis points, bps, commissions and slippage, bid-ask spread, turnover cost, cost drag, round-trip cost.

## How it works

Every trade costs something. A broker may charge a commission; the order crosses the bid-ask spread, buying at the ask and selling at the bid; a large order moves the price against itself. Backtests fold all of this into one number, a one-way cost in basis points. One basis point is one hundredth of a percent, so a cost of ten basis points takes a tenth of a percent of the amount traded on each purchase and again on each sale.

The arithmetic is simple and unforgiving. A round trip pays the one-way cost twice, and a rule pays it on every round trip, year after year, compounding. A slow trend rule with one round trip a year barely notices ten basis points. A fast rule with dozens of round trips a year pays the same cost dozens of times over, and the total can exceed what the rule earned before costs.

Transaction costs are like a toll on a bridge: someone who crosses once a year never thinks about it, while a commuter who crosses twice a day can end up paying more in tolls than in fuel.

The right number depends on the instrument and the trader. For the most heavily traded ETFs, such as SPY, the quoted spread is a small fraction of a basis point and many brokers charge no commission, so a few basis points one way covers a small order in normal markets. Less liquid funds, single stocks, large orders and stressed markets cost much more, and spreads widen exactly on the volatile days when fast rules trade most. Choosing a cost is part of the test: a rule that only works at zero cost has not been shown to work.

Costs also change which settings look attractive. Optimising a rule on a history without costs favours the settings that trade most, because fast settings can fit noise; adding costs to the search pushes it toward slower settings that keep more of what they earn. MarketHeist's robustness pages charge a fixed cost throughout and show how the verdict moves with a cheaper and a dearer setting.

## Formula

**Cost charged on bar t, and the strategy's return after costs**

```
c_t = κ |q_t - q_{t - 1}|, κ = \frac{bps}{10000}, r_t^{strat} = q_t r_t - c_t
```

where:

- qₜ: the position held over bar t, after the execution delay (1 = invested, 0 = cash)
- rₜ: the asset's close-to-close return over bar t
- κ: one-way cost as a fraction of the amount traded
- bps: the one-way cost in basis points (1 basis point = 0.0001)
- cₜ: the cost charged on bar t: κ on an entry, κ on an exit, 0 when the position does not change

On the first bar of the backtest the strategy pays κ times its starting position, as if buying in. The exit cost falls on the first bar in cash, so a round trip pays 2κ in all.

**Rule of thumb for the yearly drag**

```
g_κ \approx g_0 - 2 κ N (1 + g_0)
```

where:

- g₀: the strategy's compound annual growth rate before costs
- g_κ: its compound annual growth rate at one-way cost κ
- N: round trips per year

Each round trip multiplies wealth by about (1 − κ)², so N round trips a year multiply yearly growth by about 1 − 2κN. The approximation holds while 2κN is small.

## Worked example

SPY's daily bars from Oct 2006 to Sep 2026, about 20 years, with a fast rule: hold SPY while its close is above its 10-day simple moving average, otherwise cash, acted on with the standard one-bar delay. The same trades are then charged 0, 5, 10 and 25 basis points one way.

The rule completed 437 round trips, 21.9 a year, holding SPY on 63.4% of days. Before costs it grew 4.3% a year, against 11.1% for holding SPY, which pays no trading costs in the test.

Each step up in cost took more: 2.0% a year at 5 basis points, -0.2% at 10 and -6.6% at 25. The Sharpe ratio went from 0.41 before costs to -0.51 at 25 basis points, and $10,000 grew to $23,003 before costs and to $2,583 at 25 basis points.

The drop follows the rule of thumb. With 21.9 round trips a year, each paying 25 basis points on the way in and again on the way out, the yearly cost comes close to the gap between 4.3% and -6.6%.

Whether 25 basis points is realistic depends on who trades and what. A small order in SPY with a commission-free broker pays far less in normal markets; a large order, a thinly traded fund or a panicky day can pay as much or more. A slow rule such as the golden cross trades only a few times a decade and barely notices any of these levels. The robustness pages charge 5 basis points one way throughout.

Data through Sep 2026. Reproduce id: 8808f16300236eae (this guide, its lab setup and the data month).

## How MarketHeist computes it

- **Data**: Daily bars (open, high, low, close, volume) of the fund as the MarketHeist data service serves them to the backtester: prices adjusted for splits and dividends, so a dividend counts as reinvested. They come from a snapshot taken each month and cut at the data month of this page, and are not rounded. The fund's own history, not an extension: a fund younger than the window is measured over the years it has.
- **Window**: The worked example and the lab measure the last 20 years of trading days, Oct 2006 to Sep 2026 (5030 days), ending at the data month of this page. Every setup, and buy and hold, is measured over exactly these days; an indicator is warmed up on the days before them, so changing a setting never moves the window, and a setting that needs more history than exists before the window is refused rather than measured over fewer days.
- **Backtest**: The backtester's own engine, in the order it runs it: the indicator, the position rule (or entry and exit triggers) and the optional regime filter produce a position for every day of the fund's whole history; the position is then shifted forward by the execution delay and applied to each day's return over the window. Cash earns 0, there is no leverage, and a one-way cost in basis points is charged on the size of every change of position. Round trips are the closed entries of the trade log (a trade still open on the last day is not counted); the win rate is the share of them with a gain; the payoff ratio is the average win over the size of the average loss; expectancy is the average return per trade; the per-trade profit factor is the sum of the winning trades' returns over the size of the sum of the losing ones, while the per-day profit factor sums days.
- **Years and volatility**: A year is 252 trading days, the engine's convention: trades per year is round trips over days divided by 252, the CAGR is the growth multiple to the power 252 over the days, and volatility is the sample standard deviation of the daily returns times the square root of 252.
- **Indicator statistics**: The indicator's main output over the window: its last value, its 10th, 50th and 90th percentile (linear interpolation between ranks), and the share of days the rule alone says long, before the delay and any regime filter. Every output of the indicator is also summarized by its median and the share of days below 0.
- **Buy and hold**: The fund held every day of the window with dividends reinvested. The largest one-day gain and loss are the highest and lowest daily returns; the CAGR without the 10 or 30 largest gains (or losses) replaces those days' returns with 0 and recompounds.
- **Cost model**: One-way cost = bps ÷ 10,000 × |change in position|, subtracted from that bar's strategy return. A full entry or exit pays the cost once; a partial change (advanced mode) pays in proportion. If the backtest starts invested, the first bar pays for the initial purchase. (`runBacktest` in packages/shared/engine/backtest.ts)
- **Which bar pays**: The bar where the delayed position changes. On an entry bar the strategy earns the bar's return minus the cost; the exit cost lands on the first bar in cash, whose return is minus the cost. (`runBacktest` in packages/shared/engine/backtest.ts)
- **Trade log**: A trade's return runs from the equity just before entry to the last invested bar, so it includes the entry cost but not the exit cost, which falls on the next bar. Growth, drawdown, Sharpe ratio and the other metrics include both. (`computeTradeLog` in packages/shared/engine/backtest.ts)
- **Buy-and-hold**: Never charged, not even for the initial purchase: the comparison line is the fund's total return.
- **Leverage**: Costs are deducted before leverage is applied, and the cost-adjusted return is then multiplied by the leverage, so a leveraged strategy pays costs in proportion to its exposure. (`resolveLeverage` in packages/shared/engine/backtest.ts)
- **Not modelled**: Spreads that widen in volatile markets, market impact that grows with order size, minimum commissions, taxes on realised gains, and interest on cash. The one number stands in for all trading frictions.
- **Engine functions**: `computePosition` (packages/shared/engine/run_basic.ts), `generatePosition` (packages/shared/engine/positions.ts), `applyRegimeFilter` (packages/shared/engine/regime_filter.ts), `generateTriggeredPosition` (packages/shared/engine/triggered_position.ts), `runBacktest` (packages/shared/engine/backtest.ts), `getIndicator` (packages/shared/engine/indicators/registry.ts)

## Transaction costs in basis points compared with its neighbours

What a one-way cost in basis points stands in for

| Cost | What it is | Grows with | In the cost setting |
| --- | --- | --- | --- |
| Commission | The broker's fee per order | Number of orders; often zero for ETFs today | Included if you add it |
| Bid-ask spread | Buying at the ask and selling at the bid | Illiquidity and volatility | Half the spread is the usual one-way estimate |
| Slippage | The gap between the price the signal used and the fill | Speed of the market, delay in sending the order | Included if you add it |
| Market impact | The price moving against a large order | Order size relative to daily volume | Not scaled by size; one flat rate |
| Taxes | Tax on gains realised at each exit | Turnover and the account's tax status | Not modelled |
| Financing | Interest on borrowed money for leverage | Leverage and interest rates | Not modelled |

## Limitations

- One flat rate for every trade. Real costs vary with market conditions and order size, and they are usually highest on the volatile days when fast rules trade most.
- The example uses a deliberately fast rule to make the drag visible. Slow rules lose far less to the same cost per trade, so the size of the gap here is not typical of trend-following in general.
- Taxes are ignored. In a taxable account each exit can realise gains, which can cost more than commissions and spreads combined.
- Cash earns nothing in the backtester's example, which understates a rule that sits in cash during years of high interest rates.
- One fund, one window. A cost that looks small on SPY can be large on a thinly traded fund or a single stock.

## Frequently asked questions

**What is a basis point?**

One hundredth of a percent. One hundred basis points make one percent, so a cost of five basis points on a purchase of ten thousand dollars is five dollars. Costs, fees and interest-rate changes are often quoted in basis points because the numbers are small.

**What cost in basis points is realistic for an ETF backtest?**

For a small order in a heavily traded ETF such as SPY, a few basis points one way covers the spread and any commission in normal markets. Less liquid funds, larger orders, stressed markets and single stocks justify much more. Running the backtest at several cost levels shows how much the conclusion depends on the choice.

**What is the difference between one-way and round-trip costs?**

A one-way cost is paid on a single purchase or sale. A round trip, buying and later selling, pays it twice. MarketHeist's setting is one way, charged on every entry and every exit.

**Why is buy-and-hold not charged any cost?**

It is the reference line, the fund's total return over the same days. Buy-and-hold trades once, so its cost is negligible over any long window, and leaving it uncharged keeps it identical to the fund's published total return.

**Do costs change which settings of a rule look strongest?**

Yes. Without costs, a search over settings tends to favour fast settings that trade often; with costs, those settings pay the most, and slower settings that trade less move up the ranking. Testing settings with realistic costs from the start avoids choosing a setting that only works for free.

## References

1. Perold, A. F. (1988) The Implementation Shortfall: Paper versus Reality. Journal of Portfolio Management 14(3). The gap between a paper portfolio and what trading actually delivers.
2. Novy-Marx, R. and Velikov, M. (2016) A Taxonomy of Anomalies and Their Trading Costs. Review of Financial Studies 29(1). How turnover and costs erase high-frequency strategies' returns.
3. Siegel, J. J. (1994) Stocks for the Long Run. McGraw-Hill. A 200-day moving-average rule tested with and without transaction costs.

## Try it

App: https://marketheist.io/backtest/?c=eyJ0aWNrZXIiOiJTUFkiLCJmcmVxdWVuY3kiOiIxZCIsImluZGljYXRvcl9pZCI6Im1hX2Nyb3Nzb3ZlciIsImluZGljYXRvcl9wYXJhbXMiOnsic2hvcnRfd2luZG93IjoxLCJsb25nX3dpbmRvdyI6MTAsIm1hX3R5cGUiOiJTTUEifSwicG9zaXRpb25fcnVsZSI6eyJ0eXBlIjoidGhyZXNob2xkIiwidGhyZXNob2xkIjoxLCJkaXJlY3Rpb24iOiJhYm92ZSJ9LCJleGVjdXRpb25fZGVsYXkiOjEsInRyYW5zYWN0aW9uX2Nvc3RzX2JwcyI6MCwibGV2ZXJhZ2UiOnsibW9kZSI6Im5vbmUifX0

MCP prompt (MarketHeist MCP server, https://marketheist.io/mcp):

```
Using MarketHeist.io, backtest SPY on daily bars holding while the close is above its 10-day simple moving average (ma_crossover, short window 1, long window 10, threshold 1.0, execution delay 1) at 0, 5, 10 and 25 basis points of one-way transaction cost, and show how CAGR and the Sharpe ratio fall as costs rise.
```

Historical simulation, not advice.
