SlideShare a Scribd company logo
Machine Learning for Trading
Bharath Rao, Alphamatters Advisors
Is Trading Profitable?
• Is Gambling a Good Habit? I’m afraid that
Depends on who you are
• Easy to be fooled by the randomness of markets
but hard to keep getting lucky
• It’s a zero sum game
• Transaction Costs make the expected payoff
negative
So why are we here then?
• Haar Kar Jeetne Wale Ko Baazigar Kehte hain!
• I believe its possible to use math to do a one
up on markets
• Or am I fooled by randomness?
Is Machine Learning Relevant to
Trading?
• It’s relevant wherever there is lots of data –
– Trading
– Investing
– Marketing
– Drug Discovery
– NLP
– Image Processing
• The challenge is financial markets are different
from every other domain above
How are ‘markets’ different from
‘marketing’?
• Markets have time series data that’s not
stationary
• Marketing data (consumer behavior) is largely
stationary
• Geometric Brownian Motion makes markets
extremely difficult to model
• You may find patterns but they may not repeat
What is ML to start with?
• Optimization
– Classification
– Regression
How to use ML in trading?
• Compute things like trading rage
• Classify Market Condition as to calm or turbulent
• Predict Returns
• Model Volatility
• Predict Reversals
What Techniques Work
• SVM
• Neural Net
• Boosting
• Random Forest
• Linear Regression
• Deep Learning?
What features?
• What are features?
• What can be useful features
• Prices
• Volumes
• OIs
• Volatility Measures
• Premium / Discount
• Fundamentals
Steps Involved
• Understand the Driving Process: See if the data can be modeled using known
models
• Feature Selection: Identify potential predictors (technical / fundamental)
• Feature Rationalization: Prune the feature set by performing PCA on features
• Data Transformation: Normalize the data and Transform it if necessary
• Data Split: Divide data into in sample of out of sample
• Modeling: Build the ML model using in sample data; Test the same on OOS data
• Repeat the previous 2 steps about 30 times and tabulate the performance metrics
How do we Transform Data?
• Technical Indicators?
• Signal Processing?
• Time Series Models?
Real Life Example
• Finding potential Reversals in a day and Using
it for Intraday Trading
– Volume spikes turn out to be predictors
– Estimating the Trading Range is useful
– Technical Oscillators are useful as a qualifier
How to estimate the trading range?
• It’s correlated to volatility
• It’s correlated to volume
• It’s correlated to the average true range of the
last few days
Feature Selection Illustrated
What else can ML be used for?
• Fundamentals based investing
• Ranking Stocks / other assets by factors
• Option Arbitrage by Learning Greeks
Things to keep in mind while using ML
• Have an idea of the underlying stochastic process
• Have a large sample size relative to feature set
• Perform as many out of sample tests as possible
• Avoid snooping (especially while splitting)
• Keep it simple and stupid (Occam’s Razor)
Things to keep in mind contd.
• Enquire as to why the hypotheses arrived at by
the ML algorithm should work at all
• Avoid using it for HFT (unless you have super high
performance hardware)
• Avoid using it in high kurtosis strategies (like
classical trend following)
• Diversify, Diversify, Diversify……
Problems in using ML
• Overfitting
• Black Box Decision Making
• Irrepeatable data patterns
• Complex hypotheses
• Hard to diagnose failure
• Change in market microstructure can make
historical data invalid
• Impossible to model Black Swans using ML
Ho do I use ML
• Make sure I’m not dealing with geometric
brownian motion using statistical tests
• Empirically Come up with skeletons of
hypotheses and statistically validate the same
• Use ML to sharpen the hypotheses and
improve performance metrics
General Trading Mistakes
ML Metrics
• Classification: Confusion Matrix
– Precision
– Recall
• Regression: Root Mean Squared Error
Trading Metrics
• Annualized Returns
• Max Drawdown
• Sharpe
• Volatility of Returns
• Beta
• Win Ratio
• Profit per Trade
• Rolling returns on weekly, monthly, quarterly basis
• Win Ratio on weekly, monthly, quarterly basis
• Skew
• Kurtosis
• VaR
Some Gambling Concepts
• Gambler’s Fallacy
• Martingale
• Kelley’s Criterion
• Gambler’s Ruin
• Recommendations Business
• The 8th Wonder (Compounding)
Alternatives
Moral of the Story
• Ezekiel 25 17
– The path of the righteous man is beset on all sides
by the inequities of the selfish (NSE / CME, Bharat
Mata / Uncle Sam….), and the tyranny of evil men
(HFT Firms). Blessed is he (Algoji) who in the name
of charity and good will shepherds the weak
through the valley of darkness. For truly he is his
brothers’ keeper and….
Thank You!

