Historical Unidad de Fomento (CLF) - N/A Prices: Daily Time Series for API Integration

Metals-API 9 min read
Historical Unidad de Fomento (CLF) - N/A Prices: Daily Time Series for API Integration

You need to integrate daily Unidad de Fomento (CLF) rates into a pricing, P&L, or research workflow and backfill a chart or model from a reliable API. By the end of this guide, you’ll be able to pull CLF quotes (including the USD/CLF inverse), understand how to interpret the rates, and structure a daily time-series pipeline using Metals-API’s endpoints, with code you can copy into your app.

What you’re building: daily CLF rates that developers can ship

CLF is Chile’s inflation-indexed unit of account used in mortgages, long-dated contracts, and finance. If you’re quoting products in CLF or converting historical CLF liabilities to USD, you’ll want:

Illustration: Historical Unidad de Fomento (CLF) - N/A Prices: Daily Time Series for API Integration
  • A reliable latest CLF rate for dashboards and conversions.
  • Daily time series for backtesting, charting, and risk (e.g., CLF carry over time).
  • Clear handling of base currency and an explicit USD/CLF inverse (so you don’t have to invert floats yourself).

This post shows how to do that with Metals-API’s latest and time-series endpoints focused on CLF. If you’re new to the API, the reference is here: Metals-API Documentation. You can also confirm the code for CLF and related symbols at Metals-API Supported Symbols.

Symbols you’ll use for CLF

Metals-API returns exchange rates relative to a base currency (default USD). For CLF work, you’ll commonly use the following:

Symbol Meaning How to read when base=USD Typical usage
CLF Unidad de Fomento CLF per 1 USD (i.e., how many CLF you get for 1 USD) Convert USD amounts into CLF
USD US Dollar Always 1.0 when base=USD Anchor for conversions
USDCLF Inverse cross USD per 1 CLF (the inverse of CLF when base=USD) Convert CLF amounts into USD without manual inversion

Get the latest CLF and USD/CLF in one request

The quickest way to start is with the latest endpoint, scoped to the symbols you need. This example requests CLF plus the pre-computed inverse USDCLF to avoid floating-point inversions in your app:

curl "https://metals-api.com/api/latest?access_key=YOUR_API_KEY&base=USD&symbols=CLF,USD,USDCLF"

Here is a real response sample you can use to validate your parsing and math:

{"success":true,"timestamp":1792282140,"date":"2026-10-18","base":"USD","rates":{"CLF":0.024881,"USD":1,"USDCLF":40.191310638639926}}

How to read this JSON

  • success: Boolean flag the request was processed.
  • timestamp: Unix epoch seconds. Treat it as UTC for storage, caching, and charting.
  • date: The effective valuation date associated with these rates.
  • base: The quote base used for all rates. With base=USD, rates are quoted per 1 USD.
  • rates.CLF: CLF per 1 USD. Multiply USD amounts by this to get CLF.
  • rates.USDCLF: USD per 1 CLF. Multiply CLF amounts by this to get USD.

Example conversions using the payload above:

  • 1000 USD → CLF: 1000 × 0.024881 = 24.881 CLF
  • 10 CLF → USD: 10 × 40.191310638639926 = 401.91310638639926 USD

Production-ready code: fetch and convert CLF with JavaScript

The snippet below queries the latest CLF rates, validates the fields you’ll actually use, and provides helpers to convert between USD and CLF. You can drop this into a Node.js service, Cloudflare Worker, or a browser app (mind your API key exposure on the web).

