Welcome to Quantopian! That's a fascinating algo. I spent the couple hours on it ;) That's a sign of something that's got me interested!
There is a key difference between your implementation and the linked strategy, I think, is the monthly increase in funds. The linked assumes that you're increasing your amount to be invested every month - that you're taking part of your paycheck, presumably, and investing it. Quantopian doesn't really handle that well - we assume you start with a bucket of money, and we don't really model increases in the bucket. But anything is possible in Python ;)
So I took your line here:
context.target_value += 500 * context.expected_monthly_return
And I rewrote it as:
context.target_value = context.target_value * context.expected_monthly_return + context.monthly_add
I also built a "fake cash" system that, I think, tracks how much money you "have" if you pay into it every month.
The result was pretty fascinating. If you start it in January '08 like they did in their example, it works ok. But if you started in January '02, then 2008 breaks the model horribly - you go into negative "fake cash" by quite a bit.
I'm curious, outside of backtesting, what the theory is behind how this should or shouldn't work.
Disclaimer
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 Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian 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.