SlideShare a Scribd company logo
1 of 21
How To Build Your Own Pairs Trading
Algorithm Trading System

Quantopian Meetup
Gary Chan
Introduction
• Started programming at a young age
• Played poker as main source of income for a few
years
• Money is just a way to keep score
• Became interested in stock market
• Read ~70 textbooks, mostly corporate finance,
CFA curriculum
• Currently running an algorithmic trading system
out of my apartment
Expectations
• I’m not here to divulge secrets
• Teach a man to fish, not give him a fish
• You will see how easy the pairs trading model is
to understand and build
• Deployable by retail investors
• Seeing is believing
• You will not be able to build your own
tomorrow… but one day… if you want it badly
enough
• It’s a small world, so share ideas
Why you can beat the professionals
• Definition of professionals
• Algorithmic does not mean high
frequency
• HFT is not for retail investors
• Strategy capacity
• Find a niche
Disclaimers
• A lot of learning, before this came to fruition
• Content here will not be complete due to time
constraints
• Survivorship bias, Look ahead bias
• Model risk, implementation risk, execution
risk, over parameterization
• Random models can have profitable backtests
• I’m not responsible if you lose money
Algorithmic Trading is Easy
•
•
•
•
•
•

What does easy / hard mean?
Info, books, tools, cheaply or freely available
Yahoo, Google, Morningstar, Edgar, Quantopian
Visual Studio Express, MySQL, R
Many textbooks written on the subject
Low capital requirements (30K minimum)
compared to other ventures
• Backtest before you use real money!!
• Higher quality data will cost more money
My Current System
•
•
•
•
•

Low frequency
Single computer, 3 years old
Runs on Wifi from my apartment
Started coding Oct 2012
Started forward testing play money in March
2013
• Started forward testing real money June 2013
• Current performance consistent with backtests
• Just started using cloud computing
My Cloud
My Cloud Part 2
Backtesting
• Profitable backtests does not mean good
• You need a valid model
• Live trading WILL underperform backtests
How A Good Backtest Looks
• Consistent, high R Squared
• Similar parameters have similar equity curves
Key Info From Backtests
•
•
•
•

Portfolio of 39 pairs
Average of 12 to 18 pairs with opened positions, $5400 max drawdown
$10k sized legs in backtests, $395 average profit per trade
81.3% winning trades, 4540 trades, 26 day average holding period
Pairs Trading Books
• Contains Code
• Complete manual to putting together your own system
Types of Investment Strategies
• Mean Reversion
– Buy low, sell high / Sell high, buy low
– Fundamental Analysis
– Statistical Arbitrage

• Momentum
– Sell low, buy lower / Buy high, sell higher
– News

• Technical analysis does not work
Necessary Math
•
•
•
•
•
•
•

Basic statistics
Linear algebra
Standard deviations, regressions
Types of distributions (normal, logarithmic)
Random walks
Stationary (mean reverting) series
Cointegration
Mean Reversion Example #1
•
•
•
•
•

Keep an opened mind
Everything can be measured in money
If you don’t believe me, put it on EBay
Fear can be measured in dollars
Unwarranted fear -> Sell volatility to profit
Mean Reversion Example #2
•
•
•
•
•

Stocks move in random walks
Some stocks move together
Spread between the stocks are mean reverting
Buy low, sell high on the spread
Statistical arbitrage means you win most of the
time, not all the time
• Buyouts and bankruptcies result in large losses
• Diversification is a must
• Learn some corporate finance / fundamentals
Case Study, GLD and IAU
• Two gold ETF’s
• Pull end of day prices from Yahoo Finance into
csv files
• Do a linear regression
• Calculate the spread
• Graph of spread is mean reverting
• Find #Stdevs to enter / exit trade
• Optimize parameters
Next Steps
• Try higher quality data
• You could trade this by hand + excel, but
better to automate the process
• Many systems are built in excel
• Optimize the code
• Backtest until you find a profitable strategy
• Use a brokerage with an API, sample code
• Forward test with play money
Next Steps Part 2
•
•
•
•
•
•
•

Execution, order, position management
Test with small amounts of real money
Tweak your system
Ramp up trading size if still profitable
Exhaust universe for the strategy
Find new strategies
Never stop learning
The End
• Ernest P Chan - Quantitative Trading: How to Build
Your Own Algorithmic Trading Business (Wiley Trading)
• Ganapathy Vidyamurthy - Pairs Trading: Quantitative
Methods and Analysis (Wiley Finance)
• R - http://www.r-project.org/ (like Matlab)
Yahoo, Google, Morningstar, Edgar, Quantopian
• Visual Studio Express, MySQL, R
• garychan7@gmail.com
• https://twitter.com/RITrading - I tweet my trades here

