Module contents
Stage 4 of 9Advanced 100 min

Transaction costs, market impact and capacity

Add a cost model with commission, half-spread estimated from daily data, slippage, and square-root impact as a function of volume participation. Calculate each strategy's break-even cost and capacity, and examine how costs affect gross Sharpe.

After this lesson you can

  • Estimate the effective spread from daily data using a published estimator.
  • Implement square-root impact and calibrate its coefficient with explicit assumptions.
  • Calculate break-even cost and net Sharpe as a function of managed capital.
  • Reduce turnover with no-trade bands and measure the net improvement.

Before you start

Every trade consumes edge

A strategy can have a predictive signal and still lose after paying to trade. The transaction cost model distinguishes commission, half-spread, additional slippage, and impact. Each component must be expressed per unit of traded notional and counted once. If the execution price already includes the spread, subtracting it again would double-count the cost.

Suppose the mid-price is 100, the purchase ask is 100.05, and the sale bid is 99.95. The full spread is 0.10%, or 10 basis points; paying half-spread costs 5 bp on each leg relative to the mid-price. A round trip costs approximately 10 bp of one leg’s notional before commission and impact. Comparing a full-spread measure with a per-trade cost without dividing by two creates a factor-of-two error.

Commission is an explicit fee; spread represents the separation between quotes; additional slippage captures deviations not included in the other terms. Impact models how price changes when consuming liquidity. In real data the categories can overlap and require a defined reference and horizon. Here we treat them as hypothetical additive terms and charge the cost on both purchases and sales.

For example, changing a position by 10,000 currency units with a 10 bp full spread, 1 bp commission, and 1 bp additional slippage costs 7 units before impact: 10,000 times 7/10,000. If average impact were another 3 bp, the total would be 10 units. This sum is charged on notional actually changed, not on the entire portfolio value. An unfilled order does not pay this fill cost, though it may have opportunity costs the model omits.

One fixed cost for every asset hides differences in price, volume, and trading hours. Even for one asset, a volatile open can differ from a quiet session. The model allows different parameters per trade, although the later experiment holds them fixed to isolate size and turnover. An extension must lag liquidity and volatility estimates to avoid using the day’s final volume when deciding an order sent at the start.

InteractiveCapital, costs, and Sharpe

Hypothetical aggregate example: ADV 50 million, daily asset volatility 2%, annual gross returns 10% and 18%, portfolio volatilities 12% and 16%, annual turnovers 15 and 100. Fixed portfolio volatility, zero risk-free rate; the typical trade is capital × turnover / 252.

■ Momentum · ■ Reversal · logarithmic horizontal scale: 0.1 to 1000 million; vertical curve limited to Sharpe between −4 and 3.

Break-even is where mean net return reaches zero; capacity depends on these assumptions and excludes execution constraints, taxes, and financing.

10.00 M
10
2
0.5
1.0
Momentum Sharpe0.61
Momentum break-even299.05 M
Reversal Sharpe−1.07
Reversal break-even1.52 M
Two hypothetical strategies with different turnover; the calculation assumes fixed volatility and one average daily trade.

The figure uses preset returns, volatilities, and turnover rather than market estimates. Higher turnover multiplies cost per unit of capital; more capital increases participation and impact. The crossing is the capital at which annual net mean reaches zero under these assumptions. It is not a universal capacity or guaranteed execution limit.

A spread from highs and lows

Without intraday quotes, Corwin and Schultz propose estimating spread from two-session ranges. The method separates approximate spread and volatility contributions using how the range changes when the window widens. It is an estimator under assumptions, not the effective spread of a particular order.

For highs and lows adjusted for the gap between sessions, let

β=log⁡2(Ht/Lt)+log⁡2(Ht+1/Lt+1),γ=log⁡2(max⁡(Ht,Ht+1)min⁡(Lt,Lt+1)).\beta=\log^2(H_t/L_t)+\log^2(H_{t+1}/L_{t+1}),\quad \gamma=\log^2\left(\frac{\max(H_t,H_{t+1})}{\min(L_t,L_{t+1})}\right).

With d=3−22d=3-2\sqrt2, calculate

α=2β−βd−γd,S^=2tanh⁡(max⁡(α,0)/2).\alpha=\frac{\sqrt{2\beta}-\sqrt{\beta}}{d}-\sqrt{\frac{\gamma}{d}}, \qquad \widehat S=2\tanh(\max(\alpha,0)/2).

The result is the full spread relative to the midpoint. The code corrects the gap if the entire second-day range lies above or below the previous close; it truncates negative two-day estimates to zero before aggregation. That convention introduces bias, and other aggregation methods can differ. The estimate for the pair including session t+1t+1 is available only after that session ends and must not be used to execute during it.

For three synthetic bars in the lab, the estimates are 0 and approximately 111.7 bp for the two available pairs. The value represents no company and does not establish accuracy: a bar does not directly report the quote, size, or price our order would receive. Splits, bad data, sessions without trades, and large gaps can distort ranges. In a real study, compare aggregate estimates with independent quotes or executions and use lagged information.

Zero also needs careful interpretation. A negative estimate is truncated, so zero may mean the formula did not distinguish a positive spread for that two-day pair. It does not mean trading was free. With noisy data, report the proportion of zeros, number of observations, and sensitivity to the truncation rule as well as the mean. A window that is too short can fluctuate greatly; one that is too long may respond late to a liquidity change.

Impact and participation

The empirical square-root impact law is written here as

I=YσdıˊaQ/ADV,I=Y\sigma_{\mathrm{día}}\sqrt{Q/\mathrm{ADV}},

