From 891b6eaa3df68679784780a2ac3c166e7226a892 Mon Sep 17 00:00:00 2001 From: Chris Sellers Date: Fri, 22 Nov 2024 18:23:26 +1100 Subject: [PATCH] Improve Tardis bar requests --- nautilus_trader/adapters/tardis/data.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/nautilus_trader/adapters/tardis/data.py b/nautilus_trader/adapters/tardis/data.py index 9240461c61d..051d4f64467 100644 --- a/nautilus_trader/adapters/tardis/data.py +++ b/nautilus_trader/adapters/tardis/data.py @@ -445,6 +445,17 @@ async def _request_bars( LogColor.MAGENTA, ) + if start and start.date() == self._clock.utc_now().date(): + self._log.error( + f"Cannot request bars: `start` cannot fall on the current UTC date, was {start.date()} (try an earlier `start`)", + ) + return + if start and end and start.date() == end.date(): + self._log.error( + f"Cannot request bars: `start` and `end` cannot fall on the same date, was {start.date()} (try an earlier `start`)", + ) + return + date_now_utc = self._clock.utc_now().date() replay_request = create_replay_normalized_request_options( @@ -478,8 +489,8 @@ async def _request_bars( bar for pycapsule in bar_capsules if (bar := capsule_to_data(pycapsule)) - and (start is None or bar.ts_event >= start) - and (end is None or bar.ts_event <= end) + and (start is None or bar.ts_event >= start.value) + and (end is None or bar.ts_event <= end.value) ] self._log.debug(