Get High Grade Copper Dec 2025 (HGZ25) - Per Pound prices using this API with Python examples
Need High Grade Copper Dec 2025 (HGZ25) per-pound prices you can wire into Python? This guide shows how to use the Metals-API to fetch real-time copper (XCU) rates, convert them to USD per pound, and build time-series analytics for backtesting your HGZ25 strategies. While futures like HGZ25 are exchange-traded contracts and not direct symbols on Metals-API, you can use spot copper (XCU) as a liquid proxy, then account for futures basis and seasonality in your own models. We’ll implement an end-to-end workflow: query latest copper rates, convert to per-pound, retrieve multi-day history, and discuss practical caveats like units, base currency, timestamps, caching, and market closures.
What HGZ25 traders and builders actually need
HGZ25 is the COMEX High Grade Copper futures contract expiring in December 2025. If you’re:
- Building a quoting engine for copper-linked products, you likely want a reliable per-pound spot reference with the ability to overlay a futures basis curve.
- Implementing risk checks in a trading tool, you need stable, cached spot data and a conversion to USD/lb that’s consistent across environments.
- Backfilling charts and analytics for HGZ25, you want time-series copper spot data (XCU) as an input to your basis or curve-fitting model.
This post uses the Metals-API to deliver these pieces cleanly and reliably. If you don’t have an API key yet, go to the Metals-API Website and get a free API key to follow along.
Key idea: Use copper (XCU) spot, convert to USD per pound, and layer futures basis yourself
Metals-API returns spot metal exchange rates by default with base=USD and units per troy ounce. The copper symbol is XCU. Because most futures (including HGZ25) and physical contracts reference prices per pound (avoirdupois), you need to convert per-troy-ounce data to per-pound. Then, for HGZ25 valuation, add your independently sourced futures basis term structure (from your brokerage or exchange feed) to translate spot into the appropriate futures level. This separation keeps your architecture portable: Metals-API handles metals spot data; your trading system handles futures term structure and execution-grade details.
Important unit and conversion notes
- Metals-API default unit: per troy ounce.
- 1 troy ounce = 31.1034768 grams.
- 1 avoirdupois pound = 453.59237 grams.
- Therefore, 1 pound = 453.59237 / 31.1034768 ≈ 14.583333 troy ounces.
- Metals-API “rates” are quoted as ounces of metal per 1 USD (base=USD). Price in USD per troy ounce = 1 / rate.
- USD per pound = (USD per troy ounce) × 14.583333 = 14.583333 / rate.
Example: If rates.XCU = 0.294118 ounces per USD, then USD per ounce ≈ 1 / 0.294118 ≈ 3.4, and USD per pound ≈ 3.4 × 14.583333 ≈ 49.583. Always compute this in code to avoid rounding slippage.
Endpoints we use for HGZ25 workflows
To keep this focused, we’ll use three Metals-API endpoints most relevant to HGZ25 builders:
- Latest (real-time) rates for XCU, which you’ll convert to USD/lb.
- Time-series (daily historical) rates for XCU to build spot curves and backtests.
- OHLC (open/high/low/close) for adding daily candles to charts and calculating volatility/ATR-style indicators. Note: use where supported for XCU per your plan.
For full endpoint coverage and additional parameters (e.g., bid/ask, intraday, fluctuation, conversion, LME history), see the Metals-API Documentation. To verify if a symbol is available for a given endpoint, check the Metals-API Supported Symbols.
Validate the symbol and plan fit
Before coding, confirm XCU is listed and available on your plan. Use the symbols list linked above. Futures tickers like HGZ25 are exchange contract identifiers and typically not returned by Metals-API. In this workflow, use XCU spot and apply your basis in downstream logic.
Requesting latest copper (XCU) and converting to USD/lb
Below is a curl request for the Latest Rates Endpoint querying only copper (XCU) with base USD.
curl -s "https://metals-api.com/api/latest?access_key=YOUR_API_KEY&base=USD&symbols=XCU"
Example JSON response (structure aligns with the Metals-API latest format and includes XCU):
{
"success": true,
"timestamp": 1790035808,
"base": "USD",
"date": "2026-09-22",
"rates": {
"XCU": 0.294118
},
"unit": "per troy ounce"
}
Interpreting the fields you actually use
- success: Boolean indicating request status.
- timestamp: Unix epoch seconds when the rate snapshot was taken. Convert to your app timezone; Metals-API returns UTC-aligned date strings.
- base: The base currency of the rates. Default is USD.
- date: UTC date corresponding to the snapshot.
- rates.XCU: Copper ounces per USD (per troy ounce unit). To get USD per lb, compute 14.583333 / rates.XCU.
- unit: “per troy ounce” clarifies the unit of the rate.
Python example: Convert XCU to USD/lb and prepare for HGZ25 basis
import os
import requests
API_KEY = os.getenv("METALS_API_KEY", "YOUR_API_KEY")
BASE_URL = "https://metals-api.com/api"
def usd_per_pound_from_rate(rate_oz_per_usd: float) -> float:
# 1 lb = ~14.583333 troy ounces
TROY_OUNCES_PER_POUND = 14.583333
return TROY_OUNCES_PER_POUND / rate_oz_per_usd
def latest_copper_usd_per_lb():
url = f"{BASE_URL}/latest"
params = {
"access_key": API_KEY,
"base": "USD",
"symbols": "XCU"
}
r = requests.get(url, params=params, timeout=10)
r.raise_for_status()
data = r.json()
if not data.get("success", False):
raise RuntimeError(f"Metals-API error: {data}")
xcu_rate = data["rates"]["XCU"] # ounces per USD
usd_per_lb = usd_per_pound_from_rate(xcu_rate)
snapshot_ts = data["timestamp"]
snapshot_date = data["date"]
return {
"timestamp": snapshot_ts,
"date": snapshot_date,
"xcu_rate_oz_per_usd": xcu_rate,
"usd_per_lb": round(usd_per_lb, 6),
"unit_input": data.get("unit", "per troy ounce"),
"unit_output": "USD per pound"
}
if __name__ == "__main__":
print(latest_copper_usd_per_lb())
How to use this for HGZ25: With USD/lb spot in hand, incorporate your futures basis model. For example, fetch your HGZ25 mid-market basis (USD/lb) from a market data vendor or compute via calendar spreads. Then:
- Indicative HGZ25 price (USD/lb) ≈ XCU spot (USD/lb) + December 2025 basis (USD/lb)
- Or apply cost-of-carry if you maintain your own storage/financing model.
Note: Metals-API focuses on metals spot and related historical data; for contract-specific futures quotes like HGZ25, use exchange or broker feeds (e.g., CME Group’s contract specifications and quotes; see CME High Grade Copper specs).
Build an HGZ25 backtest with spot time-series (XCU)
To create a historical series for research and strategy calibration, request daily time-series for XCU and convert each observation to USD/lb. You can then align those values with your historical HGZ25 settlements and measure basis behavior, seasonal patterns, or roll strategies.
Time-series Endpoint: daily copper spot for a period
Example curl request for a date range:
curl -s "https://metals-api.com/api/timeseries?access_key=YOUR_API_KEY&base=USD&symbols=XCU&start_date=2026-09-15&end_date=2026-09-22"
Illustrative JSON response with XCU in the structure returned by the timeseries endpoint:
{
"success": true,
"timeseries": true,
"start_date": "2026-09-15",
"end_date": "2026-09-22",
"base": "USD",
"rates": {
"2026-09-15": { "XCU": 0.296735 },
"2026-09-16": { "XCU": 0.295410 },
"2026-09-17": { "XCU": 0.296000 },
"2026-09-18": { "XCU": 0.295900 },
"2026-09-21": { "XCU": 0.294800 },
"2026-09-22": { "XCU": 0.294118 }
},
"unit": "per troy ounce"
}
Fields and how to use them
- timeseries: Indicates a multi-day response.
- start_date / end_date: The requested window; ensure you handle weekends/holidays (some dates may not appear if markets are closed).
- rates[date].XCU: Ounces per USD for that date. Convert each to USD/lb via 14.583333 / rate.
- unit: Confirms per troy ounce.
Tips for robust time-series handling
- Fill missing non-trading days if your model expects continuous calendars; label them as non-trading or forward-fill cautiously for visualization only.
- Normalize your timestamps to UTC to match Metals-API; convert downstream as needed.
- Cache results locally (e.g., by YYYY-MM-DD and symbol) to minimize repeated API calls.
- Validate monotonic date ordering and deduplicate if you run multiple fetches.
Daily candles and risk analytics with OHLC
For charting, volatility modeling, and signal extraction, the OHLC endpoint provides open/high/low/close snapshots for supported symbols and dates. You can compute ranges, true range, or intraday-based approximations if your plan supports intraday queries. Below is an example format (ensure XCU OHLC is available on your plan):
{
"success": true,
"timestamp": 1790035808,
"base": "USD",
"date": "2026-09-22",
"rates": {
"XCU": {
"open": 0.295000,
"high": 0.296500,
"low": 0.294000,
"close": 0.294118
}
},
"unit": "per troy ounce"
}
Usage:
- Convert open/high/low/close to USD/lb: for each field v, USD/lb = 14.583333 / v.
- Compute indicators (e.g., ATR) on the USD/lb series to align with HGZ25 risk metrics.
Why use spot copper (XCU) for an HGZ25 workflow?
Futures dynamics are often decomposed into two pieces: a spot component and a basis/term-structure component. Metals-API supplies a stable spot signal (XCU) and robust historical data to support:
- Real-time indicative pricing for downstream quoting UIs (convert to USD/lb promptly).
- Backtesting roll strategies and basis regressions when combined with your futures settlement history.
- Risk and P&L estimation driven by spot shocks, with separate scenarios for basis widening/narrowing.
By decoupling spot from futures mechanics, you retain flexibility and avoid lock-in to a single exchange feed in early product iterations.
Units, base currency, timestamps, and timezone: things that bite new builders
- Units: Always check “unit” in the response. Metals-API rates are per troy ounce by default. Convert explicitly to pounds for HGZ25 parity.
- Base currency: Base is USD unless you specify otherwise. If you need prices in another currency (e.g., EUR/lb), convert currency after you compute USD/lb using either Metals-API conversion or your FX feed.
- Timestamps: Use the Unix timestamp for ordering snapshots precisely; “date” is UTC by design. Align all internal pipelines to UTC first, then localize for display.
- Weekends/holidays: Metals markets and liquidity vary by region and venue; handle days with missing or unchanged data, and do not extrapolate blindly for trading decisions.
Caching and request efficiency
- Cache latest responses with a TTL aligned to your plan’s update frequency (e.g., 60 minutes or 10 minutes). Don’t over-poll.
- For time-series, store retrieved ranges and use incremental updates rather than re-fetching the entire history daily.
- Batch symbols where possible; but for this HGZ25 workflow you likely only need XCU.
Error handling and data validation
- Check success and handle non-200 HTTP statuses. Retry transient network errors with exponential backoff.
- Validate “rates” contains XCU before accessing it. Gracefully handle nulls or missing fields.
- Log timestamp and unit for every calculation so you can trace mismatches in post-mortems.
Security best practices
- Store your access_key in environment variables or a secrets manager, not in source control.
- Use HTTPS-only and verify your HTTP client’s certificate handling is standard.
- Rate-limit your own public endpoints if you proxy Metals-API data to frontends to avoid key leakage and abuse.
Architectural pattern for HGZ25 with Metals-API
- Ingest layer: Scheduled job hits Metals-API latest and timeseries for XCU.
- Normalization layer: Convert all XCU rates to USD/lb; store with UTC timestamps, and clearly annotate the conversion factor used.
- Futures layer: Join USD/lb spot with your HGZ25 basis curve or settlement history; compute indicative HGZ25 prices and analytics.
- Delivery: Surface per-pound prices to tools, dashboards, and alerts. Use cached responses for real-time cards; batch time-series to BI/ML systems.
Endpoint specifics and developer notes
1) Latest Rates Endpoint for XCU
Purpose: fetch the most recent copper rate in ounces per USD, then convert to USD/lb for HGZ25 parity.
- Required params: access_key. Optional: base (defaults to USD), symbols (use XCU).
- Response fields you use: timestamp, date, base, rates.XCU, unit.
Common pitfalls:
- Forgetting that rates are ounces per USD, not USD per ounce. Always invert before converting to pounds.
- Not caching within the plan’s update interval (avoid wasteful polling).
Performance tips:
- Pin to symbols=XCU to reduce payload size.
- Process in-memory and write only derived USD/lb values and raw rate to storage.
2) Time-Series Endpoint for XCU
Purpose: backfill daily XCU spot to build indicators, compare to HGZ25 settlements, and extract basis behavior.
- Required params: access_key, start_date, end_date. Optional: base=USD, symbols=XCU.
- Response fields: timeseries flag, date range, rates[date][symbol], unit.
Pitfalls:
- Assuming every calendar date is present; handle weekends/holidays explicitly.
- Inconsistent rounding can produce accidental arbitrage in derived series; standardize precision.
Optimization:
- Partition historical storage by symbol and month; ingest incremental deltas.
- Precompute USD/lb values on ingest, not on read.
3) OHLC Endpoint for XCU
Purpose: obtain daily open/high/low/close for enhanced charting and volatility estimates relevant to HGZ25 risk models.
- Key fields: rates.XCU.open/.high/.low/.close. All are ounces per USD; convert each to USD/lb.
Usage tips:
- Compute ranges and ATR in USD/lb to align with HGZ25 quote conventions.
- If your plan doesn’t include OHLC for XCU, fall back to time-series closes and your intraday calculations where available.
Realistic response walkthrough
Suppose Latest returns:
{
"success": true,
"timestamp": 1790035808,
"base": "USD",
"date": "2026-09-22",
"rates": {
"XCU": 0.294118
},
"unit": "per troy ounce"
}
- rates.XCU = 0.294118 ounces per USD.
- USD/oz = 1 / 0.294118 ≈ 3.4.
- USD/lb = 3.4 × 14.583333 ≈ 49.583.
- Store both the raw rate and USD/lb for auditability and to recompute if unit conventions change.
A note on HGZ25 basis and seasonality
Metal futures prices reflect expected storage, financing, supply-demand seasonality, and exchange-specific factors. For HGZ25, you will generally observe that the futures price may trade at a premium or discount to spot XCU, and that this basis evolves over time. To model HGZ25 fairly in your systems:
- Source HGZ25 settlements or real-time quotes from your exchange or broker feed.
- Estimate basis term structure vs. spot XCU (USD/lb). Fit curves (e.g., spline, Nelson-Siegel) or regression-based models.
- Use Metals-API XCU as the anchor. For live quoting, XCU USD/lb + current basis gives an indicative HGZ25 level.
Best practices for production systems
- Monitoring: Track error rates, response latency, and staleness checks vs. timestamp.
- Circuit breakers: Fall back to the last good spot value with a stale-data warning if the endpoint is temporarily unavailable.
- Alerting: Trigger alerts on abnormal day-over-day changes in USD/lb and on missing data in expected trading windows.
Get started now
Visit the Metals-API Website to get a free API key and start pulling XCU spot rates today. Use the Metals-API Supported Symbols page to confirm copper support on your plan, and review the Metals-API Documentation for advanced endpoints, parameters, and response schemas.
Additional resources
- CME High Grade Copper contract specifications for HG futures contract details.
- Metals-API Documentation for endpoint details and plan-specific features.
- Metals-API Supported Symbols to verify copper symbol availability.
FAQ
Can I query HGZ25 directly from Metals-API?
No. Metals-API provides metals spot and related historical data (e.g., XCU for copper). Futures contract symbols like HGZ25 are exchange-traded instruments. Use Metals-API for spot (convert to USD/lb) and combine with your futures feed for HGZ25-specific quotes.
Does Metals-API return USD per pound directly?
By default, it returns metals per troy ounce with base USD. Convert to USD/oz by inverting the rate, then multiply by 14.583333 to get USD/lb.
How often are latest rates updated?
Update frequency depends on your plan tier. Cache responses in your service according to the documented update interval to avoid unnecessary calls. See the Metals-API Documentation for details.
Which timezone should I assume for timestamps and dates?
Timestamps are Unix epoch seconds; dates are UTC. Normalize to UTC internally, and only convert to local timezones at the presentation layer.
Can I get OHLC for copper (XCU)?
OHLC availability depends on plan and symbol support. If supported for XCU on your plan, you can compute USD/lb for open/high/low/close and use them for charting and volatility metrics. Otherwise, use time-series closes.
How do I handle weekends and holidays?
Expect missing dates or unchanged values. Do not assume continuous daily changes. Forward-fill only for display; avoid using filled values in risk or trading logic without explicit justification.
What about FX conversions (e.g., EUR/lb)?
Compute USD/lb first, then convert using either Metals-API currency endpoints (per your plan) or your FX provider to maintain consistency across your stack.
Where can I find all supported symbols?
Check the Metals-API Supported Symbols page for the current list and specifications.