Get LBMA Platinum Pm (LBXPTPM) - Per Troy Ounce Historical Prices using this API — Python example to fetch daily closes

Metals-API 11 min read
Get LBMA Platinum Pm (LBXPTPM) - Per Troy Ounce Historical Prices using this API — Python example to fetch daily closes

If you need LBMA Platinum Pm (LBXPTPM) historical prices per troy ounce to power a daily close chart, feed a backtesting engine, or reconcile ERP valuations, you can get them quickly with the Metals-API. This guide shows how to fetch LBXPTPM daily closes using two focused endpoints—the time-series and OHLC endpoints—plus a Python example that returns a clean vector of closes you can drop into your analytics pipeline. We’ll cover units (troy ounces vs grams), base currency, timestamps and timezone, caching to control costs, and how to handle weekends and market closures. By the end, you’ll have everything you need to integrate LBMA Platinum PM fix data into production. For API setup and broader capabilities, start at the Metals-API Website and the authoritative Metals-API Documentation.

Why LBXPTPM historical closes matter for green-tech and manufacturing analytics

Platinum (XPT) is a cornerstone metal in catalytic converters, green hydrogen production (PEM electrolyzers and fuel cells), and a spectrum of sustainable innovation. Accurate LBMA Platinum PM fix prices help:

  • Fintech and quant teams build risk models, factor studies, and signal engines tied to clean-energy supply chains.
  • Manufacturers and jewelry businesses price inventory, hedge exposure, and benchmark procurement.
  • Smart technology platforms integrate live dashboards and automated alerts for sustainable materials portfolios.

Metals-API delivers LBXPTPM historical data per troy ounce via JSON, so you can ingest, transform, and visualize daily closes with minimal friction.

Key concept: LBXPTPM and Metals-API rates orientation

Metals-API returns rates by default as “per 1 USD,” where the numeric value represents troy ounces per USD (unit: per troy ounce). That’s an important orientation point:

  • If rates.LBXPTPM = 0.000912, it means 1 USD = 0.000912 troy ounces of LBMA Platinum PM.
  • To get a conventional “USD per troy ounce” close, invert it: close_usd_per_oz = 1 / 0.000912 ≈ 1096.49.

You can also set a different base currency (e.g., EUR), but the default is USD. Always confirm the unit field and invert when you need “price per ounce.”

Symbols and metadata

Before you code, confirm symbol availability and naming on the official list: Metals-API Supported Symbols. For this article and the examples below, we use the exact symbol from the title: LBXPTPM.

Which endpoints to use for daily LBXPTPM closes

For historical LBMA Platinum PM prices per troy ounce, these 2–3 endpoints cover most production use cases:

  • Time-series Endpoint: Retrieve daily rates for a date range. Best for building a vector of closes efficiently.
  • OHLC Endpoint: Fetch open, high, low, close for a specific date. Useful for day-level quality control or spot analysis.
  • Historical Rates Endpoint (single day): Fetch the rate on a given date—handy for backfills or verification.

We’ll focus on time-series to fetch “daily closes” at scale, then show OHLC and single-day historical for verification and data QA.

Authentication and base request pattern

You authenticate via an API key. Pass it via the access_key query parameter. Get yours free at the Metals-API Website and review required parameters in the Metals-API Documentation.

Time-series endpoint: fetch a clean vector of daily LBXPTPM closes

Purpose: Retrieve daily historical rates for LBXPTPM between start_date and end_date, inclusive. This is ideal for building a daily time series of “closes.”

HTTP request parameters

  • access_key: Your API key.
  • start_date: YYYY-MM-DD (must be within your plan’s historical range).
  • end_date: YYYY-MM-DD (not earlier than start_date).
  • symbols: Use exactly LBXPTPM.
  • base (optional): Defaults to USD. If omitted, the rate is in “troy ounces per USD.”

Curl example: daily LBXPTPM closes for a week

