Skip to content

Commit

Permalink
Improve Tardis bar requests
Browse files Browse the repository at this point in the history
  • Loading branch information
cjdsellers committed Nov 22, 2024
1 parent a243de6 commit 891b6ea
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions nautilus_trader/adapters/tardis/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 891b6ea

Please sign in to comment.