Quick guide: Get Platinum Jan 2027 (PLF27) - Per Troy Ounce Historical Prices using this API

Metals-API 13 min read
Quick guide: Get Platinum Jan 2027 (PLF27) - Per Troy Ounce Historical Prices using this API

If you need Platinum Jan 2027 (PLF27) per troy ounce historical prices for backtesting a strategy, valuing hedges, or reconciling P&L, the fastest path is to use spot platinum (XPT) historical data as your clean reference series. This quick guide shows how to fetch reliable per-troy-ounce platinum history from Metals-API and map it to a PLF27 workflow: from building a daily time series, to extracting OHLC for event days, to handling weekends, units, and caching so your jobs are fast and cost effective. We’ll keep everything developer-friendly—just the essential endpoints, complete examples, and the gotchas you actually hit in production.

What PLF27 users actually need from a platinum historical feed

PLF27 refers to a January 2027 platinum futures contract. While Metals-API focuses on standardized spot metal symbols like XPT (platinum), the workflow most desks and quant teams follow is to use spot platinum per troy ounce as the consistent, time-continuous series for:

  • Backtesting directional or spread strategies anchored to PLF27
  • Estimating fair value and residuals vs. futures (carry and basis modeling)
  • Risk reporting and sanity checks when exchange feeds are delayed or incomplete
  • Index construction and normalized analytics (e.g., daily returns, volatility)

In other words: you’ll fetch platinum spot (XPT) “per troy ounce” historical prices from Metals-API, and use them as your PLF27 proxy or benchmark. This guide demonstrates how to request that data correctly and reliably.

Endpoint focus: the three calls to build a complete PLF27 proxy stack

We’ll use exactly three endpoints that cover the bulk of production needs for PLF27-aligned workflows:

  • Historical Rates (for single-day backfill or replay)
  • Time-series (for range backfill between two dates)
  • OHLC (for event-day open/high/low/close context)

For all calls below:

  • Symbol: XPT (Platinum)
  • Unit: per troy ounce (ensure you don’t treat rates as grams or kilograms)
  • Base: USD by default in the response

Get the full API reference at the Metals-API Documentation and confirm symbol availability on the Metals-API Supported Symbols page. If you don’t yet have credentials, start with a free key at the Metals-API Website.

Before you code: mapping spot XPT to PLF27 and key assumptions

Because PLF27 is a futures contract and Metals-API provides spot platinum under XPT, here’s how practitioners connect the dots:

  • Use XPT per troy ounce as a stable historical benchmark for price levels and returns.
  • Apply your PLF27-specific basis model (carry, storage, financing) to translate spot to futures if needed. The spot series is the input to your model—Metals-API does not compute futures bases for you.
  • Store timestamps and timezones consistently. Metals-API returns a UNIX-like epoch timestamp and ISO date. Align this to your strategy’s timezone (e.g., UTC for analytics; exchange local time for execution events).
  • Use OHLC bars around major events (roll windows, macro releases) to compare with PLF27 intraday moves when you have your own exchange-time intraday snapshots.

Authentication and request structure

All requests require your access_key parameter. Example base:

https://metals-api.com/api/<endpoint>?access_key=YOUR_API_KEY&symbols=XPT

Keep your key out of repositories and CI logs. For server-side jobs, inject via environment variables. Rotate keys if they leak. For production web apps, proxy requests through your backend to avoid exposing the key in browser JavaScript.

Endpoint 1: Historical Rates (single day replay)

Purpose

Get platinum per troy ounce (XPT) for one historical date. Useful for daily revaluation or point-in-time backfills (e.g., PLF27 risk report on a specific historical cutoff).

Parameters

  • date (path): YYYY-MM-DD
  • access_key (query): your API key
  • symbols (query): XPT
  • Optional: base (query) if you need a different base currency; default is USD

Example curl

curl "https://metals-api.com/api/2026-09-24?access_key=YOUR_API_KEY&symbols=XPT"

Example JSON response

{
"success": true,
"timestamp": 1790208986,
"base": "USD",
"date": "2026-09-24",
"rates": {
"XPT": 0.000915
},
"unit": "per troy ounce"
}

How to read this

  • unit: "per troy ounce" means the numeric rate expresses how many troy ounces of XPT one USD buys. Invert to get USD per ounce: price_oz_usd = 1 / 0.000915 ≈ 1092.90 USD/oz (example math only; always compute in code).
  • base: "USD" indicates the base currency for the rates. If you change base, adjust your calculations accordingly.
  • timestamp/date: Use timestamp for programmatic ordering; date is ISO for readability and keying daily bars.