async function getClfLatest() {
const url = "https://metals-api.com/api/latest?access_key=YOUR_API_KEY&base=USD&symbols=CLF,USD,USDCLF";
const res = await fetch(url, { method: "GET" });
if (!res.ok) throw new Error("HTTP " + res.status);
const json = await res.json();

if (!json.success) {
throw new Error("Metals-API error: " + JSON.stringify(json));
}
if (!json.rates || typeof json.rates.CLF !== "number" || typeof json.rates.USDCLF !== "number") {
throw new Error("Missing CLF or USDCLF in response");
}

const ts = json.timestamp; // Unix epoch seconds (UTC)
const asOf = json.date; // "YYYY-MM-DD"

// With base=USD:
// - CLF is CLF per 1 USD
// - USDCLF is USD per 1 CLF
const clfPerUsd = json.rates.CLF;
const usdPerClf = json.rates.USDCLF;

return {
asOf,
timestamp: ts,
clfPerUsd,
usdPerClf,
toClfFromUsd: (usd) => usd * clfPerUsd,
toUsdFromClf: (clf) => clf * usdPerClf
};
}

// Example usage
getClfLatest()
.then(({ asOf, clfPerUsd, usdPerClf, toClfFromUsd, toUsdFromClf }) => {
console.log("As of:", asOf);
console.log("CLF per USD:", clfPerUsd);
console.log("USD per CLF:", usdPerClf);
console.log("1,000 USD =", toClfFromUsd(1000), "CLF");
console.log("25 CLF =", toUsdFromClf(25), "USD");
})
.catch(err => {
console.error("Error fetching CLF:", err);
});

Daily time series for CLF: backfill charts and models

For backtesting, daily marks, or charting, query the time-series endpoint over your desired date window. You can request both CLF and USDCLF so downstream code doesn’t invert. A typical integration pulls a rolling window (e.g., 2 years) on first run, then appends each new day.

Pattern to request a time window:

  • Endpoint: time-series
  • Parameters: access_key, base=USD, start_date=YYYY-MM-DD, end_date=YYYY-MM-DD, symbols=CLF,USDCLF

Parse the response as a date-indexed object with daily rates. If the market is closed or the CLF fixing isn’t published for a given date (weekends/holidays), expect the next available business date. Your ETL should either forward-fill missing business days for chart continuity or leave gaps, depending on your analytics needs.

For endpoint parameters and response shape, review the reference examples under Time-series at Metals-API Documentation.

Interpretation details that save you time

Base currency and inverted crosses

Metals-API defaults to base=USD. With base=USD, rates.CLF is “CLF per 1 USD,” and rates.USDCLF is “USD per 1 CLF.” The pre-computed USDCLF field keeps you from inverting decimal values and dealing with precision across systems.

Timestamps and timezone

  • timestamp is Unix epoch seconds (UTC). Convert to your local time only for display; store in UTC.
  • date is the valuation date. Use this for business-day alignment in charts and P&L buckets.

Units: CLF is not a metal weight

Unlike metals quoted “per troy ounce,” CLF is a currency-like unit of account. Do not apply metal unit conversions (ounces, grams) to CLF. CLF amounts convert to/from USD using the numeric rates shown above—no weight units involved.

Handling weekends and holidays

  • CLF is an administratively published unit. On weekends/holidays, new values may not post.
  • For time series, consider forward-filling the last available value across non-business days if your charts expect a value per calendar day. For finance P&L, align strictly to business days.

Caching and request efficiency

  • Cache latest responses keyed by date and symbol set (e.g., “USD:CLF,USDCLF”). Reuse for all widgets shown on the same page load.
  • For intraday dashboards, check your plan’s update frequency and poll accordingly. Many use a “only refresh when date or timestamp changes” strategy.
  • For time series, fetch only the new day on subsequent runs rather than re-downloading the entire history.

Data integrity checks

  • Always verify success === true and presence of rates.CLF (and rates.USDCLF if requested).
  • Sanity-check reciprocal identity: approximately 1 / rates.CLF ≈ rates.USDCLF (tolerate small rounding differences).
  • Pin to the valuation date in the payload, not your local clock, when writing daily bars.

Practical workflows powered by CLF time series

1) Pricing a CLF-denominated product in USD

If your catalog or mortgage quote is in CLF but your checkout is in USD, pull rates.USDCLF and multiply the CLF notional to get the USD charge. This avoids hand-inversion errors and keeps parity with your reporting ledger in USD.

