From 788f23853011036f4bf196e09e6f6cabd2b1d5c2 Mon Sep 17 00:00:00 2001 From: moshferatu Date: Tue, 13 Feb 2024 14:28:27 -0800 Subject: [PATCH] Query filters using datetime set to midnight regardless of what the caller provides as this is what is expected of the data --- backtesting/filter/backtest_filter.py | 1 + 1 file changed, 1 insertion(+) diff --git a/backtesting/filter/backtest_filter.py b/backtesting/filter/backtest_filter.py index 15fc9eb..709d88f 100644 --- a/backtesting/filter/backtest_filter.py +++ b/backtesting/filter/backtest_filter.py @@ -9,5 +9,6 @@ class BacktestFilter: pass def trade_allowed(self, date: datetime) -> bool: + date = datetime.combine(date, datetime.min.time()) # Enforcing midnight. filtered_dates = self.backtest_filter[self.backtest_filter['Date'] == date] return filtered_dates.empty or filtered_dates['Trade Allowed'].values[0] \ No newline at end of file