Help! Different Annual Performance Despite Same Exact Trades

When I run a backtest from 2004 to 2009 I get a different total return for the year 2008 then when I just run it for 2008. The trades are exactly the same, there is no difference.

For the 04 to 09 test, I get a starting total return (using the sliders on the performance tab) on Jan 1, 2008, of 89.82% and on Dec 30th, 2008 I get 175.64%. So 175.64%-89.82%=85.82%
For the 08 Test, I get a starting value of 0% and then an ending total return of 43.05%.

Again, the trades are exactly the same, there are no differences in anything at all except for the backtest time frames. Both tests start at $10 mil. PS- This is true regardless of what year I choose, except for the first year. So if I go back and look at 05, 06, 07, individually, the total return numbers will be different than if I look at them within the sliders on the longer test. 2 responses The issue is the returns are arithmetic returns. One cannot add or subtract (or do much of any math for that matter) on arithmetic returns. What are arithmetic returns? It's what we usually think of as 'return' expressed as a percent. The formula is the well known arithmetic_return = ((value_current - value_previous) / abs(value_previous)) So as an example, if one's portfolio is$100 on 1-1-2008 and $150 on 12-31-2008, the return for that time would be return_2008 = (150 - 100) / abs(100) which equals .50 or 50% Nothing surprising I'm sure. Let's pretend the following year we loose$50. One's portfolio is $150 on 12-31-2008 and$100 on 12-31-2009, the return for that time would be

return_2009 = ((100 -150) / abs(150) which equals .33 or 33%

That looks right. Now, what was our return for the total two year time. One's portfolio is $100 on 1-1-2008 and$100 on 12-31-2009, the return for that time would be

return_2008_2009 = ((100 -100) / abs(100) which equals 0%

That makes sense. We ended with what we started so a return of 0%. But, shouldn't that also simply be the sum of the two returns?

return_2008_2009 = return_2008 + return_2009 = .50 + (-.33) = .17 which is 17%

Hmm 17%?, something's not right. Adding (or subtracting) arithmetic returns doesn't work. To add or subtract returns one must use log returns. Here is the formula to get log returns from arithmetic returns and vice versa

log_return = ln(arithmetic_return + 1)
arithmetic_return = exp(log_return) - 1

Let's try adding log returns and see what we get.

log_return_2008_2009 = ln(return_2008+1) + ln(return_2009+1) = .4 + (-4) = 0.0
arithmetic_return_2008_2009 = exp(log_return_2008_2009) - 1 = 1 - 1 = 0%

That looks better! So, to add or subtract returns simply change to log returns, do the math, then convert back to arithmetic returns.

Let's go back to the 2004 to 2009 test in the original post. We want to find the return for 2008. The starting return on 1-1-2008 is 89.82% and on 12-30-2008 it is 175.64%. We just need to subtract the initial return from the final return. However, we know we must convert to log returns first. Let's do that math

log_return_2008 = ln(1.7564+1) - ln(.8982+1) = 1.014 - .641 = .373
arithmetic_return_2008 = exp(.373) - 1 = 46.2 - 1 = 45.2%

So our calculated 2008 arithmetic return is 45.2%. The backtest was 43.05%. They are very close (much closer than the result when subtracting arithmetic returns). However, they should be exact if it is true that the trades are identical. The difference may be rounding. The log functions are very sensitive. Another issue may be dividends. One must hold a stock on the ex-div date to get a dividend credit. If you want to debug the difference it would be helpful if the actual backtests were attached to the post.

Hope that helps.

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.

Glorious reply, exactly what I needed, thank you very much for your time and effort!!! :)