Skip to content

Add gold and silver commodity endpoints#390

Open
Jackisome wants to merge 1 commit into
RomelTorres:developfrom
Jackisome:add-gold-silver-commodities
Open

Add gold and silver commodity endpoints#390
Jackisome wants to merge 1 commit into
RomelTorres:developfrom
Jackisome:add-gold-silver-commodities

Conversation

@Jackisome

@Jackisome Jackisome commented Jun 21, 2026

Copy link
Copy Markdown

Summary

Adds wrappers for the official Alpha Vantage gold/silver endpoints in Commodities, aligned with the existing commodity method style (get_wti(), get_copper(), etc.):

Historical series:

  • get_gold(interval="monthly", symbol="GOLD") -> GOLD_SILVER_HISTORY
  • get_silver(interval="monthly", symbol="SILVER") -> GOLD_SILVER_HISTORY

Realtime spot prices:

  • get_gold_spot(symbol="GOLD") -> GOLD_SILVER_SPOT
  • get_silver_spot(symbol="SILVER") -> GOLD_SILVER_SPOT

The official docs accept:

  • Gold: GOLD / XAU
  • Silver: SILVER / XAG

Historical intervals are documented as:

  • daily
  • weekly
  • monthly

Relationship to #387

This PR overlaps with #387 on the historical endpoint (GOLD_SILVER_HISTORY). I updated this PR to follow the same package-style API direction as #387 (get_gold() / get_silver()), while also adding:

  • realtime spot endpoint support (get_gold_spot() / get_silver_spot())
  • test coverage for history and spot methods
  • XAU / XAG symbol coverage in tests

If maintainers prefer #387 as the base implementation, I am happy to adapt this PR to contribute only the missing spot endpoint support and tests.

Context

This follows up on the previously closed #385. The duplicate follow-up issue #389 was closed in favor of this implementation PR.

The official API supports these endpoints, but they were not exposed through the Python wrapper. Using ForeignExchange / FX_DAILY is not a substitute for XAG/USD or XAU/USD, because gold/silver are handled by the dedicated GOLD_SILVER_* endpoints.

Tests

python -m pytest test_alpha_vantage/test_commodities.py -q

Result:

4 passed

I also tried a broader existing test file, but it appears blocked by an unrelated existing import problem around sectorperformance.py not being present in the branch.

@Jackisome
Jackisome force-pushed the add-gold-silver-commodities branch from 34b209a to ecd5b84 Compare June 21, 2026 17:12
@Jackisome

Copy link
Copy Markdown
Author

I noticed that #387 already implements the historical gold/silver endpoint via get_gold() and get_silver().

I have updated this PR to align with that package API style instead of the earlier get_gold_silver_* naming:

  • get_gold(...) / get_silver(...) for GOLD_SILVER_HISTORY
  • get_gold_spot(...) / get_silver_spot(...) for GOLD_SILVER_SPOT

So there is still overlap with #387 on the historical endpoint, but this PR additionally covers the realtime spot endpoint and adds tests for both history and spot behavior, including XAU / XAG aliases.

If maintainers prefer #387 as the base, I am happy to adjust this PR further to contribute only the spot support and tests.

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.

Feature Request: add support for gold/silver API calls

1 participant