Common pitfalls

  • Forgetting to invert to USD/oz. Metals-API returns metals in units “per USD” by default when base is USD. If you store prices as USD per ounce, always invert.
  • Weekend dates: Markets may be closed; expect carry-over from last trading day. Don’t assume a missing rate is an error—check the success flag and handle closures.
  • Time cutoff mismatches: If your PLF27 analytics assume exchange close, define a consistent daily snapshot rule using the timestamp returned.

Endpoint 2: Time-series (range backfill)

Purpose

Backfill a continuous daily series for platinum (XPT) between start_date and end_date—your backbone to model PLF27 basis and evaluate strategies over historical windows.

Parameters

  • start_date (query): YYYY-MM-DD
  • end_date (query): YYYY-MM-DD
  • access_key (query): your API key
  • symbols (query): XPT

Example curl

curl "https://metals-api.com/api/timeseries?access_key=YOUR_API_KEY&start_date=2026-09-18&end_date=2026-09-25&symbols=XPT"

Example JSON response

{
"success": true,
"timeseries": true,
"start_date": "2026-09-18",
"end_date": "2026-09-25",
"base": "USD",
"rates": {
"2026-09-18": {
"XPT": 0.000915
},
"2026-09-20": {
"XPT": 0.000913
},
"2026-09-25": {
"XPT": 0.000912
}
},
"unit": "per troy ounce"
}

How to use it for PLF27 workflows

  • Resample to business days if your model ignores weekends. Some responses may include nonstandard days with carried values.
  • Compute daily USD/oz price as 1 / rate and then returns (log or arithmetic). This normalizes your PLF27 basis model against spot moves.
  • Cache the entire JSON payload by date range to avoid refetching unchanged history. See caching guidance below.

Edge handling

  • Gaps and closures: If a date key is absent, don’t interpolate silently. Carry-forward only when consistent with your risk policy.
  • Timezone alignment: The date keys are calendar dates. Use the numeric timestamp for precise EOD anchoring if needed.

Endpoint 3: OHLC (event-day open/high/low/close)

Purpose

Extract open, high, low, and close platinum (XPT) for a single date to contextualize event-day moves or calibrate PLF27 slippage assumptions.

Parameters

  • date (path): YYYY-MM-DD
  • access_key (query): your API key
  • symbols (query): XPT

Example curl

curl "https://metals-api.com/api/open-high-low-close/2026-09-25?access_key=YOUR_API_KEY&symbols=XPT"

Example JSON response

{
"success": true,
"timestamp": 1790295386,
"base": "USD",
"date": "2026-09-25",
"rates": {
"XPT": {
"open": 0.000915,
"high": 0.000918,
"low": 0.00091,
"close": 0.000912
}
},
"unit": "per troy ounce"
}

Using OHLC with PLF27

  • Convert each field to USD/oz by inversion to compare with your PLF27 intraday data or settlement prices.
  • Define slippage envelopes using spot high/low; compare actual PLF27 fills vs. spot volatility bands.
  • Store the entire OHLC tuple; don’t reduce to close-only if you intend to validate execution or model tail risk.

Complete example: pull a backtest-ready platinum series in Python

The following minimal script fetches a time range for XPT, converts to USD per troy ounce, and computes daily returns. You can embed this in a backtesting pipeline for PLF27 basis or spread strategies.

# Minimal Python example (server-side)
import os
import requests
import math

API_KEY = os.getenv("METALS_API_KEY")
BASE_URL = "https://metals-api.com/api"

def fetch_timeseries(start_date, end_date):
url = f"{BASE_URL}/timeseries"
params = {
"access_key": API_KEY,
"start_date": start_date,
"end_date": end_date,
"symbols": "XPT"
}
r = requests.get(url, params=params, timeout=15)
r.raise_for_status()
data = r.json()
if not data.get("success", False):
raise RuntimeError(f"API error: {data}")
return data

def to_usd_per_oz(rate_per_usd):
# Metals-API returns "per troy ounce" with base USD, i.e., ounces per USD.
# Convert to USD per troy ounce by inversion.
return 1.0 / rate_per_usd if rate_per_usd else float("nan")

def daily_returns(prices):
# prices: dict of date -> USD per oz
dates = sorted(prices.keys())
rets = {}
for i in range(1, len(dates)):
d0, d1 = dates[i-1], dates[i]
p0, p1 = prices[d0], prices[d1]
if p0 > 0 and p1 > 0:
rets[d1] = math.log(p1 / p0)
return rets

