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!

Author