More Related Content

What's hot

"Quantitative Trading as a Mathematical Science" by Dr. Haksun Li, Founder an...
"Quantitative Trading as a Mathematical Science" by Dr. Haksun Li, Founder an..."Quantitative Trading as a Mathematical Science" by Dr. Haksun Li, Founder an...
"Quantitative Trading as a Mathematical Science" by Dr. Haksun Li, Founder an...
Quantopian
 

What's hot (20)

Modeling the Stock Market: Common pitfalls and how to avoid them!
Modeling the Stock Market: Common pitfalls and how to avoid them!Modeling the Stock Market: Common pitfalls and how to avoid them!
Modeling the Stock Market: Common pitfalls and how to avoid them!
 
Should You Build Your Own Backtester? by Michael Halls-Moore at QuantCon 2016
Should You Build Your Own Backtester? by Michael Halls-Moore at QuantCon 2016Should You Build Your Own Backtester? by Michael Halls-Moore at QuantCon 2016
Should You Build Your Own Backtester? by Michael Halls-Moore at QuantCon 2016
 
Quantopian is Launching a Crowd-sourced Hedge Fund
Quantopian is Launching a Crowd-sourced Hedge FundQuantopian is Launching a Crowd-sourced Hedge Fund
Quantopian is Launching a Crowd-sourced Hedge Fund
 
Stauth common pitfalls_stock_market_modeling_pqtc_fall2018
Stauth common pitfalls_stock_market_modeling_pqtc_fall2018Stauth common pitfalls_stock_market_modeling_pqtc_fall2018
Stauth common pitfalls_stock_market_modeling_pqtc_fall2018
 
"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. ...
 
Being open (source) in the traditionally secretive field of quant finance.
Being open (source) in the traditionally secretive field of quant finance.Being open (source) in the traditionally secretive field of quant finance.
Being open (source) in the traditionally secretive field of quant finance.
 
"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...
 
"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...
 
"Quantitative Trading as a Mathematical Science" by Dr. Haksun Li, Founder an...
"Quantitative Trading as a Mathematical Science" by Dr. Haksun Li, Founder an..."Quantitative Trading as a Mathematical Science" by Dr. Haksun Li, Founder an...
"Quantitative Trading as a Mathematical Science" by Dr. Haksun Li, Founder an...
 
Algorithmic Trading Latest Trends & Developments Lecture By Dr. Lipa Roitman
Algorithmic Trading Latest Trends & Developments Lecture By Dr. Lipa RoitmanAlgorithmic Trading Latest Trends & Developments Lecture By Dr. Lipa Roitman
Algorithmic Trading Latest Trends & Developments Lecture By Dr. Lipa Roitman
 
"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 ...
 
A Guided Tour of Machine Learning for Traders by Tucker Balch at QuantCon 2016
A Guided Tour of Machine Learning for Traders by Tucker Balch at QuantCon 2016A Guided Tour of Machine Learning for Traders by Tucker Balch at QuantCon 2016
A Guided Tour of Machine Learning for Traders by Tucker Balch at QuantCon 2016
 
Using Domain Expertise to Improve Text Analysis, Evan Schnidman, Founder and ...
Using Domain Expertise to Improve Text Analysis, Evan Schnidman, Founder and ...Using Domain Expertise to Improve Text Analysis, Evan Schnidman, Founder and ...
Using Domain Expertise to Improve Text Analysis, Evan Schnidman, Founder and ...
 
Algorithmic Finance Meetup: Starmine Short Interest Talk
Algorithmic Finance Meetup: Starmine Short Interest Talk Algorithmic Finance Meetup: Starmine Short Interest Talk
Algorithmic Finance Meetup: Starmine Short Interest Talk
 
Risk Management: Maximising Long-Term Growth Presentation
Risk Management: Maximising Long-Term Growth PresentationRisk Management: Maximising Long-Term Growth Presentation
Risk Management: Maximising Long-Term Growth Presentation
 
The Genesis of an Order Type by Dan Aisen, Co-founder and Quantitative Develo...
The Genesis of an Order Type by Dan Aisen, Co-founder and Quantitative Develo...The Genesis of an Order Type by Dan Aisen, Co-founder and Quantitative Develo...
The Genesis of an Order Type by Dan Aisen, Co-founder and Quantitative Develo...
 
