Complete webinar recording: https://blog.quantinsti.com/algo-trading-epat-projects-12-april-2022/
------------------------------------------------
About the Presentation:
This project models a Statistical Arbitrage pair trading strategy to Brazil’s B3 (former Bovespa) stock market exchange. We run our strategy on two distinct time intervals.
From 1-Jan-2009 to 31-Dec-2014 and from 1-Jan-2018 to 30-Apr-2021. As we only had current sector distribution available, the results for the former period clearly suffered from survivorship bias.
Stock sector classification was downloaded directly from Brazil’s B3 stock market exchange. From all sectors, we considered only the ones with five or more stocks, namely: oil, metal, steel, paper, transp_material, machines, rail_roads, highways, storage, services, agriculture, meat, food, construction, fabric, clothes_shoes, education, car_rental, retail, hospitals, drugstores, it, telecom, electricity, water, banking, financial_services, insurance and real_estate.
Results were very encouraging, though did not consider transaction fees or slippage costs. All calculations were done based on daily close prices.
------------------------------------------------
Speaker:
Dr. Luiz Guedes (Head of Quantitative Analysis at Occam Brasil)
Dr Luiz Guedes has over 30 years of experience in his career in software development, specifically in the payment card industry. In addition, he is a faculty member at the Instituto Militar de Engenharia – IME, where he teaches Compilers and Programming Languages.
As a software developer and innovator, Dr Guedes has extensively used the Innovative Problem Solving approach to write software for constrained systems and secure electronic transactions, particularly on the development of programming and execution environments, cryptographic algorithms and security communication protocols.
In July 2021, one month after concluding QuantInsti's EPAT programme, he started a new position as Head of Quantitative Analysis at Occam Brasil, where he has just been invited to become a Partner.
Dr Guedes holds a doctor’s degree in computer science from the Pontifícia Universidade Católica do Rio de Janeiro – PUC/RIO, a master’s degree in computer systems and a computer engineer degree, both from IME. Additionally, he acquired an MBA in business from the Fundação Getúlio Vargas – FGV.
------------------------------------------------
This event was conducted on:
Tuesday, April 12, 2022
9:30 AM ET | 7:00 PM IST | 9:30 PM SGT
------------------------------------------------
Link to our Blog: https://blog.quantinsti.com/
Like us on Facebook @ https://www.facebook.com/quantinsti/
Follow us on Twitter @ https://twitter.com/QuantInsti
Follow us on LinkedIn @ https://www.linkedin.com/school/quantinsti/
Follow us on Instagram @ https://www.instagram.com/quantinstian/
E-mail us @ sales@quantinsti.com
------------------------------------------------
2. Statistical Arbitrage Concepts
• Arbitrage: Trade operation free of risk
• Statistical Arbitrage: Use of Statistics to find Trade operations (almost) free of risk
• Pairs Trading: Statistical arbitrage model based on finding asset pairs that mutually
(almost) neutralize each other’s risk.
• Dollar neutral, Beta neutral, Alpha neutral,...
• Cointegrated pair: Pair of assets that can be linearly combined to produce a
stationary time series
• Stationary time series: Time series with constant mean and variance
4. Pairs Trading Backtest Algorithm
1. Identify Sectors and Tickers
2. For each Sector
1. Find cointegrating pairs for the training period
2. Get cointegrating pairs hedge ratio (Johansen test)
3. For each pair
1. Calculate pairs spread for the test period using training period
hedge ratio
2. Run Bollinger Band Trading strategy for testing period
3. Save results
Training Period Testing
Train start Train end = Test start -1 Test end
5. Backtest Process
Training Period Testing
Training Period Testing
Training Period Testing
Training Period Testing
...
Training Period Testing
Train start Train end = Test start -1 Test end
x
6. Pairs Trading Backtest Algorithm
1. Identify Sectors and Tickers
2. While period <= lastPeriod
1. For each Sector
1. Find cointegrating pairs for the training period
2. Get cointegrating pairs hedge ratio (Johansen test)
3. For each pair
1. Calculate pairs spread for the test period using training period hedge
ratio
2. Run Bollinger Band Trading strategy for testing period
3. Save results
2. Advance to next period
11. Project BackTest Process
Training Period Testing
2018-01-01 2020-04-30 2021-04-30
Training Period Testing
2009-01-01 2014-01-01 2014-12-31
Survivorship Bias!!!
13. Pairs per Sector
#sectors x #pairs 1-Jan-2009 to 31-Dec-2014 1-Jan-2018 to 30-Apr-2021
All (sectors larger than 5) 10 x 750 15 x 1098
Cointegrated (signific >
90%)
10 x 393 15 x 442
Constant sign 10 x 333 14 x 361
Half-life <= 60 4 x 89 12 x 140
14. Pairs per Sector – IBrX100
#sectors x #pairs All Top 100
All (sectors larger than 5) 15 x 1098 5 x 81
Cointegrated (signific >
90%)
15 x 442 5 x 21
Constant sign 14 x 361 4 x 18
Half-life <= 60 12 x 140 3 x 5
16. Room for improvements
Find best Hyperparameters
• Training period length
• Testing period length
• Stationarity check period length
Merge small sectors with fundamental relation
Other types of Statistical Arbitrage
• Index Arbitrage
• Option Arbitrage
Recommended References:
• Chan, Ernie. Algorithmic Trading (Wiley Trading). Wiley.
• Hilpisch, Yves. Python for Algorithmic Trading . O'Reilly Media.