curl -G https://metals-api.com/api/timeseries \
--data-urlencode "access_key=YOUR_API_KEY" \
--data-urlencode "start_date=2026-09-13" \
--data-urlencode "end_date=2026-09-20" \
--data-urlencode "symbols=LBXPTPM" \
--data-urlencode "base=USD"

Illustrative JSON response

{
"success": true,
"timeseries": true,
"start_date": "2026-09-13",
"end_date": "2026-09-20",
"base": "USD",
"rates": {
"2026-09-13": { "LBXPTPM": 0.000915 },
"2026-09-14": { "LBXPTPM": 0.000914 },
"2026-09-15": { "LBXPTPM": 0.000913 },
"2026-09-16": { "LBXPTPM": 0.000913 },
"2026-09-17": { "LBXPTPM": 0.000912 },
"2026-09-18": { "LBXPTPM": 0.000912 },
"2026-09-19": { "LBXPTPM": 0.000912 },
"2026-09-20": { "LBXPTPM": 0.000912 }
},
"unit": "per troy ounce"
}

Field-by-field: what you’ll actually use

  • success: Boolean, verify before parsing.
  • timeseries: Confirms you hit the timeseries endpoint.
  • start_date, end_date: Echo your request; good for logging and QA.
  • base: The currency base, usually USD.
  • rates: Map of YYYY-MM-DD to object of { "LBXPTPM": rate }.
    • Each rate is “troy ounces per USD.” Invert to “USD per troy ounce.”
    • Expect nulls or missing keys on non-publication days; handle gracefully.
  • unit: “per troy ounce.” Confirms measurement basis.

Python example: fetch and compute daily closes (USD/oz)

import os
import json
import math
import urllib.parse
import urllib.request
from datetime import date

API_BASE = "https://metals-api.com/api/timeseries"
ACCESS_KEY = os.environ.get("METALS_API_KEY") # or hardcode for testing

def fetch_lbxptpm_closes(start_date: str, end_date: str) -> dict:
if not ACCESS_KEY:
raise RuntimeError("Set METALS_API_KEY in your environment.")

params = {
"access_key": ACCESS_KEY,
"start_date": start_date,
"end_date": end_date,
"symbols": "LBXPTPM",
"base": "USD"
}
url = f"{API_BASE}?{urllib.parse.urlencode(params)}"

with urllib.request.urlopen(url, timeout=20) as resp:
data = json.loads(resp.read().decode("utf-8"))

if not data.get("success"):
raise RuntimeError(f"API error: {data}")

unit = data.get("unit")
if unit != "per troy ounce":
raise ValueError(f"Unexpected unit: {unit}")

closes = {}
for day, obj in data.get("rates", {}).items():
rate = (obj or {}).get("LBXPTPM")
if rate is None or rate == 0:
# missing or zero: skip or backfill as per your policy
continue
closes[day] = 1.0 / rate # USD per troy ounce

# Optional: sort and return as ordered dict by date
return dict(sorted(closes.items()))

if __name__ == "__main__":
closes = fetch_lbxptpm_closes("2026-09-13", "2026-09-20")
for d, px in closes.items():
print(d, round(px, 2))

Notes:

  • We invert the rate to get USD/oz closes.
  • We skip missing/zero days. You can backfill using previous business day, but keep auditability requirements in mind.
  • Wrap this in your data-access layer and add retry logic as appropriate to your environment.

OHLC endpoint: verify the daily close for a specific date

Purpose: Load the open, high, low, and close for LBXPTPM on a specific date (UTC). Use this for point-in-time QA or to diagnose anomalies you discover in a time-series vector.

Request pattern

  • Endpoint: /open-high-low-close/YYYY-MM-DD
  • Parameters:
    • access_key
    • base (optional, defaults to USD)
    • Implicitly use symbol LBXPTPM via the rates object in the response

Curl example: OHLC for LBXPTPM on a given date

curl -G https://metals-api.com/api/open-high-low-close/2026-09-20 \
--data-urlencode "access_key=YOUR_API_KEY" \
--data-urlencode "base=USD"

Illustrative JSON response

{
"success": true,
"timestamp": 1789863263,
"base": "USD",
"date": "2026-09-20",
"rates": {
"LBXPTPM": {
"open": 0.000915,
"high": 0.000918,
"low": 0.000910,
"close": 0.000912
}
},
"unit": "per troy ounce"
}

How to interpret OHLC

  • open/high/low/close are in “troy ounces per USD.” Invert each to convert to USD per troy ounce.
  • date and timestamp are UTC. Align your analytics pipeline accordingly.
  • If you use time-series for closes, you can spot-check a handful of dates with OHLC to validate your pipeline logic.

Historical rates endpoint: backfill or verify a single date

Purpose: Retrieve the LBXPTPM rate for a single day—useful for backfilling one missing date or reconciling a specific accounting period.

Request pattern

  • Endpoint: /{YYYY-MM-DD}
  • Parameters:
    • access_key
    • symbols=LBXPTPM
    • base=USD (default)

Curl example: single-day LBXPTPM historical rate

curl -G https://metals-api.com/api/2026-09-19 \
--data-urlencode "access_key=YOUR_API_KEY" \
--data-urlencode "symbols=LBXPTPM" \
--data-urlencode "base=USD"

Illustrative JSON response

{
"success": true,
"timestamp": 1789776863,
"base": "USD",
"date": "2026-09-19",
"rates": {
"LBXPTPM": 0.000912
},
"unit": "per troy ounce"
}

Usage

  • Invert the number to get USD per troy ounce close for the date.
  • Compare against your time-series vector on the same date if you suspect a data discrepancy.

Practical integration guidance developers often miss

Units: troy ounces vs grams

  • Metals-API reports metals in troy ounces. One troy ounce ≈ 31.1034768 grams.
  • When downstream systems use grams or kilograms, convert after you get the USD/oz price:
    • USD/g = (USD/oz) / 31.1034768
    • USD/kg = (USD/oz) × (1000 / 31.1034768)

Base currency and inversion

  • Default base is USD; rate is “troy ounces per USD.” Invert for “USD per troy ounce.”
  • If you set base=EUR, then rates are “troy ounces per EUR.” Invert to get “EUR per troy ounce.”
  • Be consistent: standardize pricing to USD/oz (or your accounting base) early in your pipeline.

Timestamps and timezone

  • timestamp is Unix epoch seconds (UTC). date is YYYY-MM-DD (UTC).
  • Ensure time normalization if you store prices in a warehouse or join with regional market data.

Weekends, holidays, and LBMA publication cadence

  • LBMA fixes aren’t published on weekends and certain holidays.
  • Time-series responses may omit non-publication days or return the same last-available rate.
  • Decide on a backfill policy:
    • Forward-fill or last-business-day carry for charts.
    • Strict business-day index for quant backtests.
    • No-fill for audit trails in ERP/finance.

Caching and cost control

  • Cache immutable historical responses (e.g., a nightly job persists results by date range).
  • De-duplicate identical requests across services using a shared cache key that includes all query params.
  • Batch ranges with time-series instead of looping single-day calls.

Resilience and data validation

  • Check success and handle errors with exponential backoff for transient issues.
  • Validate that unit is “per troy ounce.” Alert if it differs.
  • Sanity-check rates and inverted prices against thresholds to catch erroneous zeros or outliers.

Security and key management

  • Store your API key in a secret manager or environment variable, not in source control.
  • Propagate the key via your deployment platform’s secret injection (e.g., container environment variables).
  • Rotate keys on a schedule and monitor usage. Least-privilege principles apply even to data APIs.

