First off, this is my very first post and I would just like to show my appreciation for the people in this community and the employees of Quantopian for providing so many resources, posts, tutorials, lectures, the platform, data packages etc. that can allow anyone without a background in any of this stuff to become very polished in algorithmic trading.
Second, I have been on this website every since I discovered it through the Economist about three-four weeks ago. This website is absolutely amazing and have been able to learn enough where I can write the code provided in this post. Even though I have no formal background in programming (I have a degree in Finance and not computer science and math!) I think I'm coming along pretty well.
Third, now that I'm done with my excitement I want to tell you about why I need help:
Utilizing alphalens in research I was able to test my factor idea of (return on equity - cost of equity) = value creation. This ultimately led to high IC with poor returns in the bottom quantile of the basic materials sector and moderately high IC for the top quantile in the technology sector. So to test what I've been learning, I wanted to long top quantile tech and short low quantile basic materials
After putting together the algorithm, I've ran into several issues:
1) The algorithm backtest is very slow
2) I've tried to implement a beta hedge via calculating beta through regression (not sure if this is working properly because beta is going crazy)
3) Not sure if my rebalance after selling due to loss is working properly
4) If you look at the recording chart, I have HUGE spikes in cash and PV and ultimately a huge spike in returns and a crash in returns.
What am I doing wrong?
Is my code poorly written?
What am I missing?
How can I improve my code?
Can you guys take a look and provide me with tips/inform me on how to fix these issue? Why are these issues happening?
Like I said, there may be a lot going on but I am just trying to practice to get better which is why I've implemented so many different functions, etc.
Thanks to everyone!
|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|