SlideShare a Scribd company logo
Optimizing Trading Strategies
Without Overfitting
Ernie Chan, Ph.D. and Ray Ng, Ph.D.
QTS Capital Management, LLC.
Typical Backtest Workflow
Optimizing Trading Signals
β€’ Optimize trading strategy β‰ˆ Optimize sum(PLs)
by tweaking trading signals.
β€’ Number(trading signals) << Number(prices)
typically.
– Easy to cherry-pick trading signals for
optimization.
– Overfitting/data Snooping Bias.
– No predictive power on unseen/out-of-sample
data!
Remedies for Overfitting
β€’ Increase length of historical backtest period.
– Subject to data availability
– Regime changes β‡’ old prices may be irrelevant.
β€’ Create mathematical model of historical prices,
then analytically find optimal trading signals
– Effectively infinite backtest period.
– Historical price models tend to be oversimplified.
– Only analytically solvable for Trading Signals and
performance objective linearly related to prices.
Remedies for Overfitting
β€’ Simulate historical prices with similar statistics
as actual historical prices.
– As large number of price series as practical.
– Can capture as many quirks of actual historical
prices as necessary.
β€’ E.g. serial correlation, volatility clustering, tail events, …
– Can be used to optimize nonlinear trading signals
and performance objectives.
Analytical Optimization
β€’ Example: a mean-reverting log price series π‘₯.
β€’ Ornstein-Uhlenbeck equation
𝑑π‘₯ 𝑑 = πœ… πœƒ βˆ’ π‘₯ 𝑑 𝑑𝑑 + πœŽπ‘‘π‘Š(𝑑)
πœ…: rate of mean reversion
πœƒ: mean log price level
𝜎: conditional volatility of π‘₯
W: random walk
β€’ What are optimal entry/exit levels?
– Optimal ≑ maximum expected (discounted) profit for
single round-trip trade.
– Similar to optimal Bollinger bands.
Solving HJB
β€’ Cartea, 2015 demonstrated solution using Hamilton-Jacobi-Bellman
equation (a PDE), familiar from stochastic control theory.
β€’ Numerical solution to equation shows
– Entry and exit levels are asymmetric w.r.t. mean, due to discount
factor.
– Entry level closer to mean level than exit level.
– Distance of entry / exit levels to mean increases with decreasing πœ….
– Distance of entry / exit levels to mean increases with increasing 𝜎.
– (Last 2 points expected because unconditional volatility is
𝜎2
2πœ…
⇔
width of Bollinger bands.)
– Long exit = short entry, vice versa.
– Position is path-dependent.
– Always in either long or short position.
Optimal Entry and Exit
Long entry
Long exit
Short exit
Short entry
∼
𝜎2
2πœ…
Analytical Optimization
β€’ What if underlying price prices are not described
by simple SDE like OU process?
– Jumps, volatility clustering, long range correlations,
etc.
β€’ What if objective function is not discounted profit
but a nonlinear function of PL?
– Sharpe ratio, Calmar ratio, etc.
β€’ What if objective function is total PL, not PL per
trade?
β€’ Even setting up HJB equation is too difficult.
Simulation for optimization
β€’ We can simulate as many copies of price series as
we like.
– All follow the same time series model, e.g. AR(p).
β€’ Find trading parameters that maximizes the
average Sharpe ratio over all simulated price
series.
– Similar to solving HJB equation.
β€’ Alternatively, find trading parameters that most
often maximizes Sharpe ratio of a simulated price
series.
– Similar to maximum likelihood estimation.
Optimizing Trading Strategies Without Overfitting by Dr. Ernest Chan
Example: AUDCAD
β€’ ADF test indicates hourly AUDCAD prices are
stationary with p-Value better than 1%.
β€’ Assume AR(1) model on daily log prices π‘₯.
π‘₯ 𝑑 = π‘Ž1 π‘₯ 𝑑 βˆ’ 1 + π‘Ž0 + 𝜎0 πœ– 𝑑
πœ–~𝒩(0, 1)
– For illustrative purpose only.
– Train (π‘Ž0, π‘Ž1, 𝜎0) on first half of data using MLE.
Optimal trading of AUDCAD
β€’ Simulate 10,000 log price series based on
fitted AR(1).
– Each series is about 3.7 years (~10 x halflife).
β€’ On each series, backtest a simple strategy:
Buy if expected log return > π‘˜πœŽ0
Sell if expected log return < -π‘˜πœŽ0
Flatten otherwise.
β€’ Apply 1.8 bps per side transaction cost.
Simulation Results
β€’ Maximizing the average Sharpe ratio gives
optimal π‘˜=0.0088Β±0.0002.
π΄π‘Ÿπ‘”π‘šπ‘Žπ‘₯ π‘˜{𝐸 π‘π‘Žπ‘‘β„Ž[π‘†β„Žπ‘Žπ‘Ÿπ‘π‘’(π‘π‘Žπ‘‘β„Ž)|π‘˜]}
β€’ In contrast, π‘˜=0.01Β±0.006 maximizes the
likelihood that a path has highest Sharpe ratio
π΄π‘Ÿπ‘”π‘šπ‘Žπ‘₯ π‘˜{π‘ƒπ‘π‘Žπ‘‘β„Ž[π΄π‘Ÿπ‘”π‘šπ‘Žπ‘₯ π‘˜[π‘†β„Žπ‘Žπ‘Ÿπ‘π‘’(π‘˜, path)]]}
β€’ In general, the first method is more accurate
since all paths are used to determine 𝐸 π‘π‘Žπ‘‘β„Ž.
Optimizing Trading Strategies Without Overfitting by Dr. Ernest Chan
OOS Backtest Optimal Parameter
OOS Backtest Suboptimal Parameter
Suboptimal > optimal?
β€’ Backtest of β€œoptimal” parameter underperforms
that of β€œsuboptimal” parameter out-of-sample.
β€’ AR(1) model may need refitting periodically.
β€’ Nobody promises that for a particular realized
path, our optimal π’Œ will maximize Sharpe!
– It is worth trading a range of π‘˜ in the vicinity of the
optimal for diversification.
β€’ See similar work by Carr and Lopez de Prado,
2014.
Further work
β€’ Can easily optimize other nonlinear functions of
prices instead
– Calmar ratio.
– CVaR .
β€’ Can easily extend this to more complicated time
series models
– AR+GARCH
– Nonlinear generative models: e.g. LSTM (recurrent
neural network)
β€’ Can easily extend this to more complicated
trading strategies, with multiple parameters.
Conclusion
β€’ Optimizing trading strategy parameters on
historical data invites overfitting.
β€’ More robust to fit time series (not trading)
models on historical data instead.
β€’ Fitted time series model can be used to
simulate arbitrary number of time series.
β€’ Can find optimal trading parameters on
simulated time series to arbitrary precision.
Thank you for your time!
www.qtscm.com
Twitter: @chanep
Blog: epchan.blogspot.com