Turkey or trader? by Jeremiah Lowin, Director of Risk Management at Kokino LLC
Turkey or trader? by Jeremiah Lowin, Director of Risk Management at Kokino LLCTurkey or trader? by Jeremiah Lowin, Director of Risk Management at Kokino LLC
Turkey or trader? by Jeremiah Lowin, Director of Risk Management at Kokino LLC
 
Tearsheet feedback webinar 10.10.18
Tearsheet feedback webinar 10.10.18Tearsheet feedback webinar 10.10.18
Tearsheet feedback webinar 10.10.18
 
QuantConnect - Options Backtesting
QuantConnect - Options BacktestingQuantConnect - Options Backtesting
QuantConnect - Options Backtesting
 
Futures Trading Strategies on SGX - India chapter in AFACT in Singapore
Futures Trading Strategies on SGX - India chapter in AFACT in SingaporeFutures Trading Strategies on SGX - India chapter in AFACT in Singapore
Futures Trading Strategies on SGX - India chapter in AFACT in Singapore
 

Viewers also liked

Algorithmic Trading-An Introduction
Algorithmic Trading-An IntroductionAlgorithmic Trading-An Introduction
Algorithmic Trading-An Introduction
Rajeev Ranjan
 
Finding Alpha from Stock Buyback Announcements in the Quantopian Research Pla...
Finding Alpha from Stock Buyback Announcements in the Quantopian Research Pla...Finding Alpha from Stock Buyback Announcements in the Quantopian Research Pla...
Finding Alpha from Stock Buyback Announcements in the Quantopian Research Pla...
Quantopian
 
Welcome to QuantCon 2015 by John “Fawce” Fawcett, Founder and CEO of Quantopian
Welcome to QuantCon 2015 by John “Fawce” Fawcett, Founder and CEO of QuantopianWelcome to QuantCon 2015 by John “Fawce” Fawcett, Founder and CEO of Quantopian
Welcome to QuantCon 2015 by John “Fawce” Fawcett, Founder and CEO of Quantopian
Quantopian
 
Self-Directed Investing by Akhil Lodha, Co-founder of Sliced Investing, and M...
Self-Directed Investing by Akhil Lodha, Co-founder of Sliced Investing, and M...Self-Directed Investing by Akhil Lodha, Co-founder of Sliced Investing, and M...
Self-Directed Investing by Akhil Lodha, Co-founder of Sliced Investing, and M...
Quantopian
 
알고리즘트레이딩(우투증권)
알고리즘트레이딩(우투증권)알고리즘트레이딩(우투증권)
알고리즘트레이딩(우투증권)
Smith Kim
 

Viewers also liked (19)

The Mobile Revolution and the Future of Modern Data Collection by Joe Reising...
The Mobile Revolution and the Future of Modern Data Collection by Joe Reising...The Mobile Revolution and the Future of Modern Data Collection by Joe Reising...
The Mobile Revolution and the Future of Modern Data Collection by Joe Reising...
 
EXANTE Algorithmic Trading: Practical Aspects
EXANTE Algorithmic Trading: Practical AspectsEXANTE Algorithmic Trading: Practical Aspects
EXANTE Algorithmic Trading: Practical Aspects
 
Trade Like a Chimp: Unleash Your Inner Primate by Andreas Clenow at QuantCon ...
Trade Like a Chimp: Unleash Your Inner Primate by Andreas Clenow at QuantCon ...Trade Like a Chimp: Unleash Your Inner Primate by Andreas Clenow at QuantCon ...
Trade Like a Chimp: Unleash Your Inner Primate by Andreas Clenow at QuantCon ...
 
Algorithmic Trading and FIX Protocol
Algorithmic Trading and FIX ProtocolAlgorithmic Trading and FIX Protocol
Algorithmic Trading and FIX Protocol
 
Algorithmic Trading-An Introduction
Algorithmic Trading-An IntroductionAlgorithmic Trading-An Introduction
Algorithmic Trading-An Introduction
 
Careers in Systematic Investing: Advice and Perspective at the End by Matthew...
Careers in Systematic Investing: Advice and Perspective at the End by Matthew...Careers in Systematic Investing: Advice and Perspective at the End by Matthew...
Careers in Systematic Investing: Advice and Perspective at the End by Matthew...
 
Algorithmic Trading
Algorithmic TradingAlgorithmic Trading
Algorithmic Trading
 
