feat: commodity canonical naming, data provenance, provider bugfix#121
Merged
luokerenx4 merged 5 commits intomasterfrom Apr 14, 2026
Merged
feat: commodity canonical naming, data provenance, provider bugfix#121luokerenx4 merged 5 commits intomasterfrom
luokerenx4 merged 5 commits intomasterfrom
Conversation
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>
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.
Summary
gold,crude_oil,copper). Each provider's fetcher translates canonical → provider ticker internally (FMP:gold→GCUSD, yfinance:gold→GC=F). Wired intomarketSearchForResearchas 4th asset class with Chinese aliasesmain.tspassedproviders.equity(fmp) instead ofproviders.commodity(yfinance), causing all commodity data to silently come from FMP which returned 2022-era data for=Fsymbols{ 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[-1]; prevented Alice from hitting "Array access requires an array" errorsTest plan
npx tsc --noEmit— cleanpnpm test— 977 tests pass (50 files)npx vitest run --config vitest.bbProvider.config.ts— FMP gold/silver/brent + yfinance all 19 commodities pass{ value, dataRange }with recent dates🤖 Generated with Claude Code