More Related Content

More from Quantopian

β€œReal Time Machine Learning Architecture and Sentiment Analysis Applied to Fi...
β€œReal Time Machine Learning Architecture and Sentiment Analysis Applied to Fi...β€œReal Time Machine Learning Architecture and Sentiment Analysis Applied to Fi...
β€œReal Time Machine Learning Architecture and Sentiment Analysis Applied to Fi...
Quantopian
Β 
β€œMarket Insights Through the Lens of a Risk Model” by Olivier d'Assier, Head ...
β€œMarket Insights Through the Lens of a Risk Model” by Olivier d'Assier, Head ...β€œMarket Insights Through the Lens of a Risk Model” by Olivier d'Assier, Head ...
β€œMarket Insights Through the Lens of a Risk Model” by Olivier d'Assier, Head ...
Quantopian
Β 
"Maximize Alpha with Systematic Factor Testing" by Cheng Peng, Software Engin...
"Maximize Alpha with Systematic Factor Testing" by Cheng Peng, Software Engin..."Maximize Alpha with Systematic Factor Testing" by Cheng Peng, Software Engin...
"Maximize Alpha with Systematic Factor Testing" by Cheng Peng, Software Engin...
Quantopian
Β 
"How to Run a Quantitative Trading Business in China with Python" by Xiaoyou ...
"How to Run a Quantitative Trading Business in China with Python" by Xiaoyou ..."How to Run a Quantitative Trading Business in China with Python" by Xiaoyou ...
"How to Run a Quantitative Trading Business in China with Python" by Xiaoyou ...
Quantopian
Β 
"Fundamental Forecasts: Methods and Timing" by Vinesh Jha, CEO of ExtractAlpha
"Fundamental Forecasts: Methods and Timing" by Vinesh Jha, CEO of ExtractAlpha"Fundamental Forecasts: Methods and Timing" by Vinesh Jha, CEO of ExtractAlpha
"Fundamental Forecasts: Methods and Timing" by Vinesh Jha, CEO of ExtractAlpha
Quantopian
Β 
"From Alpha Discovery to Portfolio Construction: Pitfalls and Solutions" by D...
"From Alpha Discovery to Portfolio Construction: Pitfalls and Solutions" by D..."From Alpha Discovery to Portfolio Construction: Pitfalls and Solutions" by D...
"From Alpha Discovery to Portfolio Construction: Pitfalls and Solutions" by D...
Quantopian
Β 
"Deep Reinforcement Learning for Optimal Order Placement in a Limit Order Boo...
"Deep Reinforcement Learning for Optimal Order Placement in a Limit Order Boo..."Deep Reinforcement Learning for Optimal Order Placement in a Limit Order Boo...
"Deep Reinforcement Learning for Optimal Order Placement in a Limit Order Boo...
Quantopian
Β 
"Making the Grade: A Look Inside the Algorithm Evaluation Process"Β by Dr. Jes...
"Making the Grade: A Look Inside the Algorithm Evaluation Process"Β by Dr. Jes..."Making the Grade: A Look Inside the Algorithm Evaluation Process"Β by Dr. Jes...
"Making the Grade: A Look Inside the Algorithm Evaluation Process"Β by Dr. Jes...
Quantopian
Β 
"Building Diversified Portfolios that Outperform Out-of-Sample"Β by Dr. Marcos...
"Building Diversified Portfolios that Outperform Out-of-Sample"Β by Dr. Marcos..."Building Diversified Portfolios that Outperform Out-of-Sample"Β by Dr. Marcos...
"Building Diversified Portfolios that Outperform Out-of-Sample"Β by Dr. Marcos...
Quantopian
Β 
"From Insufficient Economic data to Economic Big Data – How Trade Data is red...
"From Insufficient Economic data to Economic Big Data – How Trade Data is red..."From Insufficient Economic data to Economic Big Data – How Trade Data is red...
"From Insufficient Economic data to Economic Big Data – How Trade Data is red...
Quantopian
Β 
"Machine Learning Approaches to Regime-aware Portfolio Management"Β by Michael...
"Machine Learning Approaches to Regime-aware Portfolio Management"Β by Michael..."Machine Learning Approaches to Regime-aware Portfolio Management"Β by Michael...
"Machine Learning Approaches to Regime-aware Portfolio Management"Β by Michael...
Quantopian
Β 
"A Framework-Based Approach to Building Quantitative Trading Systems"Β by Dr. ...
"A Framework-Based Approach to Building Quantitative Trading Systems"Β by Dr. ..."A Framework-Based Approach to Building Quantitative Trading Systems"Β by Dr. ...
"A Framework-Based Approach to Building Quantitative Trading Systems"Β by Dr. ...
Quantopian
Β 
"Don't Lose Your Shirt Trading Mean-Reversion"Β by Edith Mandel, Principal at ...
"Don't Lose Your Shirt Trading Mean-Reversion"Β by Edith Mandel, Principal at ..."Don't Lose Your Shirt Trading Mean-Reversion"Β by Edith Mandel, Principal at ...
"Don't Lose Your Shirt Trading Mean-Reversion"Β by Edith Mandel, Principal at ...
Quantopian
Β 
"Deep Q-Learning for Trading"Β by Dr. Tucker Balch, Professor of Interactive C...
"Deep Q-Learning for Trading"Β by Dr. Tucker Balch, Professor of Interactive C..."Deep Q-Learning for Trading"Β by Dr. Tucker Balch, Professor of Interactive C...
"Deep Q-Learning for Trading"Β by Dr. Tucker Balch, Professor of Interactive C...
Quantopian
Β 
"Quantum Hierarchical Risk Parity - A Quantum-Inspired Approach to Portfolio ...
"Quantum Hierarchical Risk Parity - A Quantum-Inspired Approach to Portfolio ..."Quantum Hierarchical Risk Parity - A Quantum-Inspired Approach to Portfolio ...
"Quantum Hierarchical Risk Parity - A Quantum-Inspired Approach to Portfolio ...
Quantopian
Β 
"Snake Oil, Swamp Land, and Factor-Based Investing"Β by Gary Antonacci, author...
"Snake Oil, Swamp Land, and Factor-Based Investing"Β by Gary Antonacci, author..."Snake Oil, Swamp Land, and Factor-Based Investing"Β by Gary Antonacci, author...
"Snake Oil, Swamp Land, and Factor-Based Investing"Β by Gary Antonacci, author...
Quantopian
Β 
"From Trading Strategy to Becoming an Industry Professional – How to Break in...
"From Trading Strategy to Becoming an Industry Professional – How to Break in..."From Trading Strategy to Becoming an Industry Professional – How to Break in...
"From Trading Strategy to Becoming an Industry Professional – How to Break in...
Quantopian
Β 
"Enhancing Statistical Significance of Backtests"Β by Dr. Ernest Chan, Managin...
"Enhancing Statistical Significance of Backtests"Β by Dr. Ernest Chan, Managin..."Enhancing Statistical Significance of Backtests"Β by Dr. Ernest Chan, Managin...
"Enhancing Statistical Significance of Backtests"Β by Dr. Ernest Chan, Managin...
Quantopian
Β 
"Bayesian Deep Learning: Dealing with Uncertainty and Non-Stationarity"Β by Dr...
"Bayesian Deep Learning: Dealing with Uncertainty and Non-Stationarity"Β by Dr..."Bayesian Deep Learning: Dealing with Uncertainty and Non-Stationarity"Β by Dr...
"Bayesian Deep Learning: Dealing with Uncertainty and Non-Stationarity"Β by Dr...
Quantopian
Β 
"Trading Strategies That Are Designed Not Fitted"Β by Robert Carver, Independe...
"Trading Strategies That Are Designed Not Fitted"Β by Robert Carver, Independe..."Trading Strategies That Are Designed Not Fitted"Β by Robert Carver, Independe...
"Trading Strategies That Are Designed Not Fitted"Β by Robert Carver, Independe...
Quantopian
Β 

