Transaction costs in backtests: basis points, turnover and drag

On this page

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
ct=κ|qt−qt−1|,κ=bps10000,rtstrat=qtrt−ct
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κ≈g0−2κN(1+g0)
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).

Interactive lab

Growth of $10,000 for the same trades at each cost level against buy-and-hold, with the results table. Change the cost, the moving-average length (longer averages trade less), the delay or the fund.

SPY price with the days the base rule held itS&P 500, adjusted daily close, Oct 2006 to Sep 2026, log scale. Shaded: the 437 stretches the base rule held the fund (63% of 5030 days). Also drawn: 10-day simple average.$50$100$200$50020062011201620212026SPY adjusted close10-day simple averageHeld by the base rule
SPY on a log scale. Shaded: the days the base rule held the fund. Oct 2006 to Sep 2026.
Short / long average ratio with the base rule's lineShort / long average ratio on SPY, Oct 2006 to Sep 2026. The rule compares it with the fixed line 1.0.860.880.90.920.940.960.9811.021.041.061.08200620112016202120261Short / long average ratio
Short / long average ratio and the line the base rule compares it with. Oct 2006 to Sep 2026.
Growth of $10,000: the setups against buy and holdS&P 500, Oct 2006 to Sep 2026, log scale. $10,000 grows to $23,003 (base), $14,860 (5 bps one way), $9,598 (10 bps one way), $2,583 (25 bps one way), $82,292 (buy and hold).$5k$10k$20k$50k20062011201620212026Base rule5 bps one way10 bps one way25 bps one wayBuy and hold
Growth of $10,000 on a log scale, same days for every line. Oct 2006 to Sep 2026.
MeasureBase5 bps one way10 bps one way25 bps one wayBuy and hold
CAGR4.3%2.0%-0.2%-6.6%11.1%
Volatility (annualized)11.8%11.8%11.8%11.9%19.4%
Maximum drawdown-43.0%-45.3%-49.9%-76.7%-55.2%
Sharpe ratio0.410.230.04-0.510.64
Sortino ratio0.560.310.06-0.67n/a
Growth of $10,000$23,003$14,860$9,598$2,583$82,292
Time in the market63.4%63.4%63.4%63.4%100.0%
Round trips437437437437n/a
Round trips per year21.921.921.921.9n/a
Win rate37.8%37.3%36.6%34.1%n/a
Average win2.5%2.5%2.5%2.5%n/a
Average loss-1.2%-1.2%-1.2%-1.3%n/a
Payoff ratio2.152.062.001.87n/a
Average days held7.37.37.37.3n/a
Expectancy per trade0.2%0.2%0.1%-0.0%n/a
Profit factor, per day1.101.061.010.891.13
Profit factor, per trade1.301.231.150.97n/a
Indicator, last day0.9950.9950.9950.995n/a
Indicator, 10th / 50th / 90th percentile0.981 / 1.004 / 1.020.981 / 1.004 / 1.020.981 / 1.004 / 1.020.981 / 1.004 / 1.02n/a
Days the rule alone is long63.4%63.4%63.4%63.4%n/a

S&P 500, Oct 2006 to Sep 2026, 5030 trading days. Every setup is measured over the same days, with the indicator warmed up on earlier ones; cash earns 0. Base: MA Crossover (short window 1, long window 10, ma type SMA); long while the Short / long average ratio is above 1; execution delay 1; cost 0 bps one way. 5 bps one way: MA Crossover (short window 1, long window 10, ma type SMA); long while the Short / long average ratio is above 1; execution delay 1; cost 5 bps one way. 10 bps one way: MA Crossover (short window 1, long window 10, ma type SMA); long while the Short / long average ratio is above 1; execution delay 1; cost 10 bps one way. 25 bps one way: MA Crossover (short window 1, long window 10, ma type SMA); long while the Short / long average ratio is above 1; execution delay 1; cost 25 bps one way.

Buy and hold, same daysValue
Largest one-day gain14.5% on 13 Oct 2008
Largest one-day loss-10.9% on 16 Mar 2020
CAGR without the 10 largest gains6.6%
CAGR without the 30 largest gains1.8%
CAGR without the 10 largest losses16.0%
CAGR without the 30 largest losses22.1%

The days replaced by 0 are the largest daily gains (or losses) of the window.

How MarketHeist computes it

Every choice an implementation has to make, as the code makes it today. The page is checked against the code each time it is built.

ChoiceHow it is computedIn the code
DataDaily 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.
WindowThe 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.
BacktestThe 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 volatilityA 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 statisticsThe 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 holdThe 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 modelOne-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.runBacktestpackages/shared/engine/backtest.ts
Which bar paysThe 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.runBacktestpackages/shared/engine/backtest.ts
Trade logA 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.computeTradeLogpackages/shared/engine/backtest.ts
Buy-and-holdNever charged, not even for the initial purchase: the comparison line is the fund's total return.
LeverageCosts 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.resolveLeveragepackages/shared/engine/backtest.ts
Not modelledSpreads 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 functionsThe functions the portfolio app and the MarketHeist MCP tools run, called here on the same monthly returns.computePositionpackages/shared/engine/run_basic.tsgeneratePositionpackages/shared/engine/positions.tsapplyRegimeFilterpackages/shared/engine/regime_filter.tsgenerateTriggeredPositionpackages/shared/engine/triggered_position.tsrunBacktestpackages/shared/engine/backtest.tsgetIndicatorpackages/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
CostWhat it isGrows withIn the cost setting
CommissionThe broker's fee per orderNumber of orders; often zero for ETFs todayIncluded if you add it
Bid-ask spreadBuying at the ask and selling at the bidIlliquidity and volatilityHalf the spread is the usual one-way estimate
SlippageThe gap between the price the signal used and the fillSpeed of the market, delay in sending the orderIncluded if you add it
Market impactThe price moving against a large orderOrder size relative to daily volumeNot scaled by size; one flat rate
TaxesTax on gains realised at each exitTurnover and the account's tax statusNot modelled
FinancingInterest on borrowed money for leverageLeverage and interest ratesNot 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 on your own holdings

Open the backtester and set a transaction cost →

Or ask an assistant connected to the MarketHeist MCP server (https://marketheist.io/mcp), which computes the same figures:

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.

Ask an AI assistant

The prompt opens in a new tab, already filled in. An assistant without the MarketHeist connector answers from its own knowledge, not from the figures on this page.

Historical simulation, not advice. Computed by the MarketHeist portfolio engine from monthly total returns, data through Sep 2026. Markdown version of this page: transaction-costs.md.