fix: handle free-tier 'warning' column in get_historical_data (#66)#73
Open
alexpipipi wants to merge 1 commit into
Open
fix: handle free-tier 'warning' column in get_historical_data (#66)#73alexpipipi wants to merge 1 commit into
alexpipipi wants to merge 1 commit into
Conversation
A free API key requesting more than one year of historical data receives an extra 'warning' column in the response. get_historical_data relabels columns by fixed position, so the extra column caused a confusing pandas error: "ValueError: Length mismatch: Expected axis has 9 elements, new values have 8". Added _strip_free_tier_warning(): it surfaces the API warning message via the console and drops the 'warning' column before relabelling, so the call returns the available (one-year) data with a clear log message instead of crashing. Applied to both the EOD and intraday branches. Added regression tests. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #66 (reported by @pjmcdermott).
A free API key requesting more than one year of historical data gets an extra
warningcolumn appended to the response (NaN on all rows except the last, which holds "Data is limited by one year as you have free subscription.").get_historical_datarelabels columns by fixed position, so the extra column produced a confusing pandas error:Fix
Added
_strip_free_tier_warning()which surfaces the API warning message via the console and drops thewarningcolumn before the relabelling step. Applied right after the_rest_getcall in both the EOD and intraday branches.The call now returns the available (one-year) data with a clear warning logged, instead of crashing — which is what the reporter asked for.
Verification
tests/test_historical_free_tier_warning.py): reproduce the 9-column free-tier frame, assert no crash + warning logged +warningcolumn droppedpytest: ✅ 67 passedget_historical_data('AAPL.US', interval='d')returns the expected 8 columns, nowarningcolumn🤖 Generated with Claude Code