2) Backtesting CLF exposure

For a series of historical CLF liabilities, request a time series scoped to CLF and USDCLF. Store as OHLC-equivalent bars if needed (close-only is common for CLF). Revalue notional exposures over time using rates.USDCLF to see USD P&L from CLF moves.

3) Building a CLF chart with client-side downsampling

Fetch the full time window via time series, then downsample on the client (e.g., 1D close) for chart performance. Always label the axis with “USD/CLF” if you plot rates.USDCLF, or “CLF/USD” if you plot rates.CLF, to avoid orientation mistakes.

Endpoint selection and field mapping

For CLF work, you generally only need two endpoints:

  • Latest: for real-time dashboards and conversions (returns CLF and USDCLF as requested).
  • Time-series: for historical daily data between start_date and end_date.

If you later expand to daily performance stats, consider the fluctuation endpoint documented at Metals-API Documentation to compute changes over a date window server-side.

Validation, rounding, and formatting

  • Store raw float values as provided. Apply rounding only on output (e.g., 6–8 decimals for USDCLF, 6+ for CLF/USD).
  • When showing currency output, format using locale-aware methods but ensure internal math uses unrounded numbers.
  • If you compare against a central bank source, ensure you’re comparing the same valuation date and session.

Security and deployment notes

  • Keep YOUR_API_KEY server-side in production services. If you must call from the browser, consider a lightweight proxy that injects the key.
  • Use a retry/backoff strategy on transient network errors and cache the last good value to keep dashboards responsive.
  • Pin to TLS and validate JSON fields to avoid schema drift issues in downstream services.

Where to find symbols, docs, and plans

If you’re also integrating metals in the same stack (e.g., quoting CLF and copper together), you can use the same endpoints and add the metal symbols to your symbols list. For the full catalog of metals and currencies, visit metals-api.com.

Testing tips and data quality checks

  • Lock on a known response (like the sample above) in unit tests to validate parsing of base, date, timestamp, and both CLF and USDCLF fields.
  • Construct property-based tests for reciprocal math: abs((1 / CLF) - USDCLF) < epsilon.
  • Compare daily bars across internal caches and the API for consistency; alert on sudden missing days or zeroes.

Example ETL outline for daily CLF time series

  1. At 00:30 UTC (or after the CLF publish window you rely on), call time-series with start_date yesterday (or last stored date + 1) and end_date today.
  2. Validate success, then upsert both CLF and USDCLF into your time-series store with the date as the key.
  3. Forward-fill visualization layers if you chart calendar days; keep raw store business-day only.
  4. Serve latest from cache for 5–15 minutes depending on your plan’s update frequency.

Additional references for CLF users

  • Banco Central de Chile overview of UF (in Spanish): bcentral.cl
  • Metals-API homepage for broader capabilities and status: Metals-API

FAQ

Q1: How do I invert CLF/USD without floating-point drift?
A: Request both CLF and USDCLF in the same call. With base=USD, CLF is “CLF per 1 USD,” and USDCLF is “USD per 1 CLF.” Use USDCLF directly for CLF→USD conversions.

Q2: What timezone is the timestamp?
A: timestamp is Unix epoch seconds in UTC. The date field is the valuation date; use it when writing the daily bar.

Q3: How should I handle weekends and Chilean holidays?
A: Expect no new CLF value on non-business days. Forward-fill for charts if needed, but keep your raw store aligned to the valuation dates returned by the API.

Q4: Can I fetch a multi-year CLF history in one go?
A: Use the time-series endpoint with your target start_date and end_date. For large ranges, prefer an initial backfill followed by daily increments rather than re-downloading the entire range.

Q5: What’s the difference between CLF and currencies like USD in this API?
A: CLF behaves like a currency unit of account here. With base=USD, rates are numeric exchange rates; there are no weight-based units (troy ounces) involved for CLF.

Ready to ship CLF into your stack? Create your API key and start integrating the latest and time-series endpoints today: Register. To review or adjust your current plan, visit MCP.