Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Calculating Returns based on currently invested money, instead of capital base.

Hi folks,

i would like to backtest my algorithm for a saving scheme. This means, that I invest every month $1.000 in the same stocks (or other). When I run my backtest for 12 months, the algorithm invested $12.000. For this test I had to set the capital base to 12k, which is used for the daily returns. But this is not true, since I don't have the 12k in the beginning. So it calculates the returns for 12k, even though only 1k is invested after month 1, and 2k after month 2. If I set a capital base of 1k, the other 11k would be leveraged, which is not true either.

My question is, how is it possible to get daily returns based on currently invested capital?

Thank you very much.