SlideShare a Scribd company logo
A Framework-Based Approach toA Framework-Based Approach to
Building Quantitative Trading SystemsBuilding Quantitative Trading Systems
QuantCon NYC – 29QuantCon NYC – 29thth
April 2017April 2017
Michael Halls-MooreMichael Halls-Moore
QuantStart.comQuantStart.com
Talk OutlineTalk Outline
● About QuantStart
● The US equities market
● Typical retail trader approach
● The need for a quantitative framework
● Portfolio management
● Risk management
● Forecasting
● Good tools
● Who to read
About QuantStart.comAbout QuantStart.com
About QuantStart.comAbout QuantStart.com
● My Background:
– Computational fluid dynamics (CFD) research in aerospace
– Quant trading infrastructure development at London-based US equities fund
● QuantStart.com:
– Founded in 2012
– Talks about systematic trading, quant development, careers and machine learning
– Mainly Python, R, C++ and open-source backtesting
– Bringing institutional methods to retail traders
The US Equities MarketThe US Equities Market
The US Equities Market #1The US Equities Market #1
● Liquid Low spreads, easy to execute quickly at desired price→
● Exchange-traded Not trading obscure OTC instruments→
● Easy retail access Many retail equities brokerages→
● Can access with smaller account sizes
– Cash purchases
– Individual stocks far cheaper than futures
● Various benchmark indexes – S&P, Dow, Russell
– Mostly interested in S&P500 universe at retail level
The US Equities Market #2The US Equities Market #2
● Indexes discussed in the media are misleading
● DJIA has price-weighted methodology
● S&P500 has market-capitalisation weighted methodology
● But...S&P500 is not 'the market':
– By definition it disproportionately favours big firms, i.e. AAPL
● Does not include dividend reinvestment Total return→
● A good benchmark instead would be S&P500 Total Return index
Typical Retail Trader ApproachTypical Retail Trader Approach
Typical Retail Trader ApproachTypical Retail Trader Approach
● Emphasis on “the best indicator”
● Charts, discretionary forecasts, pattern-matching
● Few instruments traded (“stocks that I know well”)
● Excess cash kept in brokerage account, not cash-like instruments
● No risk management: What is vol, skew, kurtosis of returns?
● Survivorship Bias: Trade stocks that have done well (e.g. AAPL)
● Too much trading: Forecast overconfidence, high costs
● No concept of Portfolio Management
Why Is This Bad? #1Why Is This Bad? #1
● Discretionary forecasts are too inconsistent
– Tied to emotional state and cognitive biases (see Kahneman et al)
● “Lines on charts” are too ambiguous
– No repeatable methodology
– Far better quantitative methods available
● No risk parity
– Assets with higher vol dominate portfolio returns behaviour
● No rebalancing
– Risk is dynamic, so allocations need adjustment over time
Why Is This Bad? #2Why Is This Bad? #2
● Few instruments → No diversification
● Survivorship Bias Backtest→ optimism inflated
● Cash Positions Brokerages→ collapse taking cash with them
● No tail-risk planning
– What rules are followed in 1987, 2001, 2008?
– Often the worst time to tinker with a “system”
● In summary
– No portfolio management, no risk management, no consistency
The Need for a Quantitative FrameworkThe Need for a Quantitative Framework
The Need for a Quantitative FrameworkThe Need for a Quantitative Framework
● Systematic Framework
– Eliminates discretionary decision making
– But requires substantial confidence and discipline!
● Risk Parity
– Each asset is volatility standardised Equal “risk” in every asset→
● Rebalancing
– Risk is dynamic Periodically rebalance to reflect changing allocation of risk→
● Position Sizing
– Quantitative approach for how much to “bet” per asset
● Diversification
– Enough stocks to ensure luck is less important in portfolio performance
Performance MeasurementPerformance Measurement
● Must decompose where our performance and risk comes from
● Important for equities: Alpha, Beta and Sharpe
● Beta: Risk arising from exposure to benchmark (or market)
● Alpha: Measures the excess return on a portfolio
● Sharpe: Mean excess return divided by std of returns
– But...it is a very misleading metric for a number of reasons!
● “Vol is the currency we pay for performance” - Andreas Clenow
● All measures are backward-looking
Portfolio ManagementPortfolio Management
Portfolio Management #1Portfolio Management #1
● Requires a significant shift in thinking!
● Biggest difference between retail and institutional behaviour
● Portfolio management is not about allocation of cash but
about allocation of risk
– What risks am I taking in order to achieve my returns?
● The goal:
– Obtain high risk-adjusted returns
– Achieve good diversification
– Minimise the costs of trading/rebalancing while doing so
Portfolio Management #2Portfolio Management #2
● Began formally with Harry Markowitz in 1950s
– His essay and PhD thesis became Modern Portfolio Theory (MPT)
– He, along with Sharpe and Miller, received Nobel Prize in 1990 for this
● Extended into Capital Asset Pricing Model (CAPM)
– Origins of “Alpha” and “Beta” as linear regression coefficients
● Efficient Market Hypothesis (EMH) dominated in 70s/80s
● Factor Analysis Fama & French three-factor model→
● Behavioural Economics Cognitive biases and investor→
psychology grew in importance
Portfolio Management #3Portfolio Management #3
● Today there is strong academic evidence for persistent
equity market “anomalies”:
– Value premium Graham & Dodd, Buffett→
– Size premium Small-cap stocks outperforming large-cap stocks→
– Momentum Positive serial correlation of returns→
– And others...
● Our portfolios can take advantage of these
– Generate forecasts based on these anomalies
– Systematically exploit them across a diversified set of stocks
Risk ParityRisk Parity
Risk Parity #1Risk Parity #1
● Allocation based on trailing std of returns of assets
– Bonds get larger allocation than equities due to lower std
– Increase leverage to get similar returns to equities with lower vol
● First used by Bridgewater Associates in their “All Weather” fund (1996)
– Now all major asset allocators have a risk parity fund
– Each of them have a proprietary methodology
● Is sometimes called “Volatility Standardisation”
● Can have a big impact on risk-adjusted returns over long-term
Risk Parity #2Risk Parity #2
● We will define “risk parity” here as:
– Volatility-adjusted allocations of stocks only
– Higher std returns implies lower allocation
– No other asset classes (don't need to worry about bonds!)
● Many ways to calculate it
– Average True Range (ATR)
– Trailing std of returns (250 trading days)
– More technical estimates of volatility (large literature on this)
Risk Parity #3Risk Parity #3
● Must also take correlation into account:
– No value in having thirty highly correlated stocks, even if vol-adjusted
– You're taking ONE bet not THIRTY!
● Volatility Measures:
– Often backward-looking and non-stationary
– Says nothing about future volatility
– Must be periodically re-estimated
Portfolio RebalancingPortfolio Rebalancing
Portfolio Rebalancing #1Portfolio Rebalancing #1
● Dynamically adjust risk allocation based on new information
● Another big difference between retail and institutional quants
● Volatility is dynamic
– Modelled as conditional heteroskedastic (e.g. GARCH family of models)
– Vol often higher in times of distress (e.g. 2008)
● Correlations are dynamic
– Correlations can increase to unity in times of distress (again, 2008!)
Portfolio Rebalancing #2Portfolio Rebalancing #2
● To maintain risk parity positions are periodically resized
– Weekly or monthly
– Daily can be too “noisy” and expensive for some asset allocators
● Most trades now become rebalances
– Small adjustments are made to position sizes when it is not too
expensive to carry out
Risk ManagementRisk Management
Risk ManagementRisk Management
● How much to bet per desired asset? Position sizing→
● Vol, skew and kurtosis:
– What is the historical distribution of portfolio returns?
● Non-stationarity of returns:
– Market regime filtering
– Future is different from the past
● Counterparty Risk
– Brokerage goes under (have seen this personally!)
● Trading infrastructure fails/has bugs
Position SizingPosition Sizing
Position Sizing #1Position Sizing #1
● How much risk to take per “bet” or per stock?
● Depends upon:
– Desired level of diversification More stocks means less per stock→
– Total account size Small accounts reduce number of available bets→
– Your tolerance for risk What drawdowns can you stomach over a→
particular timeframe?
● For equities in particular:
– Too few stocks is just random luck Apple vs Lehman Brothers→
– Too many stocks will have high beta
Position Sizing #2Position Sizing #2
● Can use tools like Kelly criterion
– Optimal size of a series of bets f*→
– Institutional constraints can limit optimal growth rate
– “Fractional Kelly” or “Half Kelly” often used in practice
● Can target a level of desired volatility impact per stock
– E.g. with a portfolio of $250,000 and risk target of 10 basis points daily
vol per stock, we want each stock position to have $250 daily impact
– Dividing this number ($250) by the daily std of the stock (say, $4.67), gives
250/4.67 ~= 53 shares
– Increasing the risk target increases the shares purchased per asset
Market Regime FilteringMarket Regime Filtering
Market Regime FilteringMarket Regime Filtering
● Long-only stock strategies are often well-correlated to the market:
– Become even more so in times of distress
● Basic idea is not to have high stock exposure in bear markets
● Can detect regimes in many ways:
– Moving averages Index above or below its long-term moving average→
– State-space models Hidden Markov Models→
● Why not short stocks?
– Not symmetric due to availability of stock at broker and borrowing costs
● Regime filters can cause many “false positives”:
– Better than the alternative of giving back substantial performance in a prolonged
bear market!
Good ToolsGood Tools
Equities DataEquities Data
● Pay for good data
● Free data sources just don't cut it for the required accuracy
● Must be survivorship-bias free Include→ graveyard tickers
● Must have historical index constituents
● Must handle ticker mapping for mergers, spinoffs etc.
● Must have separate lists of dividends and splits
● All values of OHLCV should be split-adjusted, not just close
● Ideally use minutely OHLCV bars to better estimate fill price
BacktestingBacktesting
● Use robust backtesting software
● Most tools are “single instrument” Not good enough→
● Should have extensible portfolio/risk management modules
● Free: Quantopian, zipline, QSTrader, PySystemTrade, others...
● Desktop/Paid: RightEdge, Deltix
● Will need to know programming Can't get away from this!→
ForecastingForecasting
ForecastingForecasting
● I've left it to the end - it's discussed to death elsewhere!
● As important as the other aspects, but not more so
● Look for equity market anomalies:
– Value, size, momentum, PEAD, seasonal, etc.
● Can implement a lot of these with simpler “indicators”
● Or...more complex feature extraction (deep learning)
● Boils down to making a regressive forecast on an asset
– Direction, with associated strength of conviction
– E.g. momentum ranking, difference between two MA indicators
TakeawaysTakeaways
TakeawaysTakeaways
● Use a systematic portfolio management framework
● Benchmark against total return index of the stock universe
● Use risk parity for equal risk allocation
● Rebalance the portfolio to account for dynamic risk
● Choose own risk tolerance for position sizing, quantitatively
● Use a market regime filter to avoid prolonged bear markets
● Put cash in cash-like instruments
● Don't waste too much time on “the perfect indicator”
Who To ReadWho To Read
Who To Read #1 - BooksWho To Read #1 - Books
● W. Gray and J. Vogel: Quantitative Momentum
● A. Clenow: Stocks on the Move
● R. Carver: Systematic Trading
● G. Antonacci: Dual Momentum Investing
● L. Zacks: Equity Market Anomalies
● R. Grinold and R. Kahn: Active Portfolio Management
● D. Kahneman: Thinking Fast and Slow [for cognitive biases]
● ...some of the above are actually speaking here today!
Who To Read #2 - ResearchWho To Read #2 - Research
● AQR Research:
– https://www.aqr.com/library
● BlackRock Research:
– https://www.blackrock.com/corporate/en-br/insights/blackrock-investment-institute
● Bridgewater Associates Research:
– https://www.bridgewater.com/research-library/daily-observations/
● Cantab Capital:
– https://www.cantabcapital.com/we-think/
● Alpha Architect (Wes Gray et al):
– http://www.alphaarchitect.com
Thank you!Thank you!
Q&A?Q&A?

More Related Content

PPTX
"From Trading Strategy to Becoming an Industry Professional – How to Break in...
PPTX
"From Alpha Discovery to Portfolio Construction: Pitfalls and Solutions" by D...
PDF
"Build Effective Risk Management on Top of Your Trading Strategy" by Danielle...
PDF
"Quantitative Trading as a Mathematical Science" by Dr. Haksun Li, Founder an...
PPTX
"Quant Trading for a Living – Lessons from a Life in the Trenches" by Andreas...
PDF
Should You Build Your Own Backtester? by Michael Halls-Moore at QuantCon 2016
PPTX
Classification of quantitative trading strategies webinar ppt
PPTX
Automated Selection and Robustness for Systematic Trading Strategies by Dr. T...
"From Trading Strategy to Becoming an Industry Professional – How to Break in...
"From Alpha Discovery to Portfolio Construction: Pitfalls and Solutions" by D...
"Build Effective Risk Management on Top of Your Trading Strategy" by Danielle...
"Quantitative Trading as a Mathematical Science" by Dr. Haksun Li, Founder an...
"Quant Trading for a Living – Lessons from a Life in the Trenches" by Andreas...
Should You Build Your Own Backtester? by Michael Halls-Moore at QuantCon 2016
Classification of quantitative trading strategies webinar ppt
Automated Selection and Robustness for Systematic Trading Strategies by Dr. T...

What's hot (20)

PDF
Beware of Low Frequency Data by Ernie Chan, Managing Member, QTS Capital Mana...
PPTX
Volatility Trading - Hedge Fund Strategies
PPTX
Being open (source) in the traditionally secretive field of quant finance.
PDF
"Trading Strategies That Are Designed Not Fitted" by Robert Carver, Independe...
PPTX
Algorithmic trading
PDF
How to build a trading system
PPTX
Algorithmic Trading: an Overview
PPTX
"Enhancing Statistical Significance of Backtests" by Dr. Ernest Chan, Managin...
PDF
Backtesting And Live Trading With Interactive Brokers Using Python With Dr. H...
PPT
Introduction to Technical Analysis
PDF
"Portfolio Optimisation When You Don’t Know the Future (or the Past)" by Rob...
PDF
5 Day Trading Techniques
PDF
Learn A Simple Range Trading Strategy
PPTX
Order book dynamics in high frequency trading
PPTX
"How to Run a Quantitative Trading Business in China with Python" by Xiaoyou ...
PPTX
Pairs Trading from NYC Algorithmic Trading Meetup November '13
PPTX
"A Framework for Developing Trading Models Based on Machine Learning" by Kris...
PPTX
Algo trading
PDF
Best Swing Trading Indicators and Oscillators
PDF
Simple scalping secret strategy
Beware of Low Frequency Data by Ernie Chan, Managing Member, QTS Capital Mana...
Volatility Trading - Hedge Fund Strategies
Being open (source) in the traditionally secretive field of quant finance.
"Trading Strategies That Are Designed Not Fitted" by Robert Carver, Independe...
Algorithmic trading
How to build a trading system
Algorithmic Trading: an Overview
"Enhancing Statistical Significance of Backtests" by Dr. Ernest Chan, Managin...
Backtesting And Live Trading With Interactive Brokers Using Python With Dr. H...
Introduction to Technical Analysis
"Portfolio Optimisation When You Don’t Know the Future (or the Past)" by Rob...
5 Day Trading Techniques
Learn A Simple Range Trading Strategy
Order book dynamics in high frequency trading
"How to Run a Quantitative Trading Business in China with Python" by Xiaoyou ...
Pairs Trading from NYC Algorithmic Trading Meetup November '13
"A Framework for Developing Trading Models Based on Machine Learning" by Kris...
Algo trading
Best Swing Trading Indicators and Oscillators
Simple scalping secret strategy
Ad

Similar to "A Framework-Based Approach to Building Quantitative Trading Systems" by Dr. Michael Halls-Moore, Founder of QuantStart.com (20)

PPTX
Quantopian is Launching a Crowd-sourced Hedge Fund
PDF
Can Individual Investors Beat the Market?
PDF
Financial Engineering 1
PDF
Book summary the five rules of successful stock investing
PDF
Aikido Masterclass - Starting Your Algorithmic Investing Journey.pdf
PPT
value-1.ppt
PPTX
Managing your enterprise growth by numbers by Vinod Keni | #TiEInstitute
PDF
330286200-Money-and-Risk-Management1.pdf
PPTX
Equity portfolio management strategies reilly and brown.
PPT
A philosophical basis for Valuation - Mi
PDF
Conner Management Group, Investment Management, April 2014
PDF
risk management chapter 2 TYBMS SEM 6 full notes
PDF
Risk Management: Maximising Long-Term Growth Presentation
PDF
CF2-day Corporate Finance Aswath Damodaran.pdf
PPTX
Smart Directions Portfolio Diversification - 2/4/2016
PPTX
Portfolio Appraising: Effective Portfolio Appraising Techniques
PPTX
Dhaka slides keys to success
PPT
DHANDHO Global Equity Investment Strategy
DOC
Performance management book
PDF
Quantitative Trading
Quantopian is Launching a Crowd-sourced Hedge Fund
Can Individual Investors Beat the Market?
Financial Engineering 1
Book summary the five rules of successful stock investing
Aikido Masterclass - Starting Your Algorithmic Investing Journey.pdf
value-1.ppt
Managing your enterprise growth by numbers by Vinod Keni | #TiEInstitute
330286200-Money-and-Risk-Management1.pdf
Equity portfolio management strategies reilly and brown.
A philosophical basis for Valuation - Mi
Conner Management Group, Investment Management, April 2014
risk management chapter 2 TYBMS SEM 6 full notes
Risk Management: Maximising Long-Term Growth Presentation
CF2-day Corporate Finance Aswath Damodaran.pdf
Smart Directions Portfolio Diversification - 2/4/2016
Portfolio Appraising: Effective Portfolio Appraising Techniques
Dhaka slides keys to success
DHANDHO Global Equity Investment Strategy
Performance management book
Quantitative Trading
Ad

More from Quantopian (20)

PPTX
Stauth common pitfalls_stock_market_modeling_pqtc_fall2018
PPTX
Tearsheet feedback webinar 10.10.18
PDF
"Three Dimensional Time: Working with Alternative Data" by Kathryn Glowinski,...
PPTX
"Alpha from Alternative Data" by Emmett Kilduff, Founder and CEO of Eagle Alpha
PPTX
"Supply Chain Earnings Diffusion" by Josh Holcroft, Head of Quantitative Rese...
PDF
“Real Time Machine Learning Architecture and Sentiment Analysis Applied to Fi...
PDF
“Market Insights Through the Lens of a Risk Model” by Olivier d'Assier, Head ...
PDF
"Maximize Alpha with Systematic Factor Testing" by Cheng Peng, Software Engin...
PDF
"Fundamental Forecasts: Methods and Timing" by Vinesh Jha, CEO of ExtractAlpha
PDF
"Deep Reinforcement Learning for Optimal Order Placement in a Limit Order Boo...
PPTX
"Making the Grade: A Look Inside the Algorithm Evaluation Process" by Dr. Jes...
PDF
"Building Diversified Portfolios that Outperform Out-of-Sample" by Dr. Marcos...
PPTX
"From Insufficient Economic data to Economic Big Data – How Trade Data is red...
PDF
"Machine Learning Approaches to Regime-aware Portfolio Management" by Michael...
PDF
"Don't Lose Your Shirt Trading Mean-Reversion" by Edith Mandel, Principal at ...
PDF
"Deep Q-Learning for Trading" by Dr. Tucker Balch, Professor of Interactive C...
PDF
"Quantum Hierarchical Risk Parity - A Quantum-Inspired Approach to Portfolio ...
PDF
"Snake Oil, Swamp Land, and Factor-Based Investing" by Gary Antonacci, author...
PPTX
"Bayesian Deep Learning: Dealing with Uncertainty and Non-Stationarity" by Dr...
PDF
"On the Bayesian Interpretation of Black–Litterman" by Dr. Gordon Ritter, Sen...
Stauth common pitfalls_stock_market_modeling_pqtc_fall2018
Tearsheet feedback webinar 10.10.18
"Three Dimensional Time: Working with Alternative Data" by Kathryn Glowinski,...
"Alpha from Alternative Data" by Emmett Kilduff, Founder and CEO of Eagle Alpha
"Supply Chain Earnings Diffusion" by Josh Holcroft, Head of Quantitative Rese...
“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 ...
"Maximize Alpha with Systematic Factor Testing" by Cheng Peng, Software Engin...
"Fundamental Forecasts: Methods and Timing" by Vinesh Jha, CEO of ExtractAlpha
"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...
"Building Diversified Portfolios that Outperform Out-of-Sample" by Dr. Marcos...
"From Insufficient Economic data to Economic Big Data – How Trade Data is red...
"Machine Learning Approaches to Regime-aware Portfolio Management" by Michael...
"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...
"Quantum Hierarchical Risk Parity - A Quantum-Inspired Approach to Portfolio ...
"Snake Oil, Swamp Land, and Factor-Based Investing" by Gary Antonacci, author...
"Bayesian Deep Learning: Dealing with Uncertainty and Non-Stationarity" by Dr...
"On the Bayesian Interpretation of Black–Litterman" by Dr. Gordon Ritter, Sen...

Recently uploaded (20)

PPTX
Introduction to Managemeng Chapter 1..pptx
PDF
final_dropping_the_baton_-_how_america_is_failing_to_use_russia_sanctions_and...
PDF
Circular Flow of Income by Dr. S. Malini
PDF
ECONOMICS AND ENTREPRENEURS LESSONSS AND
PDF
NAPF_RESPONSE_TO_THE_PENSIONS_COMMISSION_8 _2_.pdf
PPT
KPMG FA Benefits Report_FINAL_Jan 27_2010.ppt
PPTX
4.5.1 Financial Governance_Appropriation & Finance.pptx
PDF
financing insitute rbi nabard adb imf world bank insurance and credit gurantee
PPTX
Session 14-16. Capital Structure Theories.pptx
PPTX
Unilever_Financial_Analysis_Presentation.pptx
PDF
Q2 2025 :Lundin Gold Conference Call Presentation_Final.pdf
PDF
1a In Search of the Numbers ssrn 1488130 Oct 2009.pdf
PDF
Copia de Minimal 3D Technology Consulting Presentation.pdf
PDF
HCWM AND HAI FOR BHCM STUDENTS(1).Pdf and ptts
PDF
caregiving tools.pdf...........................
PDF
how_to_earn_50k_monthly_investment_guide.pdf
PDF
ECONOMICS AND ENTREPRENEURS LESSONSS AND
PPTX
Who’s winning the race to be the world’s first trillionaire.pptx
PDF
Spending, Allocation Choices, and Aging THROUGH Retirement. Are all of these ...
PDF
ABriefOverviewComparisonUCP600_ISP8_URDG_758.pdf
Introduction to Managemeng Chapter 1..pptx
final_dropping_the_baton_-_how_america_is_failing_to_use_russia_sanctions_and...
Circular Flow of Income by Dr. S. Malini
ECONOMICS AND ENTREPRENEURS LESSONSS AND
NAPF_RESPONSE_TO_THE_PENSIONS_COMMISSION_8 _2_.pdf
KPMG FA Benefits Report_FINAL_Jan 27_2010.ppt
4.5.1 Financial Governance_Appropriation & Finance.pptx
financing insitute rbi nabard adb imf world bank insurance and credit gurantee
Session 14-16. Capital Structure Theories.pptx
Unilever_Financial_Analysis_Presentation.pptx
Q2 2025 :Lundin Gold Conference Call Presentation_Final.pdf
1a In Search of the Numbers ssrn 1488130 Oct 2009.pdf
Copia de Minimal 3D Technology Consulting Presentation.pdf
HCWM AND HAI FOR BHCM STUDENTS(1).Pdf and ptts
caregiving tools.pdf...........................
how_to_earn_50k_monthly_investment_guide.pdf
ECONOMICS AND ENTREPRENEURS LESSONSS AND
Who’s winning the race to be the world’s first trillionaire.pptx
Spending, Allocation Choices, and Aging THROUGH Retirement. Are all of these ...
ABriefOverviewComparisonUCP600_ISP8_URDG_758.pdf

"A Framework-Based Approach to Building Quantitative Trading Systems" by Dr. Michael Halls-Moore, Founder of QuantStart.com

  • 1. A Framework-Based Approach toA Framework-Based Approach to Building Quantitative Trading SystemsBuilding Quantitative Trading Systems QuantCon NYC – 29QuantCon NYC – 29thth April 2017April 2017 Michael Halls-MooreMichael Halls-Moore QuantStart.comQuantStart.com
  • 2. Talk OutlineTalk Outline ● About QuantStart ● The US equities market ● Typical retail trader approach ● The need for a quantitative framework ● Portfolio management ● Risk management ● Forecasting ● Good tools ● Who to read
  • 4. About QuantStart.comAbout QuantStart.com ● My Background: – Computational fluid dynamics (CFD) research in aerospace – Quant trading infrastructure development at London-based US equities fund ● QuantStart.com: – Founded in 2012 – Talks about systematic trading, quant development, careers and machine learning – Mainly Python, R, C++ and open-source backtesting – Bringing institutional methods to retail traders
  • 5. The US Equities MarketThe US Equities Market
  • 6. The US Equities Market #1The US Equities Market #1 ● Liquid Low spreads, easy to execute quickly at desired price→ ● Exchange-traded Not trading obscure OTC instruments→ ● Easy retail access Many retail equities brokerages→ ● Can access with smaller account sizes – Cash purchases – Individual stocks far cheaper than futures ● Various benchmark indexes – S&P, Dow, Russell – Mostly interested in S&P500 universe at retail level
  • 7. The US Equities Market #2The US Equities Market #2 ● Indexes discussed in the media are misleading ● DJIA has price-weighted methodology ● S&P500 has market-capitalisation weighted methodology ● But...S&P500 is not 'the market': – By definition it disproportionately favours big firms, i.e. AAPL ● Does not include dividend reinvestment Total return→ ● A good benchmark instead would be S&P500 Total Return index
  • 8. Typical Retail Trader ApproachTypical Retail Trader Approach
  • 9. Typical Retail Trader ApproachTypical Retail Trader Approach ● Emphasis on “the best indicator” ● Charts, discretionary forecasts, pattern-matching ● Few instruments traded (“stocks that I know well”) ● Excess cash kept in brokerage account, not cash-like instruments ● No risk management: What is vol, skew, kurtosis of returns? ● Survivorship Bias: Trade stocks that have done well (e.g. AAPL) ● Too much trading: Forecast overconfidence, high costs ● No concept of Portfolio Management
  • 10. Why Is This Bad? #1Why Is This Bad? #1 ● Discretionary forecasts are too inconsistent – Tied to emotional state and cognitive biases (see Kahneman et al) ● “Lines on charts” are too ambiguous – No repeatable methodology – Far better quantitative methods available ● No risk parity – Assets with higher vol dominate portfolio returns behaviour ● No rebalancing – Risk is dynamic, so allocations need adjustment over time
  • 11. Why Is This Bad? #2Why Is This Bad? #2 ● Few instruments → No diversification ● Survivorship Bias Backtest→ optimism inflated ● Cash Positions Brokerages→ collapse taking cash with them ● No tail-risk planning – What rules are followed in 1987, 2001, 2008? – Often the worst time to tinker with a “system” ● In summary – No portfolio management, no risk management, no consistency
  • 12. The Need for a Quantitative FrameworkThe Need for a Quantitative Framework
  • 13. The Need for a Quantitative FrameworkThe Need for a Quantitative Framework ● Systematic Framework – Eliminates discretionary decision making – But requires substantial confidence and discipline! ● Risk Parity – Each asset is volatility standardised Equal “risk” in every asset→ ● Rebalancing – Risk is dynamic Periodically rebalance to reflect changing allocation of risk→ ● Position Sizing – Quantitative approach for how much to “bet” per asset ● Diversification – Enough stocks to ensure luck is less important in portfolio performance
  • 14. Performance MeasurementPerformance Measurement ● Must decompose where our performance and risk comes from ● Important for equities: Alpha, Beta and Sharpe ● Beta: Risk arising from exposure to benchmark (or market) ● Alpha: Measures the excess return on a portfolio ● Sharpe: Mean excess return divided by std of returns – But...it is a very misleading metric for a number of reasons! ● “Vol is the currency we pay for performance” - Andreas Clenow ● All measures are backward-looking
  • 16. Portfolio Management #1Portfolio Management #1 ● Requires a significant shift in thinking! ● Biggest difference between retail and institutional behaviour ● Portfolio management is not about allocation of cash but about allocation of risk – What risks am I taking in order to achieve my returns? ● The goal: – Obtain high risk-adjusted returns – Achieve good diversification – Minimise the costs of trading/rebalancing while doing so
  • 17. Portfolio Management #2Portfolio Management #2 ● Began formally with Harry Markowitz in 1950s – His essay and PhD thesis became Modern Portfolio Theory (MPT) – He, along with Sharpe and Miller, received Nobel Prize in 1990 for this ● Extended into Capital Asset Pricing Model (CAPM) – Origins of “Alpha” and “Beta” as linear regression coefficients ● Efficient Market Hypothesis (EMH) dominated in 70s/80s ● Factor Analysis Fama & French three-factor model→ ● Behavioural Economics Cognitive biases and investor→ psychology grew in importance
  • 18. Portfolio Management #3Portfolio Management #3 ● Today there is strong academic evidence for persistent equity market “anomalies”: – Value premium Graham & Dodd, Buffett→ – Size premium Small-cap stocks outperforming large-cap stocks→ – Momentum Positive serial correlation of returns→ – And others... ● Our portfolios can take advantage of these – Generate forecasts based on these anomalies – Systematically exploit them across a diversified set of stocks
  • 20. Risk Parity #1Risk Parity #1 ● Allocation based on trailing std of returns of assets – Bonds get larger allocation than equities due to lower std – Increase leverage to get similar returns to equities with lower vol ● First used by Bridgewater Associates in their “All Weather” fund (1996) – Now all major asset allocators have a risk parity fund – Each of them have a proprietary methodology ● Is sometimes called “Volatility Standardisation” ● Can have a big impact on risk-adjusted returns over long-term
  • 21. Risk Parity #2Risk Parity #2 ● We will define “risk parity” here as: – Volatility-adjusted allocations of stocks only – Higher std returns implies lower allocation – No other asset classes (don't need to worry about bonds!) ● Many ways to calculate it – Average True Range (ATR) – Trailing std of returns (250 trading days) – More technical estimates of volatility (large literature on this)
  • 22. Risk Parity #3Risk Parity #3 ● Must also take correlation into account: – No value in having thirty highly correlated stocks, even if vol-adjusted – You're taking ONE bet not THIRTY! ● Volatility Measures: – Often backward-looking and non-stationary – Says nothing about future volatility – Must be periodically re-estimated
  • 24. Portfolio Rebalancing #1Portfolio Rebalancing #1 ● Dynamically adjust risk allocation based on new information ● Another big difference between retail and institutional quants ● Volatility is dynamic – Modelled as conditional heteroskedastic (e.g. GARCH family of models) – Vol often higher in times of distress (e.g. 2008) ● Correlations are dynamic – Correlations can increase to unity in times of distress (again, 2008!)
  • 25. Portfolio Rebalancing #2Portfolio Rebalancing #2 ● To maintain risk parity positions are periodically resized – Weekly or monthly – Daily can be too “noisy” and expensive for some asset allocators ● Most trades now become rebalances – Small adjustments are made to position sizes when it is not too expensive to carry out
  • 27. Risk ManagementRisk Management ● How much to bet per desired asset? Position sizing→ ● Vol, skew and kurtosis: – What is the historical distribution of portfolio returns? ● Non-stationarity of returns: – Market regime filtering – Future is different from the past ● Counterparty Risk – Brokerage goes under (have seen this personally!) ● Trading infrastructure fails/has bugs
  • 29. Position Sizing #1Position Sizing #1 ● How much risk to take per “bet” or per stock? ● Depends upon: – Desired level of diversification More stocks means less per stock→ – Total account size Small accounts reduce number of available bets→ – Your tolerance for risk What drawdowns can you stomach over a→ particular timeframe? ● For equities in particular: – Too few stocks is just random luck Apple vs Lehman Brothers→ – Too many stocks will have high beta
  • 30. Position Sizing #2Position Sizing #2 ● Can use tools like Kelly criterion – Optimal size of a series of bets f*→ – Institutional constraints can limit optimal growth rate – “Fractional Kelly” or “Half Kelly” often used in practice ● Can target a level of desired volatility impact per stock – E.g. with a portfolio of $250,000 and risk target of 10 basis points daily vol per stock, we want each stock position to have $250 daily impact – Dividing this number ($250) by the daily std of the stock (say, $4.67), gives 250/4.67 ~= 53 shares – Increasing the risk target increases the shares purchased per asset
  • 31. Market Regime FilteringMarket Regime Filtering
  • 32. Market Regime FilteringMarket Regime Filtering ● Long-only stock strategies are often well-correlated to the market: – Become even more so in times of distress ● Basic idea is not to have high stock exposure in bear markets ● Can detect regimes in many ways: – Moving averages Index above or below its long-term moving average→ – State-space models Hidden Markov Models→ ● Why not short stocks? – Not symmetric due to availability of stock at broker and borrowing costs ● Regime filters can cause many “false positives”: – Better than the alternative of giving back substantial performance in a prolonged bear market!
  • 34. Equities DataEquities Data ● Pay for good data ● Free data sources just don't cut it for the required accuracy ● Must be survivorship-bias free Include→ graveyard tickers ● Must have historical index constituents ● Must handle ticker mapping for mergers, spinoffs etc. ● Must have separate lists of dividends and splits ● All values of OHLCV should be split-adjusted, not just close ● Ideally use minutely OHLCV bars to better estimate fill price
  • 35. BacktestingBacktesting ● Use robust backtesting software ● Most tools are “single instrument” Not good enough→ ● Should have extensible portfolio/risk management modules ● Free: Quantopian, zipline, QSTrader, PySystemTrade, others... ● Desktop/Paid: RightEdge, Deltix ● Will need to know programming Can't get away from this!→
  • 37. ForecastingForecasting ● I've left it to the end - it's discussed to death elsewhere! ● As important as the other aspects, but not more so ● Look for equity market anomalies: – Value, size, momentum, PEAD, seasonal, etc. ● Can implement a lot of these with simpler “indicators” ● Or...more complex feature extraction (deep learning) ● Boils down to making a regressive forecast on an asset – Direction, with associated strength of conviction – E.g. momentum ranking, difference between two MA indicators
  • 39. TakeawaysTakeaways ● Use a systematic portfolio management framework ● Benchmark against total return index of the stock universe ● Use risk parity for equal risk allocation ● Rebalance the portfolio to account for dynamic risk ● Choose own risk tolerance for position sizing, quantitatively ● Use a market regime filter to avoid prolonged bear markets ● Put cash in cash-like instruments ● Don't waste too much time on “the perfect indicator”
  • 40. Who To ReadWho To Read
  • 41. Who To Read #1 - BooksWho To Read #1 - Books ● W. Gray and J. Vogel: Quantitative Momentum ● A. Clenow: Stocks on the Move ● R. Carver: Systematic Trading ● G. Antonacci: Dual Momentum Investing ● L. Zacks: Equity Market Anomalies ● R. Grinold and R. Kahn: Active Portfolio Management ● D. Kahneman: Thinking Fast and Slow [for cognitive biases] ● ...some of the above are actually speaking here today!
  • 42. Who To Read #2 - ResearchWho To Read #2 - Research ● AQR Research: – https://www.aqr.com/library ● BlackRock Research: – https://www.blackrock.com/corporate/en-br/insights/blackrock-investment-institute ● Bridgewater Associates Research: – https://www.bridgewater.com/research-library/daily-observations/ ● Cantab Capital: – https://www.cantabcapital.com/we-think/ ● Alpha Architect (Wes Gray et al): – http://www.alphaarchitect.com