if __name__ == "__main__":
data = fetch_timeseries("2026-09-18", "2026-09-25")
raw = data["rates"] # mapping date -> { "XPT": rate }
usd_per_oz = {d: to_usd_per_oz(v["XPT"]) for d, v in raw.items() if "XPT" in v}
rets = daily_returns(usd_per_oz)
# Persist usd_per_oz and rets to your store for PLF27 basis modeling, factor research, etc.
print("USD/oz:", usd_per_oz)
print("Daily log returns:", rets)

Validating the response

  • Check data["unit"] is "per troy ounce" before inverting.
  • Assert base == "USD" or branch logic if you request a non-USD base.
  • Guard for missing dates; don’t interpolate unless documented by your model governance.

Field-by-field: what matters in the JSON

  • success (bool): Quick health check. If false, inspect the payload for error info and retry logic.
  • timestamp (int): Use to anchor records unambiguously and for idempotent processing of daily snapshots.
  • date (YYYY-MM-DD): Human-readable and a convenient key for day buckets.
  • base (string): Defaults to USD; your inversion math assumes USD unless you override.
  • rates (object): For XPT requests, either a scalar (historical/latest) or structured fields (OHLC). Always feature-detect the shape.
  • unit (string): Confirm it reads "per troy ounce" when you target per-ounce analytics (PLF27 per oz alignment).

Units and conversions: avoid silent errors

  • Per troy ounce vs gram: Metals-API returns “per troy ounce.” If you need grams, convert with 1 troy ounce = 31.1034768 grams. Keep conversions in a single utility module to avoid drift.
  • USD per ounce vs ounces per USD: With base=USD, the returned number is ounces per USD. Invert to get USD per ounce for PLF27-aligned price axes.
  • Currency base changes: If you set base=EUR (example), output becomes per EUR; adapt calculations or convert to USD consistently for PLF27 comparison.

Caching strategies that save time and quota

  • Immutable history: Cache historical and time-series responses aggressively by date or date range. Use ETag-style fingerprints (e.g., hash of JSON) in your store if you want to detect changes.
  • Daily rollups: Store normalized USD/oz results as parquet or columnar formats for fast backtesting, not just the raw JSON.
  • Weekend carry: If you implement forward-fill for weekends, cache the derived series so you don’t recompute each run.
  • Retry budget: Backoff and jitter across retries to avoid thundering herds at midnight processing windows.

Handling weekends, holidays, and closures

  • Expect fewer or repeated values over non-trading days. Validate your return calculations skip non-movement rows if needed.
  • Define a canonical “as-of” rule for daily bars (e.g., last available timestamp on each calendar date) and stick to it across pipelines.
  • When reconciling with PLF27 settlements, be explicit about whether you compare spot close with futures settlement or session close; they may not align.

Security and key management

  • Secrets handling: Store your access_key in a secret manager or environment variable. Never hard-code in client-side code.
  • Network hygiene: Use TLS (HTTPS) endpoints only. Validate certificates by using standard HTTP client libraries.
  • Least privilege: If you automate across multiple environments, issue environment-specific keys and rotate periodically.

Error handling and recovery patterns

  • Transport errors: Implement retries with exponential backoff on network timeouts or 5xx responses.
  • API-level errors: Check "success": false. Log the payload for diagnostics and branch to a safe fallback (e.g., cached prior value).
  • Data validation: Assert the presence of "unit", "base", and symbol keys before computations. Fail fast if shapes differ from expectations.

Performance tips for large backfills

  • Chunk windows: For multi-year PLF27-prep backfills, split time-series requests into monthly or quarterly windows to control response sizes.
  • Parallelism: Parallelize independent windows, but cap concurrency to avoid overwhelming your network or hitting soft limits.
  • Serialization: Store normalized columns (date, xpt_usd_per_oz, returns) directly in your analytics store to skip repeated parsing.

Advanced: building a PLF27 basis model with XPT

Once you have a clean XPT per troy ounce history, you can derive a futures-consistent curve:

  • Basis inputs: financing costs, storage/insurance assumptions, and calendar days until Jan 2027 expiry.
  • Fair value: F = S * exp((r + s - y) * T), where S is spot (USD/oz), r is financing, s is storage, y is convenience yield, T is time to maturity (in years). Calibrate s and y from historical relationships or use market-implieds if available.
  • Backtesting: Evaluate residuals (PLF27 – model fair value) and their dynamics around roll windows.

Metals-API delivers the S (spot) leg and consistent historical context; you control the futures-specific economics in your code.

Verification: comparing OHLC to your futures session

When diagnosing discrepancies between spot and futures:

  • Use OHLC to identify whether a futures move was a gap or intraday swing.
  • If PLF27 settled near the spot low, expect residual widening if liquidity was thin; check spot high/low to size the move envelope.
  • Record both spot close and futures settlement times to remove time-window mismatches from the analysis.