More Related Content

PPTX
Algorithmic Trading
PPTX
Market dynamics
PPTX
Applications of Machine Learning in High Frequency Trading
PPTX
Algo Trading
PPTX
Automated Selection and Robustness for Systematic Trading Strategies by Dr. T...
PDF
Day traders crack
PDF
"Quantitative Trading as a Mathematical Science" by Dr. Haksun Li, Founder an...
PPTX
Equity Option Trading : Derivatives Market Practices
Algorithmic Trading
Market dynamics
Applications of Machine Learning in High Frequency Trading
Algo Trading
Automated Selection and Robustness for Systematic Trading Strategies by Dr. T...
Day traders crack
"Quantitative Trading as a Mathematical Science" by Dr. Haksun Li, Founder an...
Equity Option Trading : Derivatives Market Practices

What's hot (15)

DOC
technical analysis
PDF
Statistics - The Missing Link Between Technical Analysis and Algorithmic Trad...
PPTX
Presentation - IV - INTEGRATION – COMBINING TRADITIONAL TA, MP AND ORDERFLOW ...
PPTX
Portfolio management sessions 4&5 (1)
PPTX
Algorithmic Trading
PPT
Trading Style Profile Simon Liu Xinyi
PPTX
Market efficiency and portfolio theory
PDF
"Active Learning in Trading Algorithms" by David Fellah, Head of the EMEA Lin...
PDF
Big data analytics bhawani nandan prasad
PPT
Emh teach
PPT
Efficient market hypothesis
PDF
System Design & testing
PDF
Random Walks, Efficient Markets & Stock Prices
PPTX
Market efficiency and emh
PDF
From Backtesting to Live Trading by Vesna Straser at QuantCon 2016
technical analysis
Statistics - The Missing Link Between Technical Analysis and Algorithmic Trad...
Presentation - IV - INTEGRATION – COMBINING TRADITIONAL TA, MP AND ORDERFLOW ...
Portfolio management sessions 4&5 (1)
Algorithmic Trading
Trading Style Profile Simon Liu Xinyi
Market efficiency and portfolio theory
"Active Learning in Trading Algorithms" by David Fellah, Head of the EMEA Lin...
Big data analytics bhawani nandan prasad
Emh teach
Efficient market hypothesis
System Design & testing
Random Walks, Efficient Markets & Stock Prices
Market efficiency and emh
From Backtesting to Live Trading by Vesna Straser at QuantCon 2016
Ad

Similar to Machine learning for trading (20)

PPTX
"A Framework for Developing Trading Models Based on Machine Learning" by Kris...
PDF
Alexandr Honchar. Financial ML != ML and Finance
PDF
Apply AI Finance Webinar.pdf
PDF
2019_7816154.pdf
PDF
Quant trading with artificial intelligence
PPTX
Trading Engine/Robo-Advisor using Deep Reinforcement Learning
PPTX
A Sneak Peek into Artificial Intelligence Based HFT Trading Strategies
PDF
Machine Learning Trading Strategies_ The New Frontier in Quantitative Finance...
PDF
Applying Deep Learning to Enhance Momentum Trading Strategies in Stocks
PPTX
"Enhancing Statistical Significance of Backtests" by Dr. Ernest Chan, Managin...
PDF
Machine Learning for Options Trading
PPTX
Machine learning prediction of stock markets
PDF
Stock prediction and algorithmic trading
PPTX
Machine learning & Time Series Analysis
PPTX
Machine learning & Time Series Analysis , Finlab CTO 韓承佑
PPTX
Algorithmic Trading Latest Trends & Developments Lecture By Dr. Lipa Roitman
PPTX
Machine learning workshop @DYP Pune
PDF
AI in Finance: An Ensembling Architecture Incorporating Machine Learning Mode...
PPTX
How to design quant trading strategies using “R”?
PPTX
Stock market analysis using supervised machine learning
"A Framework for Developing Trading Models Based on Machine Learning" by Kris...
Alexandr Honchar. Financial ML != ML and Finance
Apply AI Finance Webinar.pdf
2019_7816154.pdf
Quant trading with artificial intelligence
Trading Engine/Robo-Advisor using Deep Reinforcement Learning
A Sneak Peek into Artificial Intelligence Based HFT Trading Strategies
Machine Learning Trading Strategies_ The New Frontier in Quantitative Finance...
Applying Deep Learning to Enhance Momentum Trading Strategies in Stocks
"Enhancing Statistical Significance of Backtests" by Dr. Ernest Chan, Managin...
Machine Learning for Options Trading
Machine learning prediction of stock markets
Stock prediction and algorithmic trading
Machine learning & Time Series Analysis
Machine learning & Time Series Analysis , Finlab CTO 韓承佑
Algorithmic Trading Latest Trends & Developments Lecture By Dr. Lipa Roitman
Machine learning workshop @DYP Pune
AI in Finance: An Ensembling Architecture Incorporating Machine Learning Mode...
How to design quant trading strategies using “R”?
Stock market analysis using supervised machine learning
Ad