More from Quantopian (20)

β€œReal Time Machine Learning Architecture and Sentiment Analysis Applied to Fi...
β€œReal Time Machine Learning Architecture and Sentiment Analysis Applied to Fi...β€œReal Time Machine Learning Architecture and Sentiment Analysis Applied to Fi...
β€œReal Time Machine Learning Architecture and Sentiment Analysis Applied to Fi...
Β 
β€œMarket Insights Through the Lens of a Risk Model” by Olivier d'Assier, Head ...
β€œMarket Insights Through the Lens of a Risk Model” by Olivier d'Assier, Head ...β€œMarket Insights Through the Lens of a Risk Model” by Olivier d'Assier, Head ...
β€œMarket Insights Through the Lens of a Risk Model” by Olivier d'Assier, Head ...
Β 
"Maximize Alpha with Systematic Factor Testing" by Cheng Peng, Software Engin...
"Maximize Alpha with Systematic Factor Testing" by Cheng Peng, Software Engin..."Maximize Alpha with Systematic Factor Testing" by Cheng Peng, Software Engin...
"Maximize Alpha with Systematic Factor Testing" by Cheng Peng, Software Engin...
Β 
"How to Run a Quantitative Trading Business in China with Python" by Xiaoyou ...
"How to Run a Quantitative Trading Business in China with Python" by Xiaoyou ..."How to Run a Quantitative Trading Business in China with Python" by Xiaoyou ...
"How to Run a Quantitative Trading Business in China with Python" by Xiaoyou ...
Β 
"Fundamental Forecasts: Methods and Timing" by Vinesh Jha, CEO of ExtractAlpha
"Fundamental Forecasts: Methods and Timing" by Vinesh Jha, CEO of ExtractAlpha"Fundamental Forecasts: Methods and Timing" by Vinesh Jha, CEO of ExtractAlpha
"Fundamental Forecasts: Methods and Timing" by Vinesh Jha, CEO of ExtractAlpha
Β 
"From Alpha Discovery to Portfolio Construction: Pitfalls and Solutions" by D...
"From Alpha Discovery to Portfolio Construction: Pitfalls and Solutions" by D..."From Alpha Discovery to Portfolio Construction: Pitfalls and Solutions" by D...
"From Alpha Discovery to Portfolio Construction: Pitfalls and Solutions" by D...
Β 
"Deep Reinforcement Learning for Optimal Order Placement in a Limit Order Boo...
"Deep Reinforcement Learning for Optimal Order Placement in a Limit Order Boo..."Deep Reinforcement Learning for Optimal Order Placement in a Limit Order Boo...
"Deep Reinforcement Learning for Optimal Order Placement in a Limit Order Boo...
Β 
"Making the Grade: A Look Inside the Algorithm Evaluation Process"Β by Dr. Jes...
"Making the Grade: A Look Inside the Algorithm Evaluation Process"Β by Dr. Jes..."Making the Grade: A Look Inside the Algorithm Evaluation Process"Β by Dr. Jes...
"Making the Grade: A Look Inside the Algorithm Evaluation Process"Β by Dr. Jes...
Β 
"Building Diversified Portfolios that Outperform Out-of-Sample"Β by Dr. Marcos...
"Building Diversified Portfolios that Outperform Out-of-Sample"Β by Dr. Marcos..."Building Diversified Portfolios that Outperform Out-of-Sample"Β by Dr. Marcos...
"Building Diversified Portfolios that Outperform Out-of-Sample"Β by Dr. Marcos...
Β 
"From Insufficient Economic data to Economic Big Data – How Trade Data is red...
"From Insufficient Economic data to Economic Big Data – How Trade Data is red..."From Insufficient Economic data to Economic Big Data – How Trade Data is red...
"From Insufficient Economic data to Economic Big Data – How Trade Data is red...
Β 
"Machine Learning Approaches to Regime-aware Portfolio Management"Β by Michael...
"Machine Learning Approaches to Regime-aware Portfolio Management"Β by Michael..."Machine Learning Approaches to Regime-aware Portfolio Management"Β by Michael...
"Machine Learning Approaches to Regime-aware Portfolio Management"Β by Michael...
Β 
"A Framework-Based Approach to Building Quantitative Trading Systems"Β by Dr. ...
"A Framework-Based Approach to Building Quantitative Trading Systems"Β by Dr. ..."A Framework-Based Approach to Building Quantitative Trading Systems"Β by Dr. ...
"A Framework-Based Approach to Building Quantitative Trading Systems"Β by Dr. ...
Β 
"Don't Lose Your Shirt Trading Mean-Reversion"Β by Edith Mandel, Principal at ...
"Don't Lose Your Shirt Trading Mean-Reversion"Β by Edith Mandel, Principal at ..."Don't Lose Your Shirt Trading Mean-Reversion"Β by Edith Mandel, Principal at ...
"Don't Lose Your Shirt Trading Mean-Reversion"Β by Edith Mandel, Principal at ...
Β 
"Deep Q-Learning for Trading"Β by Dr. Tucker Balch, Professor of Interactive C...
"Deep Q-Learning for Trading"Β by Dr. Tucker Balch, Professor of Interactive C..."Deep Q-Learning for Trading"Β by Dr. Tucker Balch, Professor of Interactive C...
"Deep Q-Learning for Trading"Β by Dr. Tucker Balch, Professor of Interactive C...
Β 
"Quantum Hierarchical Risk Parity - A Quantum-Inspired Approach to Portfolio ...
"Quantum Hierarchical Risk Parity - A Quantum-Inspired Approach to Portfolio ..."Quantum Hierarchical Risk Parity - A Quantum-Inspired Approach to Portfolio ...
"Quantum Hierarchical Risk Parity - A Quantum-Inspired Approach to Portfolio ...
Β 
"Snake Oil, Swamp Land, and Factor-Based Investing"Β by Gary Antonacci, author...
"Snake Oil, Swamp Land, and Factor-Based Investing"Β by Gary Antonacci, author..."Snake Oil, Swamp Land, and Factor-Based Investing"Β by Gary Antonacci, author...
"Snake Oil, Swamp Land, and Factor-Based Investing"Β by Gary Antonacci, author...
Β 
"From Trading Strategy to Becoming an Industry Professional – How to Break in...
"From Trading Strategy to Becoming an Industry Professional – How to Break in..."From Trading Strategy to Becoming an Industry Professional – How to Break in...
"From Trading Strategy to Becoming an Industry Professional – How to Break in...
Β 
"Enhancing Statistical Significance of Backtests"Β by Dr. Ernest Chan, Managin...
"Enhancing Statistical Significance of Backtests"Β by Dr. Ernest Chan, Managin..."Enhancing Statistical Significance of Backtests"Β by Dr. Ernest Chan, Managin...
"Enhancing Statistical Significance of Backtests"Β by Dr. Ernest Chan, Managin...
Β 
"Bayesian Deep Learning: Dealing with Uncertainty and Non-Stationarity"Β by Dr...
"Bayesian Deep Learning: Dealing with Uncertainty and Non-Stationarity"Β by Dr..."Bayesian Deep Learning: Dealing with Uncertainty and Non-Stationarity"Β by Dr...
"Bayesian Deep Learning: Dealing with Uncertainty and Non-Stationarity"Β by Dr...
Β 
"Trading Strategies That Are Designed Not Fitted"Β by Robert Carver, Independe...
"Trading Strategies That Are Designed Not Fitted"Β by Robert Carver, Independe..."Trading Strategies That Are Designed Not Fitted"Β by Robert Carver, Independe...
"Trading Strategies That Are Designed Not Fitted"Β by Robert Carver, Independe...
Β 

