Skip to content

Fix Pandas >= 2.x compatibility issue in get_history() frequency generation#33

Open
JrryChen wants to merge 2 commits into
yhilpisch:masterfrom
JrryChen:master
Open

Fix Pandas >= 2.x compatibility issue in get_history() frequency generation#33
JrryChen wants to merge 2 commits into
yhilpisch:masterfrom
JrryChen:master

Conversation

@JrryChen
Copy link
Copy Markdown

@JrryChen JrryChen commented Mar 1, 2026

This PR fixes a compatibility issue with Pandas versions >= 2.x when calling get_history with second-based granularity (e.g. "S5").

In newer Pandas versions, uppercase time frequency aliases are no longer accepted when passed to pd.time_date() so the current implementation of batching frequencies into hourly segments when a user requests second-based granularity breaks, resulting in an error:
ValueError: Invalid frequency: 6H.
Failed to parse with error message:
ValueError("Invalid frequency: H. Failed to parse with error message: KeyError('H'). Did you mean h?")

This PR updates this freq string to use a lowercase "h" to be more in line with newer Pandas versions.

No other bugs were noticed beyond fixing this error.

JrryChen added 2 commits March 1, 2026 09:29
Newer numpy versions use a lowercase "h" instead of "H". When trying to get smaller granular historical data like at 5 seconds, an error would occur:
ValueError: Invalid frequency: 6H. Failed to parse with error message: ValueError("Invalid frequency: H. Failed to parse with error message: KeyError('H'). Did you mean h?")
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