Show HN: I discovered a trading algorithm that returns ~24.85% annually
As others have said, "Average return is just one statistic". When trading, losses hit harder than wins. Go up 50% then down 50% and you're not even, you're down 25%. The degree of overestimation from this mean return -> "annualized return" calculation depends on what the returns distribution looks like.<p>Here's the calculation used in main.js line 77 applied to a very extreme unrealistic example. I simulated 253 days of return percentages from a uniform distribution between -5.5% and 5.6%, and then the actual total return percent, calculated in R<p><pre><code>    set.seed(2020)
    n <- 253
    daily_gain <- runif(n, -.055, .056)
    
    total_gain <- sum(daily_gain)
    avg <- total_gain/n
    annualizedReturn <- (1 + avg)^n -1
    
    annualizedReturn
    # [1] 0.2933685
    
    prod(1 + daily_gain) - 1
    # [1] 0.1324846
</code></pre>
Edit:<p>In reality the actual numbers are likely to be not nearly as different as this example. I chose uniformly distributed returns with a wide range to make the reason against this calculation very obvious. Here's an example return distribution where there's hardly any difference. Normal returns with average of 0.085% and standard deviation of .05 i.e. daily_gain <- rnorm(n, .085/100, .05/100) gives<p><pre><code>    annualizedReturn
    # 1] 0.2414539
    
    prod(1 + daily_gain) - 1
    # [1] 0.2414051
</code></pre>
For good measure here's one in the middle where your returns are normally distributed with an average of 0.35% and a sd of .2%, but then you have on average 10 bad days a year where returns are 5 percentage points lower than that distribution i.e. daily_gain <- rnorm(n, .35/100, .2/100) - rbinom(n, 1, 10/n)*.05 gives<p><pre><code>    annualizedReturn
    # [1] 0.2712024
    
    prod(1 + daily_gain) - 1
    # [1] 0.2490317</code></pre>