Skip to content

Commit

Permalink
Guarantee exit dates are in sorted order.
Browse files Browse the repository at this point in the history
  • Loading branch information
edtechre committed Mar 17, 2023
1 parent 29ef6b9 commit 6902781
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/pybroker/strategy.py
Original file line number Diff line number Diff line change
Expand Up @@ -1208,9 +1208,11 @@ def _run_walkforward(
for sym in exec.symbols:
sessions[ExecSymbol(exec.id, sym)] = {}
if self._config.exit_on_last_bar:
exit_dates[sym] = df[df[DataCol.SYMBOL.value] == sym][
sym_dates = df[df[DataCol.SYMBOL.value] == sym][
DataCol.DATE.value
].values[-1]
].values
sym_dates.sort()
exit_dates[sym] = sym_dates[-1]
for train_idx, test_idx in self.walkforward_split(
df=df,
windows=windows,
Expand Down

0 comments on commit 6902781

Please sign in to comment.