Skip to content

feat: commodity canonical naming, data provenance, provider bugfix#121

Merged
luokerenx4 merged 5 commits intomasterfrom
dev
Apr 14, 2026
Merged

feat: commodity canonical naming, data provenance, provider bugfix#121
luokerenx4 merged 5 commits intomasterfrom
dev

Conversation

@luokerenx4
Copy link
Copy Markdown
Contributor

Summary

  • Commodity canonical naming — CommodityCatalog (24 commodities) with provider-agnostic IDs (gold, crude_oil, copper). Each provider's fetcher translates canonical → provider ticker internally (FMP: gold→GCUSD, yfinance: gold→GC=F). Wired into marketSearchForResearch as 4th asset class with Chinese aliases
  • Fix: commodityClient used wrong providermain.ts passed providers.equity (fmp) instead of providers.commodity (yfinance), causing all commodity data to silently come from FMP which returned 2022-era data for =F symbols
  • calculateIndicator returns { value, dataRange } — OHLCV time span metadata flows through the full type chain (TrackedValues → stats/technical → calculator). Agent can now see "to": "2022-04-29" and know the data is stale
  • Tool description clarification — SMA/RSI return scalar, no [-1]; prevented Alice from hitting "Array access requires an array" errors
  • e2e test coverage — bbProvider tests for FMP/yfinance commodity canonical names + full analysis pipeline tests across equity/crypto/commodity

Test plan

  • npx tsc --noEmit — clean
  • pnpm test — 977 tests pass (50 files)
  • npx vitest run --config vitest.bbProvider.config.ts — FMP gold/silver/brent + yfinance all 19 commodities pass
  • Analysis e2e: equity AAPL, crypto BTCUSD/ETHUSD, commodity gold/crude_oil all return { value, dataRange } with recent dates
  • Manual: deploy and verify Alice's commodity_watchlist cron returns fresh data

🤖 Generated with Claude Code

Ame and others added 5 commits April 14, 2026 09:25
Establish provider-agnostic commodity identity so agent/cron can use
canonical names (gold, crude_oil, copper) instead of provider-specific
tickers (GC=F, GCUSD). Provider fetchers translate internally.

- Add CommodityCatalog (24 commodities, search/resolve/list) with
  Chinese aliases and provider ticker aliases for migration ease
- Add FMP COMMODITY_MAP mirroring yfinance's pattern for canonical→ticker
- Wire commodity into marketSearchForResearch as 4th asset class
- Add bbProvider e2e tests for both FMP and yfinance canonical names
  (FMP Starter: only gold/silver/brent; yfinance: all 19 pass)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
main.ts passed `providers.equity` (fmp) to SDKCommodityClient and
OpenBBCommodityClient instead of `providers.commodity` (yfinance).
This caused all commodity data requests to silently go through FMP,
which returned 2022-era historical data for Yahoo-style =F symbols
without any error — explaining the "frozen data" reports from the
commodity_watchlist cron (04-07 through 04-10).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Extend the indicator calculator's type chain so data provenance flows
from OHLCV bars all the way to the tool return value. This would have
caught the FMP-returning-2022-data bug immediately — agent can now see
"to: 2022-04-29" and know something is wrong.

- Add TrackedValues type (values + DataSourceMeta) to carry metadata
  alongside number arrays through the calculation pipeline
- Data-access functions (CLOSE/HIGH/LOW/OPEN/VOLUME) return TrackedValues
- Stats/technical functions accept number[] | TrackedValues via toValues()
- Calculator collects sources and returns { value, dataRange }
- Tool layer builds meta from actual bar dates (no synthetic timestamps)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Full pipeline tests: SDK client → OHLCV fetch → calculator → { value, dataRange }.
Covers CLOSE, SMA, RSI, BBANDS for equity (AAPL), crypto (BTCUSD, ETHUSD),
commodity canonical names (gold, crude_oil), and FMP commodity with
year >= 2026 assertion to catch stale-data bugs.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Alice was appending [-1] to SMA/RSI results, causing "Array access
requires an array, got number" errors. The tool description grouped
array access with stats/technical functions, making it easy to
misread as "all results need [-1]".

Restructured description: data-access functions (CLOSE etc) return
arrays and support [-1]; stats/technical functions return scalars
and must NOT use [-1]. Also noted commodity canonical names and
the new { value, dataRange } return shape.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@luokerenx4 luokerenx4 merged commit 953fd91 into master Apr 14, 2026
2 checks passed
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