Skip to content

Commit 3045b64

Browse files
authored
ENH: Update stats calculation for Buy & Hold to be long-only (kernc#152)
Refs: kernc#150
1 parent 2bb8f29 commit 3045b64

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

backtesting/backtesting.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1380,7 +1380,7 @@ def _round_timedelta(value, _period=_data_period(index)):
13801380
s.loc['Equity Peak [$]'] = equity.max()
13811381
s.loc['Return [%]'] = (equity[-1] - equity[0]) / equity[0] * 100
13821382
c = data.Close.values
1383-
s.loc['Buy & Hold Return [%]'] = abs(c[-1] - c[0]) / c[0] * 100 # long OR short
1383+
s.loc['Buy & Hold Return [%]'] = (c[-1] - c[0]) / c[0] * 100 # long-only return
13841384
s.loc['Max. Drawdown [%]'] = max_dd = -np.nan_to_num(dd.max()) * 100
13851385
s.loc['Avg. Drawdown [%]'] = -dd_peaks.mean() * 100
13861386
s.loc['Max. Drawdown Duration'] = _round_timedelta(dd_dur.max())

0 commit comments

Comments
 (0)