Changing Notions of Risk Management in Financial Markets
Changing Notions of Risk Management in Financial MarketsChanging Notions of Risk Management in Financial Markets
Changing Notions of Risk Management in Financial Markets
 
(Krx 홍콩+세미나+참가후기) 세미나+발표자료_101004
(Krx 홍콩+세미나+참가후기) 세미나+발표자료_101004(Krx 홍콩+세미나+참가후기) 세미나+발표자료_101004
(Krx 홍콩+세미나+참가후기) 세미나+발표자료_101004
 
Finding Alpha from Stock Buyback Announcements in the Quantopian Research Pla...
Finding Alpha from Stock Buyback Announcements in the Quantopian Research Pla...Finding Alpha from Stock Buyback Announcements in the Quantopian Research Pla...
Finding Alpha from Stock Buyback Announcements in the Quantopian Research Pla...
 
Quantinsti’s webinar on algorithmic trading
Quantinsti’s webinar on algorithmic tradingQuantinsti’s webinar on algorithmic trading
Quantinsti’s webinar on algorithmic trading
 
Welcome to QuantCon 2015 by John “Fawce” Fawcett, Founder and CEO of Quantopian
Welcome to QuantCon 2015 by John “Fawce” Fawcett, Founder and CEO of QuantopianWelcome to QuantCon 2015 by John “Fawce” Fawcett, Founder and CEO of Quantopian
Welcome to QuantCon 2015 by John “Fawce” Fawcett, Founder and CEO of Quantopian
 
Self-Directed Investing by Akhil Lodha, Co-founder of Sliced Investing, and M...
Self-Directed Investing by Akhil Lodha, Co-founder of Sliced Investing, and M...Self-Directed Investing by Akhil Lodha, Co-founder of Sliced Investing, and M...
Self-Directed Investing by Akhil Lodha, Co-founder of Sliced Investing, and M...
 
Crowd-sourced Alpha: The Search for the Holy Grail of Investing
 Crowd-sourced Alpha: The Search for the Holy Grail of Investing Crowd-sourced Alpha: The Search for the Holy Grail of Investing
Crowd-sourced Alpha: The Search for the Holy Grail of Investing
 
Presentation Robot Trading By Fisline
Presentation Robot Trading By FislinePresentation Robot Trading By Fisline
Presentation Robot Trading By Fisline
 
Algorithmic trading
Algorithmic tradingAlgorithmic trading
Algorithmic trading
 
알고리즘트레이딩(우투증권)
알고리즘트레이딩(우투증권)알고리즘트레이딩(우투증권)
알고리즘트레이딩(우투증권)
 
Modeling Transaction Costs for Algorithmic Strategies
Modeling Transaction Costs for Algorithmic StrategiesModeling Transaction Costs for Algorithmic Strategies
Modeling Transaction Costs for Algorithmic Strategies
 
Peculiarities of Volatilities by Ernest Chan at QuantCon 2016
Peculiarities of Volatilities by Ernest Chan at QuantCon 2016Peculiarities of Volatilities by Ernest Chan at QuantCon 2016
Peculiarities of Volatilities by Ernest Chan at QuantCon 2016
 

Similar to Pairs Trading from NYC Algorithmic Trading Meetup November '13

Wagga Digital Enterprise Training Session 4 (eCommerce)
Wagga Digital Enterprise Training Session 4 (eCommerce)Wagga Digital Enterprise Training Session 4 (eCommerce)
Wagga Digital Enterprise Training Session 4 (eCommerce)
Dan Winson
 

Similar to Pairs Trading from NYC Algorithmic Trading Meetup November '13 (20)

Algorithmic Trading
Algorithmic TradingAlgorithmic Trading
Algorithmic Trading
 
Artificial Intelligence Working On Investment Management
Artificial Intelligence Working On Investment ManagementArtificial Intelligence Working On Investment Management
Artificial Intelligence Working On Investment Management
 
How to become a Full Time Trader - Nooresh Merani
How to become a Full Time Trader - Nooresh Merani How to become a Full Time Trader - Nooresh Merani
How to become a Full Time Trader - Nooresh Merani
 
How to become a Full Time Trader
How to become a Full Time TraderHow to become a Full Time Trader
How to become a Full Time Trader
 
Kleos Africa webinar Babatunde Akin-Moses - Business Valuation Simplified
Kleos Africa webinar   Babatunde Akin-Moses - Business Valuation SimplifiedKleos Africa webinar   Babatunde Akin-Moses - Business Valuation Simplified
Kleos Africa webinar Babatunde Akin-Moses - Business Valuation Simplified
 
