The strategy logic is simple but sound: aim to stay invested in stocks (better long-term returns), but switch to bonds (safety) during market crisis.
This is an implementation of a strategy I published at my blog. It is not exactly as described at the blog post, but it does not materially impact the results. See the original strategy at: This Simple Strategy Can Beat The Stock Market.
The code is very simple and self-explanatory but be warned that my python skills are not great... so my coding style might be a bit "unusual".
Any feedback is welcome. I'd appreciate.
If you have any questions, I'd be glad to answer.
Have fun!
PS: I am new to QuantConnect strategy testing... so I could not manage to have a daily equity curve ploted... the benchmark curve is also missing... anyone knows how to solve those little issues? Thanks!
Aaron Gilman
I am not 100% but I was having the same issue. I think it may have to do with setting SPY at Resolution.Daily. Try setting the resolution for both of the ETFs to Resolution.Minute and then add self.SetBenchmark("SPY") after you do self.AddSecurity. Then you should be able to go to the chart and select "Benchmark" from the dropdown to display correctly.
Upbias
Thanks, now I can see the correct benchmark!
Upbias
A Short Disclaimer​​​​​​​​​​​​​​​​​
Note that I am not a financial advisor, and all content (strategies, code, ec.) is presented here “as is” and on an educational and informational basis only.
Michael Manus
ricardo_ribeiro your website/webserver is not working.....
i wanted to check what kind of other strategies you posted :)
Upbias
hummm... strange,,, it seems fine to me...
PS: also look at the menu link "app"
Upbias
ah... there is some issue with the redirects using firefox... i am looking into it...
Upbias
looks like it is taking a while to update the redirects...
you can use new link:
https://www.upbias.com/blog/simple-strategy-can-beat-the-stock-market/
Upbias
Thank you michael_manus for pointing out the redirect issue! I hope it is solved now...
Upbias
Hey all,
I've just put a link at my blog post pointing back to this discussion... i hope it is not a problem...
but if it is, please tell me... so i can remove that link.
Jared Broad
No problem Ricardo; we welcome unique/new strategy sharing & discussion from commercial entities as long as its about the science not sales (so you're fine). I recommend copying the embed code from the bottom of the backtest result (on sharing tab) and then you can embed the backtest result directly into your blog.
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.
Upbias
Great, thanks!
Upbias
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!