Performance and scaling tips

  • Prefer time-series for contiguous historical windows; it minimizes round-trips.
  • Parallelize across non-overlapping symbols or date segments only if needed; stay within your plan’s limits.
  • Persist daily snapshots to your data lake or warehouse to avoid re-fetching the same ranges.
  • Compress and partition by date for efficient downstream analytics.

Quality checks: reconciling closes from different endpoints

  • Use time-series for your canonical daily close.
  • Randomly sample dates and verify with OHLC close. Differences should be rare; investigate timezone assumptions if they appear.
  • For specific audit events, call the historical single-day endpoint and reconcile all three views.

LBXPTPM in sustainable and smart-technology workflows

Developers powering clean energy solutions (e.g., hydrogen PEM systems) can wire LBXPTPM into:

  • Automated hedge triggers when LBMA PM fix crosses thresholds tied to bill-of-materials exposure.
  • Embedded procurement dashboards that forecast platinum demand vs. price bands headroom.
  • Smart alerts for ESG-aligned portfolios integrating platinum intensity with green-tech KPIs.

Metals-API’s reliable daily cadence enables reproducible research, robust product pricing, and transparent reporting. For a broader look at available symbols and endpoints, explore the Metals-API Supported Symbols and the full Metals-API Documentation.

Error handling and troubleshooting

  • Invalid key or plan limits: The response will include success=false and an error object; log and surface a clear operator message.
  • Missing days: Implement a policy—skip, backfill, or annotate. Always keep an audit log.
  • Network timeouts: Add retries with jitter; cap attempts and alert if persistent.
  • Data drift: If close values jump beyond expected volatility bands, alert and verify against a secondary data source.

End-to-end workflow blueprint

  1. Get your API key at the Metals-API Website.
  2. Nightly job calls time-series for LBXPTPM from last-ingested date to today, base USD.
  3. Invert to USD per troy ounce and persist to your warehouse with UTC date.
  4. For 1–2 random dates per week, call OHLC for verification; alert on discrepancies.
  5. Expose the vector to your charting layer, risk engine, and ERP integration.
  6. Cache historical results and maintain idempotent ingestion with checksums.

Validation checklist before going to production

  • Symbol verified: LBXPTPM present on the supported symbols list.
  • Base confirmed: base=USD or your preferred accounting currency.
  • Unit confirmed: unit = "per troy ounce".
  • Inversion applied correctly for “USD per troy ounce.”
  • Weekend/holiday policy implemented.
  • Retries, caching, and observability in place.

Additional references

Conclusion: from LBXPTPM to production-grade close vectors

Fetching LBMA Platinum PM (LBXPTPM) historical closes per troy ounce is straightforward with Metals-API. Use the time-series endpoint to build your canonical daily vector, validate with the OHLC endpoint for selected dates, and rely on the single-day historical endpoint for precise backfills. Normalize units, invert to price per ounce, implement caching and business-day policies, and you’ll have a robust foundation for green-tech analytics, manufacturing ERP valuation, and fintech product features. Ready to implement? Review the Metals-API Documentation and grab a key from the Metals-API Website to get started today.

FAQ

  • Q: What unit does LBXPTPM use?
    A: Metals-API returns “troy ounces per USD” by default. Invert to get USD per troy ounce.
  • Q: How do I get a daily close vector for a month?
    A: Use the time-series endpoint with start_date, end_date, and symbols=LBXPTPM. Invert each daily rate.
  • Q: How do I verify a specific day’s close?
    A: Call the OHLC endpoint for that date and confirm the close field (invert to USD/oz).
  • Q: What about weekends and holidays?
    A: LBMA doesn’t publish on those days. Decide on a backfill or skip policy and document it.
  • Q: Can I change the base currency?
    A: Yes. Set base (e.g., EUR). You’ll get “troy ounces per EUR,” then invert for EUR per troy ounce.
  • Q: Where can I confirm the symbol?
    A: Check Metals-API Supported Symbols.