Passer au contenu
Tous les documents de la bibliothèque

Modéliser les coûts de transaction en trading

Article Machine Learning for Trading

Résumé

Ce chapitre traite les coûts de transaction comme une contrainte à toutes les étapes de la recherche et du déploiement d’une stratégie, de l’évaluation des facteurs et du backtesting à la construction du portefeuille, à la surveillance des risques et au suivi en production. Il distingue les frais explicites, le spread et l’impact implicites, ainsi que les limites de capacité, puis décrit des modèles de coûts de référence, des hypothèses de spread à l’impact linéaire et en racine carrée. Il explique aussi pourquoi les coûts varient selon la liquidité, la volatilité, le régime de marché, l’urgence et l’heure de la journée.

Les méthodes d’exécution telles que TWAP, VWAP, la participation adaptative et Almgren–Chriss sont présentées comme des moyens de gérer l’impact et le risque lié au timing en fonction de la dégradation du signal, et non d’éliminer les coûts. L’analyse des coûts de transaction utilise les exécutions réalisées pour décomposer le déficit d’exécution et recalibrer les hypothèses. Les garde-fous pratiques comprennent le seuil de rentabilité du taux de rotation, l’avantage minimal requis, la capacité et des critères prédéfinis d’arrêt d’une stratégie. Le chapitre présente des outils et des exemples pour différentes classes d’actifs, mais le calibrage des modèles dépend des données d’exécution disponibles ; de simples hypothèses de backtest peuvent induire en erreur si les conditions changent ou si la stratégie prend de l’ampleur.

Idées clés

  • Les coûts de transaction influent sur la viabilité d’une stratégie tout au long de la recherche et du déploiement.
  • Les coûts explicites, les coûts implicites et les contraintes de capacité exigent des choix de modélisation distincts.
  • Les spreads et l’impact de marché varient selon la liquidité, la volatilité, le régime, l’urgence et les tendances intrajournalières.
  • Les calendriers d’exécution gèrent les arbitrages entre impact, risque de timing et dégradation du signal.
  • L’analyse des coûts de transaction transforme les exécutions réalisées en retours d’information pour les modèles de coûts et les garde-fous des stratégies.

Étiquettes

Texte intégral
# Chapter 18: Transaction Costs


# Chapter 18: Transaction Costs

The chapter reframes transaction costs from a backtest adjustment into a workflow constraint that affects factor evaluation, simulation, portfolio construction, risk management, and production monitoring. Readers should care because it establishes the chapter's central claim: many strategies fail not because the forecast is wrong, but because the implementation problem was ignored.

## Learning Objectives

- Identify where transaction costs enter the ML4T workflow, from factor evaluation and backtesting to portfolio construction, risk management, and production monitoring
- Distinguish explicit, implicit, and capacity-related trading costs and map each component to the relevant modeling choice
- Explain why execution costs vary with market regime, intraday liquidity, volatility, and execution urgency
- Choose and calibrate baseline backtest cost models, from spread-based assumptions to linear and square-root impact models, using conservative research defaults when direct execution data is unavailable
- Compare common execution approaches, including TWAP, VWAP, adaptive participation, and Almgren-Chriss-style optimal execution, in terms of impact, timing risk, and signal decay
- Use transaction cost analysis to decompose realized costs, diagnose model misspecification, and recalibrate ex ante assumptions
- Apply break-even turnover, minimum required edge, alpha-to-go, capacity analysis, and precommitted kill criteria to decide whether a strategy remains economically viable after costs

## Sections

### 18.1 Where Costs Enter the ML4T Workflow

This section reframes transaction costs from a backtest adjustment into a workflow constraint that affects factor evaluation, simulation, portfolio construction, risk management, and production monitoring. Readers should care because it establishes the chapter's central claim: many strategies fail not because the forecast is wrong, but because the implementation problem was ignored.

- [`01_cost_taxonomy`](01_cost_taxonomy.ipynb) — This notebook maps the transaction cost landscape across our seven asset classes, comparing exchange fee structures, spread regimes, and the resulting breakeven alpha requirements for each case study. Uses cme_futures, crypto_perps, etfs and 3 more data.
- [`03_market_impact_calibration`](03_market_impact_calibration.ipynb) — This notebook calibrates market impact models using real market data, estimates Kyle's lambda from NASDAQ-100 trade classification data, maps intraday volume profiles, and estimates strategy capacity limits for each asset class. Uses cme_futures, crypto_perps, etfs and 5 more data.

