Hi, this is my first entry on Quantopian. I hope to seek suggestions on my strategy and results.
My strategy attempts to take advantage of market psychology due to oil price movements in the recent years. Greed and fear has led to close scrutiny of oil stocks, which has also likely lead to stronger co-integration within them.
Kalman filter is applied to compute beta and beta hedging ratio between two Oil & Gas equipment & services companies (Haliburton & Schlumberger). Co-integration test verified the pair and it was one of best pair I could find. I also coded the Kalman filter for the sake of learning and it was running appreciably faster than the pykalman module in my notebook.
The transition and measurement noise is estimated based on the sum of innovation chi square test and verified with innovation sequence chart and innovation residue auto-correlation test.
Mahalanobis distance, a result that can be obtained from the mathematics of Kalman filters is used to compute leverage. It is an attempt to selectively apply leverage. The equation “y = A/x + B” is used to bind the leverage ratio within 1 to 2 to avoid excessive leverage and meet Q fund requirement. It performed better than sigmoid shaped functions.
For similar mean leverage ratio strategy, I noted that leveraging shorter distance trade generates higher return & Sharpe as it appears more frequently. However it is riskier and could lead to larger max drawdown. Longer distance trade seems safer but does not occur as frequently to beat the market.
In this backtest, the unleveraged formula is able to track the market return with 0.02 beta and a max drawdown of 9.4%. For a mean leverage of ~1.85 (similar to the backtest result below), the algorithm can be pushed to obtain 200% return at the cost of 18.5% max drawdown with the commented leverage formula. The strategy does not work well before 2011, except for 2008.
I also have a small margin of safety (1.05*std. dev) to avoid excessive trading, which erodes profit due to commission fee.
- How do I further improve the quality of entering and exit a trade? I want to learn how squeeze more alpha/sharpe from a pair. Adaptive Kalman filter / OU process works?
- How does code performance/speed affect trade execution especially minute frequency trade?
- Q fund worthy? :P
|Returns||1 Month||3 Month||6 Month||12 Month|
|Alpha||1 Month||3 Month||6 Month||12 Month|
|Beta||1 Month||3 Month||6 Month||12 Month|
|Sharpe||1 Month||3 Month||6 Month||12 Month|
|Sortino||1 Month||3 Month||6 Month||12 Month|
|Volatility||1 Month||3 Month||6 Month||12 Month|
|Max Drawdown||1 Month||3 Month||6 Month||12 Month|