diff --git a/src/pybroker/strategy.py b/src/pybroker/strategy.py index 361844c..bd9ce39 100644 --- a/src/pybroker/strategy.py +++ b/src/pybroker/strategy.py @@ -154,11 +154,7 @@ def backtest_executions( Returns: :class:`.TestResult` of the backtest. """ - # TODO pandas 2.1.0 - try: - test_dates = test_data[DataCol.DATE.value].unique().to_numpy() - except AttributeError: - test_dates = test_data[DataCol.DATE.value].unique() + test_dates = test_data[DataCol.DATE.value].unique() test_dates.sort() test_syms = test_data[DataCol.SYMBOL.value].unique() test_data = ( @@ -194,19 +190,10 @@ def backtest_executions( ) if exec.fn is not None: exec_fns[sym] = exec.fn - # TODO pandas 2.1.0 - try: - sym_exec_dates = { - sym: frozenset( - test_data.loc[pd.IndexSlice[sym, :]].index.to_numpy() - ) - for sym in exec_ctxs.keys() - } - except AttributeError: - sym_exec_dates = { - sym: frozenset(test_data.loc[pd.IndexSlice[sym, :]].index) - for sym in exec_ctxs.keys() - } + sym_exec_dates = { + sym: frozenset(test_data.loc[pd.IndexSlice[sym, :]].index.values) + for sym in exec_ctxs.keys() + } cover_sched: dict[np.datetime64, list[ExecResult]] = defaultdict(list) buy_sched: dict[np.datetime64, list[ExecResult]] = defaultdict(list) sell_sched: dict[np.datetime64, list[ExecResult]] = defaultdict(list) @@ -657,11 +644,7 @@ def walkforward_split( raise ValueError("DataFrame is empty.") date_col = DataCol.DATE.value dates = df[[date_col]] - # TODO pandas 2.1.0 - try: - window_dates = df[date_col].unique().to_numpy() - except AttributeError: - window_dates = df[date_col].unique() + window_dates = df[date_col].unique() window_dates.sort() error_msg = f""" Invalid params for {len(window_dates)} dates: