Skip to content

Commit d034151

Browse files
authored
adding extra day before dtcmp calc, as otherwise the extradays have no effect (mementum#388)
1 parent 26b2654 commit d034151

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

backtrader/analyzer.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -434,11 +434,13 @@ def _get_subday_cmpkey(self, dt):
434434
seconds=self.timeframe == TimeFrame.Seconds,
435435
microseconds=self.timeframe == TimeFrame.MicroSeconds)
436436

437+
# Add extra day if present
438+
if extradays:
439+
dt += datetime.timedelta(days=extradays)
440+
437441
# Replace intraday parts with the calculated ones and update it
438442
dtcmp = dt.replace(hour=ph, minute=pm, second=ps, microsecond=pus)
439443
dtcmp -= tadjust
440-
if extradays:
441-
dt += datetime.timedelta(days=extradays)
442444
dtkey = dtcmp
443445

444446
return dtcmp, dtkey

0 commit comments

Comments
 (0)