Accounting Technology and Systems Selection
Accounting Technology and Systems SelectionAccounting Technology and Systems Selection
Accounting Technology and Systems Selection
 
The Future of Prop Trading Webinar with BigMikeTrading.com
The Future of Prop Trading Webinar with BigMikeTrading.comThe Future of Prop Trading Webinar with BigMikeTrading.com
The Future of Prop Trading Webinar with BigMikeTrading.com
 
Singapore iFest 2013
Singapore iFest 2013Singapore iFest 2013
Singapore iFest 2013
 
Developer's Guide to Running Sales Teams
Developer's Guide to Running Sales TeamsDeveloper's Guide to Running Sales Teams
Developer's Guide to Running Sales Teams
 
SalesKoch Playbook
SalesKoch PlaybookSalesKoch Playbook
SalesKoch Playbook
 
A prop firm's transition to building multi product, multi-market discretionar...
A prop firm's transition to building multi product, multi-market discretionar...A prop firm's transition to building multi product, multi-market discretionar...
A prop firm's transition to building multi product, multi-market discretionar...
 
Reducing the hit &-miss in scaling up an agent network
Reducing the hit &-miss in scaling up an agent networkReducing the hit &-miss in scaling up an agent network
Reducing the hit &-miss in scaling up an agent network
 
Zero to 100 - Part 6: Experiences putting Theory into Practice
Zero to 100 - Part 6: Experiences putting Theory into PracticeZero to 100 - Part 6: Experiences putting Theory into Practice
Zero to 100 - Part 6: Experiences putting Theory into Practice
 
Myths, Lies and Illusions of AB and Split Testing
Myths, Lies and Illusions of AB and Split TestingMyths, Lies and Illusions of AB and Split Testing
Myths, Lies and Illusions of AB and Split Testing
 
Wagga Digital Enterprise Training Session 4 (eCommerce)
Wagga Digital Enterprise Training Session 4 (eCommerce)Wagga Digital Enterprise Training Session 4 (eCommerce)
Wagga Digital Enterprise Training Session 4 (eCommerce)
 
Optimize Your Funnel By Getting Inside Your Buyer's Head
Optimize Your Funnel By Getting Inside Your Buyer's HeadOptimize Your Funnel By Getting Inside Your Buyer's Head
Optimize Your Funnel By Getting Inside Your Buyer's Head
 
DrMustansar_69_16723_1_Lecture 09 Stock Markets.pptx
DrMustansar_69_16723_1_Lecture 09 Stock Markets.pptxDrMustansar_69_16723_1_Lecture 09 Stock Markets.pptx
DrMustansar_69_16723_1_Lecture 09 Stock Markets.pptx
 
Ramon ray
Ramon rayRamon ray
Ramon ray
 
Jeff Szczepanski
Jeff SzczepanskiJeff Szczepanski
Jeff Szczepanski
 
[On Demand Webinar] How to successfully invest in property with real estate i...
[On Demand Webinar] How to successfully invest in property with real estate i...[On Demand Webinar] How to successfully invest in property with real estate i...
[On Demand Webinar] How to successfully invest in property with real estate i...
 

More from 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
 

More from Quantopian (20)

"Three Dimensional Time: Working with Alternative Data" by Kathryn Glowinski,...
"Three Dimensional Time: Working with Alternative Data" by Kathryn Glowinski,..."Three Dimensional Time: Working with Alternative Data" by Kathryn Glowinski,...
"Three Dimensional Time: Working with Alternative Data" by Kathryn Glowinski,...
 
"Alpha from Alternative Data" by Emmett Kilduff, Founder and CEO of Eagle Alpha
"Alpha from Alternative Data" by Emmett Kilduff,  Founder and CEO of Eagle Alpha"Alpha from Alternative Data" by Emmett Kilduff,  Founder and CEO of Eagle Alpha
"Alpha from Alternative Data" by Emmett Kilduff, Founder and CEO of Eagle Alpha
 
"Supply Chain Earnings Diffusion" by Josh Holcroft, Head of Quantitative Rese...
"Supply Chain Earnings Diffusion" by Josh Holcroft, Head of Quantitative Rese..."Supply Chain Earnings Diffusion" by Josh Holcroft, Head of Quantitative Rese...
"Supply Chain Earnings Diffusion" by Josh Holcroft, Head of Quantitative Rese...
 
