-
Notifications
You must be signed in to change notification settings - Fork 3.9k
[Backtesting] Sharpe ratio calculation is incorrect #2064
Comments
Hi zappra, I'm wondering if this will help or not:
(where each sample is 1 roundtrip or 2 trades, hence the statistical correction is 2 trades)
Just some ideas, hope this helps. |
For me personally, the ratio would encapsulate a few things: Profitability (obvs) However thats all quite personal and others might favour a different bias, so perhaps there should be configuration options? I'd also vote to rename it to "Gekko Ratio" - since a) it might end up being a hybrid of other ratios and b) it's primary use would be to compare one Gekko strategy against another, or for genetic backtesting purposes. Anyone using it to compare against traditional investments needs locking up! (IMHO, obvs, etc) |
You could also do a separate ratio or calculation for downside trades. Dividing by the standard deviation would be a little deceptive (you'd get lower negative values with low deviations) so maybe taking a lower quantile instead: in roundtrips:
then
I'm not sure if that's right, this is just off the cuff. |
Note: this is the technical bug tracker, please use other platforms for getting support and starting a (non technical) discussion. See the getting help page for details.
I'm submitting a ...
[x ] bug report
[ ] question about the decisions made in the repository
Action taken (what you did)
Backtesting via UI
Expected result (what you hoped would happen)
Ex-post Sharpe ratio should calculate the mean of P(t) - RFR(t) for all roundtrips, where P(t) is the profit for the roundtrip, and RFR(t) is the risk free return for the period of the roundtrip
Actual result (unexpected outcome)
The numerator is calculated as the mean of all roundtrip profits, less an annual risk free return rate. This is incorrect, and will more often than not yield incorrect negative Sharpe ratios, even if on average the strategy is profitable.
Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, etc)
Also, might the Sortino ratio be a better fit for Crypto? The Sortino denominator is the stdDev of losses only; in other words, the volatility of positive returns doesn't punish the ratio.
The text was updated successfully, but these errors were encountered: