Skip to content

Real price data: yfinance re-ingest + Interactive Brokers source - #63

Open
digitalflanker-ux wants to merge 2 commits into
mainfrom
feat/ibkr-data-source
Open

Real price data: yfinance re-ingest + Interactive Brokers source#63
digitalflanker-ux wants to merge 2 commits into
mainfrom
feat/ibkr-data-source

Conversation

@digitalflanker-ux

@digitalflanker-ux digitalflanker-ux commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

Replaces the synthetic price data and adds Interactive Brokers as an ongoing data source. (Robinhood is execution-only and a poor research source, so it was not added.)

Immediate fix (done, not a code change)

Wiped the synthetic prices/features and re-ingested ~3 years of real, adjusted daily history from yfinance for the full universe, then recomputed features:

  • 296,743 price rows, 395/396 symbols; features 394 symbols incl. momentum/RSI/ADX/volume/obv.
  • INTC momentum is now a realistic +14.9% (was a synthetic artifact). The screens/Assistant now run on real data.

This PR — IBKR historical source (for ongoing)

  • hrp/data/sources/ibkr_source.py — daily OHLCV via ib_insync reqHistoricalData against IB Gateway/TWS; pacing-aware multi-symbol loop; env-config (IBKR_HOST/PORT, IBKR_DATA_CLIENT_ID, HRP_IBKR_PACE_SECONDS). ib_insync is imported lazily (optional trading extra), so importing/registering it needs no install.
  • Factory registers "ibkr" (IBKR primary, yfinance fallback).
  • ingest_prices gains an ibkr branch; run_job --price-source {yfinance,polygon,ibkr} threads it to the prices job.
  • .env.example + the runbook document usage.
pip install -e ".[trading]"
python -m hrp.agents.run_job --job prices --price-source ibkr   # needs IB Gateway running

Verification

  • 11 data-source tests pass (schema mapping, duration, factory registration, injected-client path); ruff/black clean.
  • Honest caveat: the live reqHistoricalData round-trip needs a running IB Gateway + market-data permissions, which aren't available in CI — that path is verified manually, not in tests. IBKR TRADES bars are unadjusted, so adj_close mirrors close.

🤖 Generated with Claude Code

https://claude.ai/code/session_011BFeBAuxWTFRayNGMD7VDn


View with Codesmith Autofix with Codesmith
Need help on this PR? Tag /codesmith with what you need. Autofix is disabled.

digitalflanker-ux and others added 2 commits June 29, 2026 20:07
Adds an IBKRDataSource (ib_insync reqHistoricalData) for broker-grade daily bars,
selectable for ongoing ingestion. yfinance remains the default (best for the
full historical backfill); Robinhood is execution-only and not added.

- hrp/data/sources/ibkr_source.py: daily OHLCV via IB Gateway/TWS, pacing-aware
  multi-symbol loop, env-config (IBKR_HOST/PORT/IBKR_DATA_CLIENT_ID/
  HRP_IBKR_PACE_SECONDS); ib_insync imported lazily (optional `trading` extra).
- factory: register "ibkr" (IBKR primary, yfinance fallback).
- ingest_prices: add `ibkr` source branch (DataSourceBase typing).
- run_job: `--price-source {yfinance,polygon,ibkr}` threads to the prices job.
- tests: schema mapping, duration, factory, injected-client path (no Gateway
  needed); live reqHistoricalData verified manually against a running Gateway.
- .env.example + runbook document IBKR usage.

Note: the synthetic prices were separately replaced with real yfinance history
(prices + features re-ingested) as the immediate fix.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011BFeBAuxWTFRayNGMD7VDn
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011BFeBAuxWTFRayNGMD7VDn
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