From e589f1c9f3ff084711dfc3c1331ca9d28649a717 Mon Sep 17 00:00:00 2001 From: edtechre Date: Fri, 17 Mar 2023 12:55:04 -0700 Subject: [PATCH] Guarantee exit date symbol exists in DataFrame. --- src/pybroker/strategy.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/pybroker/strategy.py b/src/pybroker/strategy.py index e50702a..c9b0f7f 100644 --- a/src/pybroker/strategy.py +++ b/src/pybroker/strategy.py @@ -1211,8 +1211,9 @@ def _run_walkforward( sym_dates = df[df[DataCol.SYMBOL.value] == sym][ DataCol.DATE.value ].values - sym_dates.sort() - exit_dates[sym] = sym_dates[-1] + if len(sym_dates): + sym_dates.sort() + exit_dates[sym] = sym_dates[-1] for train_idx, test_idx in self.walkforward_split( df=df, windows=windows,