Skip to content

Commit 3a1d431

Browse files
committed
Remove "(Ann)" from Sharpe/Sortino/Calmar ratios
Annualization is assumed and keeps labels backcompat.
1 parent 2ecc553 commit 3a1d431

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

backtesting/backtesting.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1410,11 +1410,11 @@ def geometric_mean(x):
14101410

14111411
# Our Sharpe mismatches `empyrical.sharpe_ratio()` because they use arithmetic mean return
14121412
# and simple standard deviation
1413-
s.loc['Sharpe Ratio (Ann.)'] = np.clip(s.loc['Return (Ann.) [%]'] / (s.loc['Risk (Ann.) [%]'] or np.nan), -1, np.inf) # noqa: E501
1413+
s.loc['Sharpe Ratio'] = np.clip(s.loc['Return (Ann.) [%]'] / (s.loc['Risk (Ann.) [%]'] or np.nan), -1, np.inf) # noqa: E501
14141414
# Our Sortino mismatches `empyrical.sortino_ratio()` because they use arithmetic mean return
1415-
s.loc['Sortino Ratio (Ann.)'] = annualized_return / (np.sqrt(np.mean(day_returns.clip(-np.inf, 0)**2)) * np.sqrt(annual_trading_days)) # noqa: E501
1415+
s.loc['Sortino Ratio'] = annualized_return / (np.sqrt(np.mean(day_returns.clip(-np.inf, 0)**2)) * np.sqrt(annual_trading_days)) # noqa: E501
14161416
max_dd = -np.nan_to_num(dd.max())
1417-
s.loc['Calmar Ratio (Ann.)'] = annualized_return / (-max_dd or np.nan)
1417+
s.loc['Calmar Ratio'] = annualized_return / (-max_dd or np.nan)
14181418
s.loc['Max. Drawdown [%]'] = max_dd * 100
14191419
s.loc['Avg. Drawdown [%]'] = -dd_peaks.mean() * 100
14201420
s.loc['Max. Drawdown Duration'] = _round_timedelta(dd_dur.max())

backtesting/test/_test.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ def test_compute_stats(self):
261261
'Avg. Trade [%]': 2.3537113951143773,
262262
'Best Trade [%]': 53.59595229490424,
263263
'Buy & Hold Return [%]': 703.4582419772772,
264-
'Calmar Ratio (Ann.)': 0.4445179349739874,
264+
'Calmar Ratio': 0.4445179349739874,
265265
'Duration': pd.Timedelta('3116 days 00:00:00'),
266266
'End': pd.Timestamp('2013-03-01 00:00:00'),
267267
'Equity Final [$]': 51959.94999999997,
@@ -276,8 +276,8 @@ def test_compute_stats(self):
276276
'Return [%]': 419.59949999999964,
277277
'Risk (Ann.) [%]': 36.53825234483751,
278278
'SQN': 0.916892986080858,
279-
'Sharpe Ratio (Ann.)': 0.5837177650097084,
280-
'Sortino Ratio (Ann.)': 1.0923863161583591,
279+
'Sharpe Ratio': 0.5837177650097084,
280+
'Sortino Ratio': 1.0923863161583591,
281281
'Start': pd.Timestamp('2004-08-19 00:00:00'),
282282
'Win Rate [%]': 46.15384615384615,
283283
'Worst Trade [%]': -18.39887353835481,

0 commit comments

Comments
 (0)