← Quantery Blog

How to stress-test backtest trading costs

September 29, 2026 · 9 min readbacktestingtrading-costsresearch-method

Stress-test trading costs by leaving the thesis fixed and applying a range of plausible costs to every simulated purchase and sale. Run the same test under a slower rebalance schedule and a stricter liquidity floor. If a modest cost assumption or one nearby implementation choice erases the result, the backtest hasn't found a durable edge yet. It has found a gross return that depends on cheap execution.

Trading costs are the difference between the frictionless price assumed by a model and the economic result a researcher could have kept after implementing its trades. Commissions are only the visible part. Bid-ask spreads, slippage, and market impact can matter more. Quantery backtests are hypothetical and exclude these costs, so the report is a starting record of the rules. The cost test comes next.

Which trading costs does a backtest leave out?

Start with the bill you are trying to approximate.

Commission is the explicit fee charged for an order. A zero-commission account hasn't made the rest of the bill disappear.

Bid-ask spread is the gap between the highest price currently offered by a buyer and the lowest price accepted by a seller. A market purchase tends to meet the ask; a market sale tends to meet the bid. Crossing that gap on both sides creates a round-trip cost even when the quoted price never moves. The SEC's Trading Basics guide explains the bid, ask, spread, and why a market order promises execution without guaranteeing a particular price.

Slippage is the gap between the price used in the research record and the price actually received. The next closing price in a backtest is a reproducible convention. It isn't a promise that an order could fill at that exact print. News, a fast market, or a thin order book can move the executable price before or during the trade.

Market impact is the price movement caused by the order itself. A small order in a heavily traded company may leave little trace. A larger order in a company with light volume can consume the available quotes and push the later pieces of the order to worse prices.

Taxes and borrowing charges belong to particular accounts or strategies. They matter, but don't hide them inside the same haircut if the thesis doesn't use short positions and the research question is pre-tax. Name each omission separately.

FINRA notes that a fund's portfolio purchases and sales incur transaction fees outside the expense ratio, and that more buying and selling can produce higher costs (its explanation of fund fees and turnover). The same mechanism applies to a rules-based stock test. The bill follows the trades, so you need to know what generates them.

Turnover connects the signal to the bill

Turnover measures how much of a portfolio is replaced over a period. A strategy can rebalance monthly without trading the whole portfolio monthly. If every company keeps passing, the evaluation clock ticks and no replacement is needed. A hard gate near a moving cutoff can do the reverse: small changes repeatedly push companies out and pull them back in.

That distinction is why you shouldn't invent turnover from the rebalance label. The current Quantery report doesn't expose a complete position ledger or transaction-turnover series. Its event list can reveal repeat qualifications, but a qualification event isn't a trade count. Say what the report can show, then stop.

Use the available evidence as a warning system:

Rebalance cadence controls when the thesis can observe a change. It doesn't tell you how many trades followed. Likewise, an exit-rule test separates the selection rule from the selling rule. Run those tests before assigning a precise cost bill to behavior the report hasn't measured.

The empirical record is a useful restraint here. Barber and Odean studied brokerage accounts held by 66,465 households from January 1991 through November 1996. The average household earned 18.7 percent a year before trading costs and 16.4 percent after them; the most active fifth earned 11.4 percent net. Those are historical sample results. They don't estimate the cost of your thesis. Their value is the mechanism: trading can leave gross selection skill looking much better than the return retained after execution (the published paper).

A liquidity gate is an implementation assumption

Liquidity is the ability to trade without conceding much price or waiting a long time. A screen needs a proxy because historical quotes and your intended order size may not be available in the fundamentals record.

Quantery's Greenblatt Magic Formula and Earnings Yield + Quality templates use dollar volume, average daily share volume multiplied by price. It asks how much stock changes hands in an ordinary day, in dollars. That makes it more comparable across a low-priced stock and a high-priced stock than share volume alone.

The shape below is illustrative. The bundled templates and Quantery's DSL reference are the reference for exact fields.

# Liquidity belongs beside the economic signal, illustrative only
params:
  min_dollar_volume: 5000000

features:
  dollar_volume: avg_volume * price

criteria:
  tradeable:
    rules:
      - { when: "is_null(dollar_volume)", score: 0, flag: no_volume }
      - { when: "dollar_volume >= $min_dollar_volume * 4", score: 2 }
      - { when: "dollar_volume >= $min_dollar_volume", score: 1 }
      - { else: 0 }

gate:
  mode: strict

The threshold is a proposed parameter. It isn't a factual line between tradable and untradable. Capacity depends on intended position size, urgency, order type, and the order book available on the day. Average dollar volume also misses the spread. A company can clear the gate and still be expensive to enter during stress.

Treat the floor as a sensitivity test. Keep the business rules fixed, raise the liquidity requirement, and rerun the same window. If the result survives while the eligible set becomes easier to trade, the economic signal has cleared one implementation challenge. If performance lives only below the original floor, the thesis may be a liquidity exposure wearing a valuation label.

Don't declare the stricter run superior just because it is easier to implement. Raising the floor changes the universe, often shifting it toward larger companies. Compare against the same benchmark first, then test whether size explains the difference. The screening universe is part of the thesis, and a liquidity edit changes that thesis.

How should you build a cost sensitivity grid?

A cost sensitivity grid applies several assumed one-way cost rates to the same simulated trades. Each purchase and each sale receives the haircut, so a completed round trip pays twice. The assumptions are scenarios. No one observed those fills.

Start with a declared baseline. Keep the thesis version, universe, dates, benchmark, rebalance cadence, reporting lag, and exit policy unchanged. Export or reconstruct trades only if you can do so from a real position ledger. If that ledger isn't available, don't manufacture a net-return curve from qualification events. Use controlled reruns as qualitative pressure tests and record the limitation.

When you do have trades, choose several round cost assumptions suited to the selected securities. Keep them round. Include a low case, a working case, and a severe case. Then calculate the result after applying the chosen one-way haircut at entry and exit. Don't pick a single decimal because it preserves the conclusion.

The useful output is a break-even question: how expensive can implementation become before excess performance against the benchmark disappears? Compare that break-even allowance with the kind of stocks and trading behavior the thesis produces. A large, slow-moving universe can support a different range from thin companies selected by a weekly price gate.

A flat cost model still misses the shape of real execution. Spreads vary by company and date. Market impact grows with the order relative to available liquidity. Volatile periods often make both worse. A constant haircut is a stress knob. It doesn't reconstruct history.

Which reruns expose a cost-dependent result?

Use three controlled challenges, one at a time.

First, slow the observation clock. Compare weekly and monthly evaluation with the same holding rules. If the slower version preserves the direction of excess performance with fewer repeat qualifications, the claim may not need every fleeting crossing. If only the fast version works, timing and execution are now part of the hypothesis.

Second, disable exit on gate failure while keeping the maximum hold fixed. A gate that flickers can create repeated departures and re-entries. If the result collapses without immediate gate-fail exits, study whether fresh business evidence or a moving price ratio caused those exits. Don't award the entry signal credit for a result carried by the selling rule.

Third, raise the dollar-volume floor without adjusting the value or quality criteria. This asks whether the pattern extends into names where the same hypothetical position would represent less of ordinary trading. It doesn't estimate the spread, but it tests whether the apparent edge requires the least liquid corner of the original universe.

Read all three beside the event study and portfolio report. A backtest report separates qualification behavior from portfolio policy. Its returns remain hypothetical and exclude costs. You're looking for dependence: on fast observation, fast exits, or thin liquidity.

What would make the result worth another test?

A cost-aware result doesn't need to be unchanged under every harsh assumption. It does need room. Nearby implementation choices should preserve the broad direction, and the break-even cost shouldn't sit on top of the first plausible friction estimate.

Write the conclusion in parts:

That last line prevents false precision. A backtest without recorded transactions cannot support a precise turnover charge. It can still tell you whether the rules appear designed to churn and whether their result disappears when you remove the conditions most likely to make execution expensive.

Then take the surviving version to an untouched period. Don't use the cost grid to choose a flattering combination of cadence, gate, and liquidity floor on the same sample. That's another search, and a holdout period only works when you stop tuning before you open it.

Gross return is what the rules did in a frictionless research model. The next question is how much friction the result can bear. Make the liquidity floor, clock, and exit policy visible. Change them separately. Keep the version that still tells the same economic story after execution gets a vote.

Want to try this on your own rules? Quantery is free for 14 days: the full app, no card required.

← All articles