This repo holds the very first algo trading strategy I have developed and live traded from 2012 to 2016.
It was built using PyAlgoTrade with the Pair Trading / Stat Arb guidelines posted in Ernie Chan's Quantitative Trading book.
It created lower-than-expected live trading returns, so I moved on. I think it might be useful for others as learning material.
Even though it made some profits live, it wasn't up to my expectation: The initial capital trading this strategy was $40k. While continuously adding savings to the account, it ended up making $6k over the 3-year period. Even if we ignore the fact that additional was capital was deployed to the account the CAGR would be around 5%.
I made two other iterations of this strategy: huba-v2 and huba-v3 will be released shortly, with similar commentary.
Finding cointegrated pairs and trading them long/short when they drift too far apart from their expected fair price. You can find all the details in Ernie's first and second book on the subject.
- Purchased minute data from iqfeed, ingested it
- Implemented Statistical Arbitrage as discussed in the book
- Created a liquidity and price filter to filter out non-tradable stocks
- Created pairs for each equity sector
- Did a bruteforce on half of my data
- Picked the best looking pairs, which seemed to make sense
- Validated them on my other half of the data
- Picked the ones which still remained reasonable and put it into paper trading
- After gaining confidence put the best pairs to live trading
- Explored AD-Fuller tests, Hurst exponents, Earnings filters and bunch of other stup
- Profit of 6k after 4 years
- Moved on to zipline based implementation (huba-v2)
- Max time in trade is a must. huba-v1 didn't have this implemented, but huba-v2 has this feature.
- Running this strategy for 3 years had a serious opportunity cost.
- Getting intra-day data was challenging and expensive at the time.
- Finding pairs by grid-search (even in the same industries) is expensive and often results from spurious discoveries.
Some pairs I traded might still show correlation.
Coming from C/C++ background this was my first serious Python project.
The whole solution was migrated to PyPy so that we have reasonable speed. Then machines were crunching data for weeks. The pair-scan results are located here.
Over time I have created two additional iterations of the StatArb strategy:
After these iterations I gave up and moved to Mean Reversion and Momentum Strategies.
Most recently I learned Options Trading and created a backtester service for income strategies.
If you don't mind sharing with me, that is awesome.
Drop me a mail at tibor (d0t) kiss (at-sign) gmail (d0t) com.
If you don't feel like sharing, that's also fine. Enjoy the ride! :)
Please use the Discussion Board.
Sure, thank you for your consideration!
It is a joke delivered as an acronym: Highly Unorthodox Broker Agent.
I must admit: nothing is unorthodox about this approach (it is well studied).
When I started developing this strategy Hungary's Minister of Economy Huba Gyorgy, Matolcsy started campaigning with his 'Unorthodox' approaches. I thought this project will be as qualified as his decisions, hence the name.