### 18.2 A Cost Taxonomy for Practitioners

This section organizes costs into explicit, implicit, and capacity components and shows that each one demands a different modeling response. Its practical value is that it stops readers from collapsing everything into a vague slippage assumption and instead teaches them how to think about the actual sources of gross-to-net decay.

- [`01_cost_taxonomy`](01_cost_taxonomy.ipynb) — This notebook maps the transaction cost landscape across our seven asset classes, comparing exchange fee structures, spread regimes, and the resulting breakeven alpha requirements for each case study. Uses cme_futures, crypto_perps, etfs and 3 more data.
- [`02_spread_estimation`](02_spread_estimation.ipynb) — This notebook estimates bid-ask spreads from OHLCV data using two classical estimators, validates them against ground-truth microstructure data, and applies them across all seven asset classes. Uses cme_futures, crypto_perps, etfs and 5 more data.
- [`12_commission_slippage_comparison`](12_commission_slippage_comparison.ipynb) — Provides a side-by-side comparison of all 6 commission models and 5 slippage models in ml4t.backtest.models. We compute costs for identical trades across varying sizes, define 4 asset-class cost stacks, and measure the P&L sensitivity and frequency sensitivity of model choice.

### 18.3 The Microstructure Regime Link

This section explains why cost parameters are not stationary and must be conditioned on time of day, volatility, liquidity, and stress. It matters because even a well-designed cost model becomes dangerous when it treats crisis execution like normal execution or assumes that today's spread and depth are stable inputs.

- [`02_spread_estimation`](02_spread_estimation.ipynb) — This notebook estimates bid-ask spreads from OHLCV data using two classical estimators, validates them against ground-truth microstructure data, and applies them across all seven asset classes. Uses cme_futures, crypto_perps, etfs and 5 more data.
- [`03_market_impact_calibration`](03_market_impact_calibration.ipynb) — This notebook calibrates market impact models using real market data, estimates Kyle's lambda from NASDAQ-100 trade classification data, maps intraday volume profiles, and estimates strategy capacity limits for each asset class. Uses cme_futures, crypto_perps, etfs and 5 more data.

### 18.4 Baseline Backtesting Cost Models

This section gives readers a practical ladder of cost models, from spread-only assumptions to linear slippage and square-root impact. It is useful because it offers a concrete modeling toolkit for research backtests while making clear when simple models are acceptable, when they are too optimistic, and why conservative calibration is often the right default.

- [`03_market_impact_calibration`](03_market_impact_calibration.ipynb) — This notebook calibrates market impact models using real market data, estimates Kyle's lambda from NASDAQ-100 trade classification data, maps intraday volume profiles, and estimates strategy capacity limits for each asset class. Uses cme_futures, crypto_perps, etfs and 5 more data.
- [`06_ml4t_execution_demo`](06_ml4t_execution_demo.ipynb) — This notebook demonstrates the ml4t.backtest.execution module for realistic execution cost modeling. The library provides four market impact models: Uses etfs data.

### 18.5 Execution Algorithms as Controls, Not Magic

This section demystifies execution algorithms by presenting TWAP, VWAP, and regime-aware participation as ways to manage trade-offs rather than eliminate costs. Readers should care because it ties execution design back to signal half-life, urgency, and capacity, showing that execution choices are part of strategy design, not an afterthought left to a trading desk.

- [`04_vwap_twap_execution`](04_vwap_twap_execution.ipynb) — This notebook implements the two most common execution benchmarks: Uses synthetic data.
- [`07_ml4t_volume_participation`](07_ml4t_volume_participation.ipynb) — This notebook demonstrates VolumeParticipationLimit from ml4t.backtest.execution for realistic institutional order execution: Uses synthetic data.
- [`08_ml_dynamic_execution`](08_ml_dynamic_execution.ipynb) — This notebook explores how machine learning can be used to dynamically adapt execution strategies based on real-time market conditions. Instead of following a fixed VWAP/TWAP schedule, we use ML to predict optimal execution parameters.