"Portfolio Optimisation When You Don’t Know the Future (or the Past)" by Rob...
"Portfolio Optimisation When You Don’t Know the Future (or the Past)" by Rob..."Portfolio Optimisation When You Don’t Know the Future (or the Past)" by Rob...
"Portfolio Optimisation When You Don’t Know the Future (or the Past)" by Rob...
 
"Quant Trading for a Living – Lessons from a Life in the Trenches" by Andreas...
"Quant Trading for a Living – Lessons from a Life in the Trenches" by Andreas..."Quant Trading for a Living – Lessons from a Life in the Trenches" by Andreas...
"Quant Trading for a Living – Lessons from a Life in the Trenches" by Andreas...
 
“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...
 
"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...
 
"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...
 

Recently uploaded

Call Girls in New Ashok Nagar, (delhi) call me [9953056974] escort service 24X7
Call Girls in New Ashok Nagar, (delhi) call me [9953056974] escort service 24X7Call Girls in New Ashok Nagar, (delhi) call me [9953056974] escort service 24X7
Call Girls in New Ashok Nagar, (delhi) call me [9953056974] escort service 24X7
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
From Luxury Escort Service Kamathipura : 9352852248 Make on-demand Arrangemen...
From Luxury Escort Service Kamathipura : 9352852248 Make on-demand Arrangemen...From Luxury Escort Service Kamathipura : 9352852248 Make on-demand Arrangemen...
From Luxury Escort Service Kamathipura : 9352852248 Make on-demand Arrangemen...
From Luxury Escort : 9352852248 Make on-demand Arrangements Near yOU
 
VIP Independent Call Girls in Andheri 🌹 9920725232 ( Call Me ) Mumbai Escorts...
VIP Independent Call Girls in Andheri 🌹 9920725232 ( Call Me ) Mumbai Escorts...VIP Independent Call Girls in Andheri 🌹 9920725232 ( Call Me ) Mumbai Escorts...
VIP Independent Call Girls in Andheri 🌹 9920725232 ( Call Me ) Mumbai Escorts...
dipikadinghjn ( Why You Choose Us? ) Escorts
 
VIP Independent Call Girls in Bandra West 🌹 9920725232 ( Call Me ) Mumbai Esc...
VIP Independent Call Girls in Bandra West 🌹 9920725232 ( Call Me ) Mumbai Esc...VIP Independent Call Girls in Bandra West 🌹 9920725232 ( Call Me ) Mumbai Esc...
VIP Independent Call Girls in Bandra West 🌹 9920725232 ( Call Me ) Mumbai Esc...
dipikadinghjn ( Why You Choose Us? ) Escorts
 

Recently uploaded (20)

Mira Road Memorable Call Grls Number-9833754194-Bhayandar Speciallty Call Gir...
Mira Road Memorable Call Grls Number-9833754194-Bhayandar Speciallty Call Gir...Mira Road Memorable Call Grls Number-9833754194-Bhayandar Speciallty Call Gir...
Mira Road Memorable Call Grls Number-9833754194-Bhayandar Speciallty Call Gir...
 
Call Girls in New Ashok Nagar, (delhi) call me [9953056974] escort service 24X7
Call Girls in New Ashok Nagar, (delhi) call me [9953056974] escort service 24X7Call Girls in New Ashok Nagar, (delhi) call me [9953056974] escort service 24X7
Call Girls in New Ashok Nagar, (delhi) call me [9953056974] escort service 24X7
 
Call Girls in New Friends Colony Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escort...
Call Girls in New Friends Colony Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escort...Call Girls in New Friends Colony Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escort...
Call Girls in New Friends Colony Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escort...
 
Booking open Available Pune Call Girls Talegaon Dabhade 6297143586 Call Hot ...
Booking open Available Pune Call Girls Talegaon Dabhade  6297143586 Call Hot ...Booking open Available Pune Call Girls Talegaon Dabhade  6297143586 Call Hot ...
Booking open Available Pune Call Girls Talegaon Dabhade 6297143586 Call Hot ...
 
(Vedika) Low Rate Call Girls in Pune Call Now 8250077686 Pune Escorts 24x7
(Vedika) Low Rate Call Girls in Pune Call Now 8250077686 Pune Escorts 24x7(Vedika) Low Rate Call Girls in Pune Call Now 8250077686 Pune Escorts 24x7
(Vedika) Low Rate Call Girls in Pune Call Now 8250077686 Pune Escorts 24x7
 
Vip Call US 📞 7738631006 ✅Call Girls In Sakinaka ( Mumbai )
Vip Call US 📞 7738631006 ✅Call Girls In Sakinaka ( Mumbai )Vip Call US 📞 7738631006 ✅Call Girls In Sakinaka ( Mumbai )
Vip Call US 📞 7738631006 ✅Call Girls In Sakinaka ( Mumbai )
 