Recently uploaded (20)

PPTX
Lecture (1)-Introduction.pptx business communication
PDF
Ôn tập tiếng anh trong kinh doanh nâng cao
PDF
COST SHEET- Tender and Quotation unit 2.pdf
PPTX
Principles of Marketing, Industrial, Consumers,
PDF
Outsourced Audit & Assurance in USA Why Globus Finanza is Your Trusted Choice
PDF
Cours de Système d'information about ERP.pdf
PDF
Unit 1 Cost Accounting - Cost sheet
PPTX
New Microsoft PowerPoint Presentation - Copy.pptx
PDF
Stem Cell Market Report | Trends, Growth & Forecast 2025-2034
PDF
Laughter Yoga Basic Learning Workshop Manual
PPTX
Probability Distribution, binomial distribution, poisson distribution
PDF
Katrina Stoneking: Shaking Up the Alcohol Beverage Industry
PDF
Deliverable file - Regulatory guideline analysis.pdf
PPTX
Dragon_Fruit_Cultivation_in Nepal ppt.pptx
PDF
Digital Marketing & E-commerce Certificate Glossary.pdf.................
PPTX
HR Introduction Slide (1).pptx on hr intro
PDF
Power and position in leadershipDOC-20250808-WA0011..pdf
PDF
How to Get Funding for Your Trucking Business
PPTX
svnfcksanfskjcsnvvjknsnvsdscnsncxasxa saccacxsax
PPT
Lecture 3344;;,,(,(((((((((((((((((((((((
Lecture (1)-Introduction.pptx business communication
Ôn tập tiếng anh trong kinh doanh nâng cao
COST SHEET- Tender and Quotation unit 2.pdf
Principles of Marketing, Industrial, Consumers,
Outsourced Audit & Assurance in USA Why Globus Finanza is Your Trusted Choice
Cours de Système d'information about ERP.pdf
Unit 1 Cost Accounting - Cost sheet
New Microsoft PowerPoint Presentation - Copy.pptx
Stem Cell Market Report | Trends, Growth & Forecast 2025-2034
Laughter Yoga Basic Learning Workshop Manual
Probability Distribution, binomial distribution, poisson distribution
Katrina Stoneking: Shaking Up the Alcohol Beverage Industry
Deliverable file - Regulatory guideline analysis.pdf
Dragon_Fruit_Cultivation_in Nepal ppt.pptx
Digital Marketing & E-commerce Certificate Glossary.pdf.................
HR Introduction Slide (1).pptx on hr intro
Power and position in leadershipDOC-20250808-WA0011..pdf
How to Get Funding for Your Trucking Business
svnfcksanfskjcsnvvjknsnvsdscnsncxasxa saccacxsax
Lecture 3344;;,,(,(((((((((((((((((((((((

Machine learning for trading

  • 1. Machine Learning for Trading Bharath Rao, Alphamatters Advisors
  • 2. Is Trading Profitable? • Is Gambling a Good Habit? I’m afraid that Depends on who you are • Easy to be fooled by the randomness of markets but hard to keep getting lucky • It’s a zero sum game • Transaction Costs make the expected payoff negative
  • 3. So why are we here then? • Haar Kar Jeetne Wale Ko Baazigar Kehte hain! • I believe its possible to use math to do a one up on markets • Or am I fooled by randomness?
  • 4. Is Machine Learning Relevant to Trading? • It’s relevant wherever there is lots of data – – Trading – Investing – Marketing – Drug Discovery – NLP – Image Processing • The challenge is financial markets are different from every other domain above
  • 5. How are ‘markets’ different from ‘marketing’? • Markets have time series data that’s not stationary • Marketing data (consumer behavior) is largely stationary • Geometric Brownian Motion makes markets extremely difficult to model • You may find patterns but they may not repeat
  • 6. What is ML to start with? • Optimization – Classification – Regression
  • 7. How to use ML in trading? • Compute things like trading rage • Classify Market Condition as to calm or turbulent • Predict Returns • Model Volatility • Predict Reversals
  • 8. What Techniques Work • SVM • Neural Net • Boosting • Random Forest • Linear Regression • Deep Learning?
  • 9. What features? • What are features? • What can be useful features • Prices • Volumes • OIs • Volatility Measures • Premium / Discount • Fundamentals
  • 10. Steps Involved • Understand the Driving Process: See if the data can be modeled using known models • Feature Selection: Identify potential predictors (technical / fundamental) • Feature Rationalization: Prune the feature set by performing PCA on features • Data Transformation: Normalize the data and Transform it if necessary • Data Split: Divide data into in sample of out of sample • Modeling: Build the ML model using in sample data; Test the same on OOS data • Repeat the previous 2 steps about 30 times and tabulate the performance metrics
  • 11. How do we Transform Data? • Technical Indicators? • Signal Processing? • Time Series Models?
  • 12. Real Life Example • Finding potential Reversals in a day and Using it for Intraday Trading – Volume spikes turn out to be predictors – Estimating the Trading Range is useful – Technical Oscillators are useful as a qualifier
  • 13. How to estimate the trading range? • It’s correlated to volatility • It’s correlated to volume • It’s correlated to the average true range of the last few days
  • 15. What else can ML be used for? • Fundamentals based investing • Ranking Stocks / other assets by factors • Option Arbitrage by Learning Greeks
  • 16. Things to keep in mind while using ML • Have an idea of the underlying stochastic process • Have a large sample size relative to feature set • Perform as many out of sample tests as possible • Avoid snooping (especially while splitting) • Keep it simple and stupid (Occam’s Razor)
  • 17. Things to keep in mind contd. • Enquire as to why the hypotheses arrived at by the ML algorithm should work at all • Avoid using it for HFT (unless you have super high performance hardware) • Avoid using it in high kurtosis strategies (like classical trend following) • Diversify, Diversify, Diversify……
  • 18. Problems in using ML • Overfitting • Black Box Decision Making • Irrepeatable data patterns • Complex hypotheses • Hard to diagnose failure • Change in market microstructure can make historical data invalid • Impossible to model Black Swans using ML
  • 19. Ho do I use ML • Make sure I’m not dealing with geometric brownian motion using statistical tests • Empirically Come up with skeletons of hypotheses and statistically validate the same • Use ML to sharpen the hypotheses and improve performance metrics
  • 21. ML Metrics • Classification: Confusion Matrix – Precision – Recall • Regression: Root Mean Squared Error
  • 22. Trading Metrics • Annualized Returns • Max Drawdown • Sharpe • Volatility of Returns • Beta • Win Ratio • Profit per Trade • Rolling returns on weekly, monthly, quarterly basis • Win Ratio on weekly, monthly, quarterly basis • Skew • Kurtosis • VaR
  • 23. Some Gambling Concepts • Gambler’s Fallacy • Martingale • Kelley’s Criterion • Gambler’s Ruin • Recommendations Business • The 8th Wonder (Compounding)
  • 25. Moral of the Story • Ezekiel 25 17 – The path of the righteous man is beset on all sides by the inequities of the selfish (NSE / CME, Bharat Mata / Uncle Sam….), and the tyranny of evil men (HFT Firms). Blessed is he (Algoji) who in the name of charity and good will shepherds the weak through the valley of darkness. For truly he is his brothers’ keeper and….