### 18.6 Optimizing Execution with Almgren-Chriss as a Unifying Framework

This section introduces Almgren-Chriss as the cleanest framework for thinking about impact, timing risk, and urgency in one model. Its importance is less in deriving a perfect trading schedule than in giving readers a disciplined way to reason about execution feasibility and to connect portfolio intent with execution reality.

- [`05_almgren_chriss_optimal_execution`](05_almgren_chriss_optimal_execution.ipynb) — This notebook implements the seminal Almgren-Chriss (2001) framework for optimal trade execution. We derive the efficient frontier of execution strategies, compute optimal trajectories, and demonstrate Transaction Cost Analysis (TCA) methodology.

### 18.7 Transaction Cost Analysis and Model Validation

This section turns realized fills into model feedback through implementation shortfall, decomposition, regime-aware benchmarking, and calibration. It matters because it closes the loop: cost assumptions stop being static research inputs and become hypotheses that are tested, decomposed, and revised against live evidence.

- [`01_cost_taxonomy`](01_cost_taxonomy.ipynb) — This notebook maps the transaction cost landscape across our seven asset classes, comparing exchange fee structures, spread regimes, and the resulting breakeven alpha requirements for each case study. Uses cme_futures, crypto_perps, etfs and 3 more data.
- [`10_gross_vs_net_performance`](10_gross_vs_net_performance.ipynb) — This notebook provides a comprehensive framework for analyzing the gap between gross (theoretical) and net (realized) strategy performance. This is the ultimate reality check for any trading strategy.

### 18.8 Designing Practical Cost Guardrails

This section provides decision rules such as break-even turnover, minimum required edge, alpha-to-go, capacity analysis, and kill criteria. Readers should care because this is where the chapter becomes operational: it shows how to decide whether a strategy can be deployed, scaled, modified, or abandoned once trading frictions are treated honestly.

- [`03_market_impact_calibration`](03_market_impact_calibration.ipynb) — This notebook calibrates market impact models using real market data, estimates Kyle's lambda from NASDAQ-100 trade classification data, maps intraday volume profiles, and estimates strategy capacity limits for each asset class. Uses cme_futures, crypto_perps, etfs and 5 more data.
- [`09_frequency_tradeoff`](09_frequency_tradeoff.ipynb) — This notebook demonstrates the critical tradeoff between signal quality and transaction costs at different rebalancing frequencies. Uses synthetic data.
- [`10_gross_vs_net_performance`](10_gross_vs_net_performance.ipynb) — This notebook provides a comprehensive framework for analyzing the gap between gross (theoretical) and net (realized) strategy performance. This is the ultimate reality check for any trading strategy.
- [`11_cost_cliff`](11_cost_cliff.ipynb) — This notebook demonstrates the dramatic impact of transaction costs on intraday trading strategies. What looks like a stellar strategy on a gross basis often becomes unprofitable or marginal after realistic costs.

The cross-case-study cost-survival comparison lives in Chapter 20: see [`20_strategy_synthesis/06_cost_survival`](../20_strategy_synthesis/06_cost_survival.ipynb).

## Running the Notebooks

```bash
# From the repository root
uv run python 18_transaction_costs/<notebook>.py

# Test mode (reduced data via Papermill)
uv run pytest tests/test_chapter_notebooks.py -v -k "18_transaction_costs"
```

## References