Practical metadata: symbols and documentation

Confirm symbol availability and metadata on the Metals-API Supported Symbols page (look for XPT). For endpoint specifics, see the Metals-API Documentation. To get started right away, request your credentials at the Metals-API Website and begin integrating within minutes.

Realistic JSON snapshots to test your pipeline

Historical (single day) example

{
"success": true,
"timestamp": 1790208986,
"base": "USD",
"date": "2026-09-24",
"rates": {
"XPT": 0.000915
},
"unit": "per troy ounce"
}

Time-series (multi-day) example

{
"success": true,
"timeseries": true,
"start_date": "2026-09-18",
"end_date": "2026-09-25",
"base": "USD",
"rates": {
"2026-09-18": { "XPT": 0.000915 },
"2026-09-20": { "XPT": 0.000913 },
"2026-09-25": { "XPT": 0.000912 }
},
"unit": "per troy ounce"
}

OHLC (event day) example

{
"success": true,
"timestamp": 1790295386,
"base": "USD",
"date": "2026-09-25",
"rates": {
"XPT": {
"open": 0.000915,
"high": 0.000918,
"low": 0.00091,
"close": 0.000912
}
},
"unit": "per troy ounce"
}

curl quick-starts you can paste into CI

  • Historical single date:
curl "https://metals-api.com/api/2026-09-24?access_key=YOUR_API_KEY&symbols=XPT"
  • Time-series range:
curl "https://metals-api.com/api/timeseries?access_key=YOUR_API_KEY&start_date=2026-09-01&end_date=2026-09-30&symbols=XPT"
  • OHLC for an event day:
curl "https://metals-api.com/api/open-high-low-close/2026-09-25?access_key=YOUR_API_KEY&symbols=XPT"

Sustainable innovation and why platinum data matters

Platinum (XPT) sits at the center of several green technology and clean energy applications: from catalytic converters to emerging hydrogen economy components. If you’re building smart pricing engines or decision tools for sustainable manufacturing, reliable platinum history is mission-critical. Metals-API’s standardized per-troy-ounce format helps you integrate platinum signals into digital transformation initiatives—ERP pricing, automated hedging, or predictive demand planning—without wrestling with fragmented data sources.

Architectural considerations for PLF27-aligned platforms

  • Data lake layering: Land raw JSON, curate normalized USD/oz parquet tables, and publish analytics-friendly marts with returns and volatility for PLF27 strategy modules.
  • Idempotent loaders: Use the "date" and "timestamp" from responses as natural keys to ensure reruns don’t duplicate rows.
  • Observability: Log success flags, HTTP status, and payload digests. Alert on schema shifts (e.g., missing unit field) before analytics break.
  • Versioning: Tag datasets with the Metals-API response date/time to audit backtests vs. live runs.

Security, compliance, and production hygiene

  • Key rotation: Rotate access keys on a schedule; invalidate old ones promptly.
  • Principle of least privilege: If you proxy Metals-API through your backend, limit exposed endpoints and validate input parameters server-side.
  • Data governance: Document inversion logic (USD/oz) and unit conversions; treat them as part of your model spec for auditability.

Where to go next

For complementary market context, many teams also consult official exchange notices and reputable market commentary providers to cross-check key event days and settlement calendars.

Conclusion

For Platinum Jan 2027 (PLF27) workflows, you rarely need a bespoke futures feed to build robust historical models. By using Metals-API’s platinum spot (XPT) per troy ounce history, you can backfill returns, compute USD/oz levels consistently, and derive futures-aligned fair values with your own basis model. The three endpoints—Historical, Time-series, and OHLC—cover the lion’s share of real-world needs. Mind the unit inversion, cache your results, and set clear weekend/holiday rules. With those in place, you’ll have a dependable, auditable foundation for PLF27 research, pricing, and risk analytics.

FAQ

  • Does Metals-API return futures data for PLF27 directly?
    Metals-API standardizes spot symbols like XPT (platinum). For PLF27-specific analytics, use XPT per troy ounce as your historical series and apply your basis model.
  • What units does the API return for platinum?
    Per troy ounce. With base=USD, the numeric output is ounces per USD; invert to get USD per ounce.
  • How do I handle weekends and holidays?
    Expect carried or unchanged values. Define a consistent “as-of” rule and avoid accidental interpolation unless specified by your methodology.
  • Can I change the base currency?
    Yes. Specify base in the query if needed, then adapt your inversion math. By default, it’s USD.
  • Where do I find the platinum symbol?
    Check XPT on the Metals-API Supported Symbols page.
  • How do I get started?
    Visit the Metals-API Website to create a free key and read the Metals-API Documentation for endpoint details.