The Economic History of the U.S. Lecture 23.pdf
The Economic History of the U.S. Lecture 23.pdfThe Economic History of the U.S. Lecture 23.pdf
The Economic History of the U.S. Lecture 23.pdf
 
From Luxury Escort Service Kamathipura : 9352852248 Make on-demand Arrangemen...
From Luxury Escort Service Kamathipura : 9352852248 Make on-demand Arrangemen...From Luxury Escort Service Kamathipura : 9352852248 Make on-demand Arrangemen...
From Luxury Escort Service Kamathipura : 9352852248 Make on-demand Arrangemen...
 
Indore Real Estate Market Trends Report.pdf
Indore Real Estate Market Trends Report.pdfIndore Real Estate Market Trends Report.pdf
Indore Real Estate Market Trends Report.pdf
 
00_Main ppt_MeetupDORA&CyberSecurity.pptx
00_Main ppt_MeetupDORA&CyberSecurity.pptx00_Main ppt_MeetupDORA&CyberSecurity.pptx
00_Main ppt_MeetupDORA&CyberSecurity.pptx
 
The Economic History of the U.S. Lecture 25.pdf
The Economic History of the U.S. Lecture 25.pdfThe Economic History of the U.S. Lecture 25.pdf
The Economic History of the U.S. Lecture 25.pdf
 
The Economic History of the U.S. Lecture 26.pdf
The Economic History of the U.S. Lecture 26.pdfThe Economic History of the U.S. Lecture 26.pdf
The Economic History of the U.S. Lecture 26.pdf
 
Solution Manual for Principles of Corporate Finance 14th Edition by Richard B...
Solution Manual for Principles of Corporate Finance 14th Edition by Richard B...Solution Manual for Principles of Corporate Finance 14th Edition by Richard B...
Solution Manual for Principles of Corporate Finance 14th Edition by Richard B...
 
Booking open Available Pune Call Girls Wadgaon Sheri 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Wadgaon Sheri  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Wadgaon Sheri  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Wadgaon Sheri 6297143586 Call Hot Ind...
 
02_Fabio Colombo_Accenture_MeetupDora&Cybersecurity.pptx
02_Fabio Colombo_Accenture_MeetupDora&Cybersecurity.pptx02_Fabio Colombo_Accenture_MeetupDora&Cybersecurity.pptx
02_Fabio Colombo_Accenture_MeetupDora&Cybersecurity.pptx
 
VIP Independent Call Girls in Andheri 🌹 9920725232 ( Call Me ) Mumbai Escorts...
VIP Independent Call Girls in Andheri 🌹 9920725232 ( Call Me ) Mumbai Escorts...VIP Independent Call Girls in Andheri 🌹 9920725232 ( Call Me ) Mumbai Escorts...
VIP Independent Call Girls in Andheri 🌹 9920725232 ( Call Me ) Mumbai Escorts...
 
VVIP Pune Call Girls Katraj (7001035870) Pune Escorts Nearby with Complete Sa...
VVIP Pune Call Girls Katraj (7001035870) Pune Escorts Nearby with Complete Sa...VVIP Pune Call Girls Katraj (7001035870) Pune Escorts Nearby with Complete Sa...
VVIP Pune Call Girls Katraj (7001035870) Pune Escorts Nearby with Complete Sa...
 
The Economic History of the U.S. Lecture 21.pdf
The Economic History of the U.S. Lecture 21.pdfThe Economic History of the U.S. Lecture 21.pdf
The Economic History of the U.S. Lecture 21.pdf
 
Shrambal_Distributors_Newsletter_Apr-2024 (1).pdf
Shrambal_Distributors_Newsletter_Apr-2024 (1).pdfShrambal_Distributors_Newsletter_Apr-2024 (1).pdf
Shrambal_Distributors_Newsletter_Apr-2024 (1).pdf
 
VIP Independent Call Girls in Bandra West 🌹 9920725232 ( Call Me ) Mumbai Esc...
VIP Independent Call Girls in Bandra West 🌹 9920725232 ( Call Me ) Mumbai Esc...VIP Independent Call Girls in Bandra West 🌹 9920725232 ( Call Me ) Mumbai Esc...
VIP Independent Call Girls in Bandra West 🌹 9920725232 ( Call Me ) Mumbai Esc...
 