Recently uploaded

A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
sonjaschweigert1
Β 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
Β 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
Β 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Nexer Digital
Β 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
Β 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
Β 
UiPath Community Day Dubai: AI at Work..
UiPath Community Day Dubai: AI at Work..UiPath Community Day Dubai: AI at Work..
UiPath Community Day Dubai: AI at Work..
UiPathCommunity
Β 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
Β 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
Β 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
Β 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
nkrafacyberclub
Β 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
Β 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
Β 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
Β 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
Β 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
KAMESHS29
Β 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
Β 
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex ProofszkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
Alex Pruden
Β 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
Β 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
Β 

Recently uploaded (20)

A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
Β 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Β 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Β 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Β 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Β 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
Β 
UiPath Community Day Dubai: AI at Work..
UiPath Community Day Dubai: AI at Work..UiPath Community Day Dubai: AI at Work..
UiPath Community Day Dubai: AI at Work..
Β 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Β 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Β 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Β 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Β 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
Β 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
Β 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Β 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Β 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
Β 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
Β 
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex ProofszkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
Β 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Β 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
Β 

Optimizing Trading Strategies Without Overfitting by Dr. Ernest Chan

  • 1. Optimizing Trading Strategies Without Overfitting Ernie Chan, Ph.D. and Ray Ng, Ph.D. QTS Capital Management, LLC.
  • 3. Optimizing Trading Signals β€’ Optimize trading strategy β‰ˆ Optimize sum(PLs) by tweaking trading signals. β€’ Number(trading signals) << Number(prices) typically. – Easy to cherry-pick trading signals for optimization. – Overfitting/data Snooping Bias. – No predictive power on unseen/out-of-sample data!
  • 4. Remedies for Overfitting β€’ Increase length of historical backtest period. – Subject to data availability – Regime changes β‡’ old prices may be irrelevant. β€’ Create mathematical model of historical prices, then analytically find optimal trading signals – Effectively infinite backtest period. – Historical price models tend to be oversimplified. – Only analytically solvable for Trading Signals and performance objective linearly related to prices.
  • 5. Remedies for Overfitting β€’ Simulate historical prices with similar statistics as actual historical prices. – As large number of price series as practical. – Can capture as many quirks of actual historical prices as necessary. β€’ E.g. serial correlation, volatility clustering, tail events, … – Can be used to optimize nonlinear trading signals and performance objectives.
  • 6. Analytical Optimization β€’ Example: a mean-reverting log price series π‘₯. β€’ Ornstein-Uhlenbeck equation 𝑑π‘₯ 𝑑 = πœ… πœƒ βˆ’ π‘₯ 𝑑 𝑑𝑑 + πœŽπ‘‘π‘Š(𝑑) πœ…: rate of mean reversion πœƒ: mean log price level 𝜎: conditional volatility of π‘₯ W: random walk β€’ What are optimal entry/exit levels? – Optimal ≑ maximum expected (discounted) profit for single round-trip trade. – Similar to optimal Bollinger bands.
  • 7. Solving HJB β€’ Cartea, 2015 demonstrated solution using Hamilton-Jacobi-Bellman equation (a PDE), familiar from stochastic control theory. β€’ Numerical solution to equation shows – Entry and exit levels are asymmetric w.r.t. mean, due to discount factor. – Entry level closer to mean level than exit level. – Distance of entry / exit levels to mean increases with decreasing πœ…. – Distance of entry / exit levels to mean increases with increasing 𝜎. – (Last 2 points expected because unconditional volatility is 𝜎2 2πœ… ⇔ width of Bollinger bands.) – Long exit = short entry, vice versa. – Position is path-dependent. – Always in either long or short position.
  • 8. Optimal Entry and Exit Long entry Long exit Short exit Short entry ∼ 𝜎2 2πœ…
  • 9. Analytical Optimization β€’ What if underlying price prices are not described by simple SDE like OU process? – Jumps, volatility clustering, long range correlations, etc. β€’ What if objective function is not discounted profit but a nonlinear function of PL? – Sharpe ratio, Calmar ratio, etc. β€’ What if objective function is total PL, not PL per trade? β€’ Even setting up HJB equation is too difficult.
  • 10. Simulation for optimization β€’ We can simulate as many copies of price series as we like. – All follow the same time series model, e.g. AR(p). β€’ Find trading parameters that maximizes the average Sharpe ratio over all simulated price series. – Similar to solving HJB equation. β€’ Alternatively, find trading parameters that most often maximizes Sharpe ratio of a simulated price series. – Similar to maximum likelihood estimation.
  • 12. Example: AUDCAD β€’ ADF test indicates hourly AUDCAD prices are stationary with p-Value better than 1%. β€’ Assume AR(1) model on daily log prices π‘₯. π‘₯ 𝑑 = π‘Ž1 π‘₯ 𝑑 βˆ’ 1 + π‘Ž0 + 𝜎0 πœ– 𝑑 πœ–~𝒩(0, 1) – For illustrative purpose only. – Train (π‘Ž0, π‘Ž1, 𝜎0) on first half of data using MLE.
  • 13. Optimal trading of AUDCAD β€’ Simulate 10,000 log price series based on fitted AR(1). – Each series is about 3.7 years (~10 x halflife). β€’ On each series, backtest a simple strategy: Buy if expected log return > π‘˜πœŽ0 Sell if expected log return < -π‘˜πœŽ0 Flatten otherwise. β€’ Apply 1.8 bps per side transaction cost.
  • 14. Simulation Results β€’ Maximizing the average Sharpe ratio gives optimal π‘˜=0.0088Β±0.0002. π΄π‘Ÿπ‘”π‘šπ‘Žπ‘₯ π‘˜{𝐸 π‘π‘Žπ‘‘β„Ž[π‘†β„Žπ‘Žπ‘Ÿπ‘π‘’(π‘π‘Žπ‘‘β„Ž)|π‘˜]} β€’ In contrast, π‘˜=0.01Β±0.006 maximizes the likelihood that a path has highest Sharpe ratio π΄π‘Ÿπ‘”π‘šπ‘Žπ‘₯ π‘˜{π‘ƒπ‘π‘Žπ‘‘β„Ž[π΄π‘Ÿπ‘”π‘šπ‘Žπ‘₯ π‘˜[π‘†β„Žπ‘Žπ‘Ÿπ‘π‘’(π‘˜, path)]]} β€’ In general, the first method is more accurate since all paths are used to determine 𝐸 π‘π‘Žπ‘‘β„Ž.
  • 16. OOS Backtest Optimal Parameter
  • 18. Suboptimal > optimal? β€’ Backtest of β€œoptimal” parameter underperforms that of β€œsuboptimal” parameter out-of-sample. β€’ AR(1) model may need refitting periodically. β€’ Nobody promises that for a particular realized path, our optimal π’Œ will maximize Sharpe! – It is worth trading a range of π‘˜ in the vicinity of the optimal for diversification. β€’ See similar work by Carr and Lopez de Prado, 2014.
  • 19. Further work β€’ Can easily optimize other nonlinear functions of prices instead – Calmar ratio. – CVaR . β€’ Can easily extend this to more complicated time series models – AR+GARCH – Nonlinear generative models: e.g. LSTM (recurrent neural network) β€’ Can easily extend this to more complicated trading strategies, with multiple parameters.
  • 20. Conclusion β€’ Optimizing trading strategy parameters on historical data invites overfitting. β€’ More robust to fit time series (not trading) models on historical data instead. β€’ Fitted time series model can be used to simulate arbitrary number of time series. β€’ Can find optimal trading parameters on simulated time series to arbitrary precision.
  • 21. Thank you for your time! www.qtscm.com Twitter: @chanep Blog: epchan.blogspot.com