3 ms·
var total = 0; for (var i = 0; i < performance.length; i++) { total += performance[i]; } var avg = total / performance.length; var tradingDays
by ffggvv 5y ago
var total = 0;
for (var i = 0; i < performance.length; i++) {
total += performance[i];
}
var avg = total / performance.length;
var tradingDays = performance.length;
var annualizedReturn = (1 + avg) \* 253 - 1;
}
I think this math is wrong. You cant just add the daily performances up to get the total return. unless im missing something.
Though seems like your "cash" variable is correctly calculated.