Pairs Trading from NYC Algorithmic Trading Meetup November '13

  • 1. How To Build Your Own Pairs Trading Algorithm Trading System Quantopian Meetup Gary Chan
  • 2. Introduction • Started programming at a young age • Played poker as main source of income for a few years • Money is just a way to keep score • Became interested in stock market • Read ~70 textbooks, mostly corporate finance, CFA curriculum • Currently running an algorithmic trading system out of my apartment
  • 3. Expectations • I’m not here to divulge secrets • Teach a man to fish, not give him a fish • You will see how easy the pairs trading model is to understand and build • Deployable by retail investors • Seeing is believing • You will not be able to build your own tomorrow… but one day… if you want it badly enough • It’s a small world, so share ideas
  • 4. Why you can beat the professionals • Definition of professionals • Algorithmic does not mean high frequency • HFT is not for retail investors • Strategy capacity • Find a niche
  • 5. Disclaimers • A lot of learning, before this came to fruition • Content here will not be complete due to time constraints • Survivorship bias, Look ahead bias • Model risk, implementation risk, execution risk, over parameterization • Random models can have profitable backtests • I’m not responsible if you lose money
  • 6. Algorithmic Trading is Easy • • • • • • What does easy / hard mean? Info, books, tools, cheaply or freely available Yahoo, Google, Morningstar, Edgar, Quantopian Visual Studio Express, MySQL, R Many textbooks written on the subject Low capital requirements (30K minimum) compared to other ventures • Backtest before you use real money!! • Higher quality data will cost more money
  • 7. My Current System • • • • • Low frequency Single computer, 3 years old Runs on Wifi from my apartment Started coding Oct 2012 Started forward testing play money in March 2013 • Started forward testing real money June 2013 • Current performance consistent with backtests • Just started using cloud computing
  • 10. Backtesting • Profitable backtests does not mean good • You need a valid model • Live trading WILL underperform backtests
  • 11. How A Good Backtest Looks • Consistent, high R Squared • Similar parameters have similar equity curves
  • 12. Key Info From Backtests • • • • Portfolio of 39 pairs Average of 12 to 18 pairs with opened positions, $5400 max drawdown $10k sized legs in backtests, $395 average profit per trade 81.3% winning trades, 4540 trades, 26 day average holding period
  • 13. Pairs Trading Books • Contains Code • Complete manual to putting together your own system
  • 14. Types of Investment Strategies • Mean Reversion – Buy low, sell high / Sell high, buy low – Fundamental Analysis – Statistical Arbitrage • Momentum – Sell low, buy lower / Buy high, sell higher – News • Technical analysis does not work
  • 15. Necessary Math • • • • • • • Basic statistics Linear algebra Standard deviations, regressions Types of distributions (normal, logarithmic) Random walks Stationary (mean reverting) series Cointegration
  • 16. Mean Reversion Example #1 • • • • • Keep an opened mind Everything can be measured in money If you don’t believe me, put it on EBay Fear can be measured in dollars Unwarranted fear -> Sell volatility to profit
  • 17. Mean Reversion Example #2 • • • • • Stocks move in random walks Some stocks move together Spread between the stocks are mean reverting Buy low, sell high on the spread Statistical arbitrage means you win most of the time, not all the time • Buyouts and bankruptcies result in large losses • Diversification is a must • Learn some corporate finance / fundamentals
  • 18. Case Study, GLD and IAU • Two gold ETF’s • Pull end of day prices from Yahoo Finance into csv files • Do a linear regression • Calculate the spread • Graph of spread is mean reverting • Find #Stdevs to enter / exit trade • Optimize parameters
  • 19. Next Steps • Try higher quality data • You could trade this by hand + excel, but better to automate the process • Many systems are built in excel • Optimize the code • Backtest until you find a profitable strategy • Use a brokerage with an API, sample code • Forward test with play money
  • 20. Next Steps Part 2 • • • • • • • Execution, order, position management Test with small amounts of real money Tweak your system Ramp up trading size if still profitable Exhaust universe for the strategy Find new strategies Never stop learning
  • 21. The End • Ernest P Chan - Quantitative Trading: How to Build Your Own Algorithmic Trading Business (Wiley Trading) • Ganapathy Vidyamurthy - Pairs Trading: Quantitative Methods and Analysis (Wiley Finance) • R - http://www.r-project.org/ (like Matlab) Yahoo, Google, Morningstar, Edgar, Quantopian • Visual Studio Express, MySQL, R • garychan7@gmail.com • https://twitter.com/RITrading - I tweet my trades here