Hello, I am sharing this algorithm that takes 2 week returns and tries to make future trading decisions based on them. It is a fairly simple strategy. It is mostly just a modified Magnitude model and takes full use of the Algorithm Framework. I am using this to demonstrate how easy and fun starting to program algorithms can be for beginners on the platform. The backtest below is a reversal from the initial theory that ended up producing better results. This algorithm is in no way trade ready and still needs to be thoroughly gone through for mistakes, bugs, and errors. My hopes now is that the community picks it up and improves on it. I will link the article on Medium that I wrote that goes with this strategy when It drops. Also, there is a research notebook attached as well. Also, I am going to be releasing more strategies in the future that will get more advanced. Let me know if you have any corrections, suggestions, or advice you would like to give me or just what you think about it. Happy Coding!
Mak K
Hi Dan,
Thanks for the post and strategy idea :)
It is very cool that you are trying to help and work with the community!
The returns are great! However I see a big issue with the drawdown of this that would very likely make it impossible to actually trade if you aren't willing to fully part with all of your money. Also there might be an issue with slippage given that some of these are very low volume assets.
I've made a small change that isn't perfect or anything and also brings some other issues such as very low frequency of trades but it sort of eliminates the issue of slippage and is over all less risky, even if it is still risky
I've attached a backtest and overall I think that backtest is a little more realistic, haven't spend too much time on this yet tho.
You might also want to look into trading using stop losses with this intraday to manage the risk.
Dan Root
Awesome! Love the work you did to improve this strategy! I agree, the low volume assets do make it riskier. View this as an example rough draft strategy, which needs tuned but has interesting performance. I have purposely left this strategy to be built off and improved as it was beginner strategy, and my focus was on how a simple strategy could be at first constructed using existing models and then tested. Thank you for your contribution to it though, maybe if enough people participate in this strategy, it could become more robust here on the community forum. The tutorial Medium Article is dropping soon, and I will link that in this discussion.
Mak K
Looking forward to that!
I think it's good to try and kickstart community projects, when I find some more time I will look into improving this more.
One thing that might be good of you to do next time is put some comments in the code and explain what you are doing so everyone will be able to follow what's happening in the code and be able to contribute :)
Dan Root
That is so true! I didn't even notice I didn't put any comments aside from the default ones that are pre-coded in. I appreciate the feedback! I will look at working on this strategy more soon as well. Maybe add some risk and use more sophisticated trading logic.
Yeah, I really love the QuantConnect community and love contributing as much as I can. It teaches so much to collaborate with other Quants and build with each other. Great Ecosystem!
Dan Root
So, this is the article I mentioned that I was going to attach to this post. This is a free friend link.
Also, I am going to include a new more cleaned up version of this algorithm with better comments, cleaner code, and a custom risk model. I created a bracket risk model that has a profit taker and stop loss. I also made the universe selection more intricate by filtering and sorting it by low ATR values.
Even though this is moving towards a better strategy it is still a simple example and needs more work to be considered a good strategy to move forward with for paper testing. I encourage any improvements or corrections. Let me know what you think! I will be posting more advanced algorithms soon as well! 😊
Fred Painchaud
Hi Dan,
Thanks for sharing the strategy!
I took the time to go through your blog post. A minor thing: we write pseudocode not sudo-code. A bigger thing: do you have any idea why a high 14-day return means to short and a low one to long? Have you researched it a bit? Or is it just linked to the type of assets you select in your Universe (your selection criteria) and/or the period you chose (14 days) (and then, other criteria and/or another period would mean another set of thresholds (.75/-.75) and/or other directions (up/down))?
Cheers,
Fred
Dan Root
Hello Fred,
Thank you for the great feedback! I will update the pseudocode typo in the blog, which is much appreciated. As for the other question about the 14-day returns, the strategy started out the other way actually. I was testing to see if the momentum from 14-day returns can carry over to current and future returns, but during back-testing I discovered that the strategy works much better as a reversal indicator. This was meant to be an introduction strategy for anyone new to QuantConnect. Because of that I kept the research low on this strategy in hopes it was easier to grasp. In my next strategy I do plan on going more into the overall conceptual research of the strategy. As for the 14-day period and the magnitude thresholds and whatnot, yeah that is the arbitrary values that could definitely be replaced with more dynamic variables. Right now, they are cherry picked for a decent PSR value, as I wanted to start small. My main goal with this strategy is to hopefully have the community improve the areas that are less optimal and see if there is any actual value in the strategy or not. I hope that answered your questions. Feel free to post an upgraded version with corrections and/or improvements.
Best regards,
Dan
Dan Root
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!