Skip to content

Commit

Permalink
Fix flaky test_daterange_duration_days_end_oolb_minute
Browse files Browse the repository at this point in the history
Test was failing to raise expected error when intended start did
not fall prior to the start limit as a result of the prior session
closing early and the start evaluated by the drg falling on a
non-trading minute after the close and then being reasonably
advanced to the start limit, hence the expected
`StartTooEarlyError` wasn't raised. Fixed by adding a day to the
`days` in these circumstances only.
  • Loading branch information
maread99 committed Oct 24, 2024
1 parent 7fd3de1 commit d9778d9
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions tests/test_daterange.py
Original file line number Diff line number Diff line change
Expand Up @@ -2856,9 +2856,15 @@ def test_daterange_duration_days_end_oolb_minute(
drg = self.get_drg(cal, pp, strict=False, **drg_kwargs)
assert drg.daterange == ((limit, end), end)

drg = self.get_drg(cal, pp, strict=True, **drg_kwargs)
start = end - (cal.day * pp["days"])
start = start if cal.is_trading_minute(start) else cal.previous_close(start)
if not cal.is_trading_minute(start):
# take off an extra day, otherwise drg would reasonably advance start to
# the start limit and not trigger StartTooEarlyError
pp["days"] += 1
start -= cal.day
start = start if cal.is_trading_minute(start) else cal.next_open(start)

drg = self.get_drg(cal, pp, strict=True, **drg_kwargs)
error_msg = re.escape(
f"Prices unavailable as start evaluates to {helpers.fts(start)} which"
" is earlier than the earliest minute for which price data is"
Expand Down

0 comments on commit d9778d9

Please sign in to comment.