- **Albert S. Kyle** (1985). [Continuous Auctions and Insider Trading](https://doi.org/10.2307/1913210). *Econometrica*.
- **Ananth Madhavan** (2002). [Market Microstructure: A Practitioner's Guide](https://www.jstor.org/stable/4480415). *Financial Analysts Journal*.
- **Andrea Frazzini et al.** (2018). [Trading Costs](https://doi.org/10.2139/ssrn.3229719).
- **Anna A. Obizhaeva and Jiang Wang** (2013). [Optimal trading strategy and supply/demand dynamics](https://doi.org/10.1016/j.finmar.2012.09.001). *Journal of Financial Markets*.
- **Bence Toth et al.** (2011). [Anomalous price impact and the critical nature of liquidity in financial markets](https://doi.org/10.1103/PhysRevX.1.021006). *Physical Review X*.
- **Christopher Schwarz et al.** (2022). [The 'Actual Retail Price' of Equity Trades](https://doi.org/10.2139/ssrn.4189239).
- **Damian Eduardo Taranto et al.** (2018). [Linear models for the impact of order flow on prices. I. History dependent impact models](https://doi.org/10.1080/14697688.2017.1395903). *Quantitative Finance*.
- **Dmitriy Muravyev and Neil D. Pearson** (2020). [Option Trading Costs Are Lower than You Think](https://doi.org/10.2139/ssrn.2580548).
- **Emilio Said** (2022). [Market Impact: Empirical Evidence, Theory and Practice](http://arxiv.org/abs/2205.07385).
- **Giuseppe A. Paleologo** (2025). The Elements of Quantitative Investing. *John Wiley & Sons*.
- **Hector Chan** (2022). [Market Impact Decay and Capacity](https://doi.org/10.3905/jpm.2022.1.382). *The Journal of Portfolio Management*.
- **James O'Donovan and Gloria Yang Yu** (2024). [A Transaction Cost Perspective on Option Anomalies](https://doi.org/10.2139/ssrn.4806038).
- **Jean-Philippe Bouchaud** (2022). [The inelastic market hypothesis: a microstructural interpretation](https://doi.org/10.1080/14697688.2022.2068052). *Quantitative Finance*.
- **Joel Hasbrouck** (1991). [Measuring the Information Content of Stock Trades](https://doi.org/10.2307/2328693). *The Journal of Finance*.
- **Marco Avellaneda and Sasha Stoikov** (2008). [High-frequency trading in a limit order book](https://doi.org/10.1080/14697680701381228). *Quantitative Finance*.
- **Nikolaus Hautsch and Ruihong Huang** (2012). [The market impact of a limit order](https://doi.org/10.1016/j.jedc.2011.09.012). *Journal of Economic Dynamics and Control*.
- **Nina Karnaukh et al.** (2015). [Understanding FX Liquidity](https://doi.org/10.2139/ssrn.2329738).
- **Rama Cont et al.** (2014). [The Price Impact of Order Book Events](https://doi.org/10.1093/jjfinec/nbt003). *Journal of Financial Econometrics*.
- **Robert Almgren and Neil Chriss** (2001). [Optimal execution of portfolio transactions](https://doi.org/10.21314/jor.2001.041). *The Journal of Risk*.
- **Ryan Donnelly** (2022). [Optimal Execution: A Review](https://doi.org/10.1080/1350486X.2022.2161588). *Applied Mathematical Finance*.
- **Steven L. Heston et al.** (2023). [Option Momentum](https://papers.ssrn.com/abstract=4113680).
- **Tarun Chordia et al.** (2000). [Commonality in liquidity](https://doi.org/10.1016/S0304-405X(99)00057-4). *Journal of Financial Economics*.
- **Thomas Ho and Hans R. Stoll** (1981). [Optimal dealer pricing under transactions and return uncertainty](https://doi.org/10.1016/0304-405X(81)90020-9). *Journal of Financial Economics*.
- **Xavier Gabaix and Ralph S. J. Koijen** (2021). [In Search of the Origins of Financial Fluctuations: The Inelastic Markets Hypothesis](https://doi.org/10.3386/w28967).
- **Yakov Amihud** (2002). [Illiquidity and stock returns: cross-section and time-series effects](https://doi.org/10.1016/S1386-4181(01)00024-6). *Journal of Financial Markets*.
- **Yuki Sato and Kiyoshi Kanazawa** (2024). [Does the square-root price impact law belong to the strict universal scalings?: quantitative support by a complete survey of the Tokyo stock exchange market](https://doi.org/10.48550/arXiv.2411.13965).
- **Yuriy Nevmyvaka et al.** (2006). [Reinforcement learning for optimized trade execution](https://doi.org/10.1145/1143844.1143929). *Association for Computing Machinery*.
- **Zoltan Eisler et al.** (2010). [The price impact of order book events: market orders, limit orders and cancellations](https://doi.org/10.48550/arXiv.0904.0900).

Reproduit dans son intégralité avec attribution, conformément à la licence de la source. Licence: MIT

Ce résumé a été rédigé par l’agent de recherche de Stratmill à partir de la source originale ; il n’en est pas une copie.