Skip to content

fix: handle free-tier 'warning' column in get_historical_data (#66)#73

Open
alexpipipi wants to merge 1 commit into
mainfrom
fix/historical-data-free-tier-warning
Open

fix: handle free-tier 'warning' column in get_historical_data (#66)#73
alexpipipi wants to merge 1 commit into
mainfrom
fix/historical-data-free-tier-warning

Conversation

@alexpipipi

Copy link
Copy Markdown
Contributor

Closes #66 (reported by @pjmcdermott).

A free API key requesting more than one year of historical data gets an extra warning column 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_data relabels columns by fixed position, so the extra column produced a confusing pandas error:

ValueError: Length mismatch: Expected axis has 9 elements, new values have 8 elements

Fix

Added _strip_free_tier_warning() which surfaces the API warning message via the console and drops the warning column before the relabelling step. Applied right after the _rest_get call 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

  • New regression tests (tests/test_historical_free_tier_warning.py): reproduce the 9-column free-tier frame, assert no crash + warning logged + warning column dropped
  • pytest: ✅ 67 passed
  • Live API no-regression: normal get_historical_data('AAPL.US', interval='d') returns the expected 8 columns, no warning column

🤖 Generated with Claude Code

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>
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.

Attempting to retrieve more that 1 year of data using a free API key results in a Pandas error rather than useful warning message

1 participant