where QQ and ADV are notionals in the same currency, σ\sigma is daily volatility as a fraction, and YY is a dimensionless coefficient. With 2% daily volatility, 5% participation, and Y=1Y=1, impact is 0.020.05=0.0044720.02\sqrt{0.05}=0.004472, about 44.72 bp. Gómez and colleagues study metaorder impact and its relationship to size and volume. The formula is an empirical approximation, not an exact law for every trade.

We apply II as average cost per executed dollar, added to half-spread and fees. This is a deliberate convention: some studies report final impact instead of average execution cost, and the two can differ. The lab fixes Y=0,5Y=0,5 as an illustrative assumption, without calibrating it on the same strategy results. Calibrating it in an application would require independent reserved fills, defined duration, participation and benchmark, uncertainty measurement, and stability checks across assets and regimes.

Do not extrapolate without limit. A large order can exceed available volume, require several days, change volatility, or violate constraints; the square root alone does not ensure execution. The example calculates costs even at high participation to show sensitivity, but does not apply an operational capacity limit or represent the order queue.

If an order is split across sessions, simply adding independent impacts requires justification of how liquidity recovers and how much movement persists. A maximum participation rule per session would limit each fill and might leave a position pending; the signal could change before the order is completed. That delay has an opportunity cost this static formula does not model.

Break-even cost and bands

The relationship between turnover and capacity starts with a simple identity. If annual gross return is 8% and total notional changed is 20 times capital per year, a fixed cost of cc per traded dollar leaves 0.08−20c0.08-20c. Break-even is c=0.004c=0.004, or 40 bp per unit of turnover. This assumes constant return and turnover and applies cost to the sum of purchases and sales. It excludes variable impact per trade.

A band of width bb retains the current weight when ∣w∗−w∣≤b|w^*-w|\le b and jumps to the target when outside. It can avoid small adjustments but introduces deviation from the signal. It does not guarantee preservation of average weight, reduced risk, or improved net return in every sample. Some rules move only to the edge of the band; the lab uses the full-jump rule so the calculation is verifiable.

With target 0.55, position 0.50, and band 0.10, no trade occurs. If the target rises to 0.70, the distance exceeds the band and the weight jumps to 0.70. The first saving is a 0.05 change that is not traded; the second move still pays cost on 0.20. The later path depends on the retained weight, so savings cannot be measured by subtracting a single isolated trade from a frequently rebalanced portfolio.

Reducing turnover is a decision coupled to the signal. A band that is too wide retains obsolete positions; a narrow one may save little. Width should be selected using training or validation data and then evaluated on another sample. Exploring many widths and publishing only the best adds selection. This lab’s comparison uses one width chosen beforehand and a synthetic sample, without claiming robustness outside it.

Local laboratory

Download p01cost.py, p01cost_lab.py, and test_p01cost.py, together with p01events.py and p01vector.py. You need NumPy, pandas, and pytest. The vectorized model deducts cost on each weight change; the event adapter records it as a fill commission. A test compares both with fixed prices and equal notional.

The following signals and returns are artificial: return includes a small component in the known position’s direction and noise generated with a fixed seed. They are constructed to study cost mechanics, not to validate real momentum or reversal. ADV of 50 million, daily volatility 2%, full spread 10 bp, commission and slippage of 1 bp each, and impact Y=0,5Y=0,5 are hypothetical parameters. Cost per trade uses the absolute weight change times fixed capital; capital is not updated to calculate size. Sharpe is the mean divided by sample standard deviation, multiplied by 252\sqrt{252}, with zero risk-free rate.

[ ]Costs, bands, and capacityLocal GPU
import os,sys
from pathlib import Path
import pytest
lib=Path(os.environ.get('P01_LIB_DIR','.')).resolve()
if not (lib/'p01cost.py').exists(): raise FileNotFoundError('Descarga los módulos y pruebas en P01_LIB_DIR')
sys.path.insert(0,str(lib))
from p01cost_lab import experiment
os.environ['PYTEST_DISABLE_PLUGIN_AUTOLOAD']='1'
status=pytest.main([str(lib/'test_p01cost.py'),'-q','-p','no:cacheprovider'])
assert status==0
experiment()
This cell needs the local lab (PyTorch with your GPU). Start it with npm run lab and open the connection link.

In the verified run, with capital of one million, the 0.1 band reduces annual momentum turnover from 14.88 to 8.63 and raises net Sharpe from 1.077 to 1.145; average target weight changes from −0.0670 to −0.0699. For reversal, turnover drops from 105.64 to 100.97 and net Sharpe improves from −1.576 to −1.513, remaining negative. Estimated break-even capitals for the sample are approximately 55.2 and 76.4 million for momentum without and with the band, and 9055 and 15,217 for reversal. These are roots of the net mean in this experiment, not empirical capacities; high capital can imply participation that invalidates the model.

Results also depend on noise and the window. The calculation omits borrowing costs, liquidity constraints, financing, taxes, and changes in capital, and does not separate training from test. The band’s apparent improvement does not establish a general rule. A practical simulation should construct weights and returns from causal data, record every trade, and compare estimates with out-of-sample executions.

Exercises

NumericParticipation and impact
With daily volatility of 2%, participation of 5%, and coefficient Y = 1, what is the impact in basis points?
NumericFixed break-even cost
With annual gross return 8% and annual turnover 20, what cost per traded notional brings net return to zero, in bp?
CodeA simple band
Implement no_trade_band(target,current,width): retain current if the absolute difference is less than or equal to width; otherwise return target. Width is nonnegative.
def no_trade_band(target,current,width):
  raise NotImplementedError()
Shift+Enter to run
QuizCost sensitivity
If two strategies have similar gross returns per unit of capital, why might the more frequently reversing one be more sensitive to costs?

What to remember

Key idea
Break-even cost connects edge and turnover; capacity adds size, liquidity, and independent calibration that must be subjected to sensitivity analysis.