Skip to content

fix: change assert tp_idx > 0 to tp_idx >= 0 in TimeAdjuster.truncate()#2245

Open
Whning0513 wants to merge 1 commit into
microsoft:mainfrom
Whning0513:fix/issue-1610-assert-boundary
Open

fix: change assert tp_idx > 0 to tp_idx >= 0 in TimeAdjuster.truncate()#2245
Whning0513 wants to merge 1 commit into
microsoft:mainfrom
Whning0513:fix/issue-1610-assert-boundary

Conversation

@Whning0513

@Whning0513 Whning0513 commented Jun 4, 2026

Copy link
Copy Markdown

When setting start_time to a date that happens to be the first trading day in day.txt, the workflow crashes with AssertionError in TimeAdjuster.truncate(). The root cause is that tp_idx (the index from calendar.searchsorted()) is 0 for the first calendar entry, but the assertion checks tp_idx > 0. Index 0 is a perfectly valid position — the assertion should be tp_idx >= 0.

Would appreciate a review, thanks!

Fixes microsoft#1610

When start_time in the workflow config exactly matches the first trading
day in the calendar, tp_idx is 0, causing the assertion to fail.
The >= check handles this edge case without affecting existing behavior.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant