Building the Gold–Silver Ratio from Historical Data
The gold–silver ratio — how many ounces of silver one ounce of gold buys — is one of the oldest relative-value measures in finance, and one of the few you can rebuild exactly, from first principles, on your own machine: divide two price series. This guide does precisely that with XAU/USD and XAG/USD, including the two places the naive division goes wrong.
Get the app — €9 →
Why the ratio, and why these two series
Dividing the two dollar quotes cancels the dollar: (XAU/USD) ÷ (XAG/USD) = XAU/XAG, ounces of silver per ounce of gold, with no currency leg left in it. That algebra is what makes the ratio a cleaner relative-value object than either metal alone — a dollar move that lifts both quotes leaves the ratio untouched. Both series here are spot quotes on the same venue with the same session calendar, which is exactly what you want: the division only means something when the two prices are from the same instant.
The data you need
Daily candles are the standard resolution for ratio work: XAU/USD daily reaches back to 1999-06-03 and XAG/USD to 1999-06-03, so the joined daily ratio series runs from the later of the two starts to the last completed session. Download each from the app as CSV (or Parquet on the Pro tier) over the same date range, and the rows align on their UTC timestamps.
One query in DuckDB
SELECT g.timestamp,
g.close / s.close AS gold_silver_ratio
FROM 'xauusd_d1.parquet' g
JOIN 'xagusd_d1.parquet' s USING (timestamp)
ORDER BY timestamp;
The JOIN … USING (timestamp) is doing quiet work: it keeps only instants both series have. With two same-venue metals that is nearly every row — but it is the honest way to align any two series, and it is what protects you when you later try the same recipe on pairs that trade different hours (more SQL recipes).
Or three lines of pandas
import pandas as pd
g = pd.read_csv('xauusd_d1.csv', parse_dates=['timestamp'], index_col='timestamp')
s = pd.read_csv('xagusd_d1.csv', parse_dates=['timestamp'], index_col='timestamp')
ratio = (g['close'] / s['close']).dropna()
The dropna() is the pandas spelling of the same alignment rule — an index-aligned division puts NaN wherever one side is missing. Loading details in the pandas guide.
The two places the naive division goes wrong
- Mismatched daily cut-offs. Build both sides from the same source with the same day boundary — this archive's UTC days do that by construction. Dividing a UTC gold close by another platform's differently-cut silver close manufactures ratio noise that never traded.
- Mixing quote sides. Use close-by-close on the same side for both series (bid/bid or ask/ask, or mid/mid). A bid on one leg against an ask on the other biases every reading by the two spreads.
Where to take it
With the ratio as a series, the standard toolkit applies: rolling percentiles for stretch, regime studies across the 1999-06-03-onward span, or a backtest of a mean-reversion rule — remembering that a ratio trade is two legs with two spreads. For intraday ratio work the same recipes run on 1-hour or 1-minute candles; both metals carry them from the same era (see each instrument page's coverage table). The full set of pairs either leg can be quoted in is in the precious-metals catalogue.
Frequently asked questions
- How is the gold–silver ratio calculated?
- Divide the gold price by the silver price in the same currency at the same instant: XAU/USD ÷ XAG/USD = ounces of silver per ounce of gold. The dollar cancels out of the division, which is why the ratio is a pure relative-value measure between the metals.
- How far back can I compute the ratio from this data?
- From the later of the two daily starts: XAU/USD daily begins 1999-06-03 and XAG/USD 1999-06-03 in this archive, so the joined daily ratio series covers the overlap of the two, up to the last completed session.
- Why do my ratio values differ slightly from a published ratio chart?
- Different sources, sides and cut-offs. A ratio built from UTC closes on one venue will differ at the margin from one built from another feed’s differently-timed closes — both are internally consistent. For research, what matters is building both legs the same way, which is the point of computing it yourself.
- Do I need to download anything special for ratio analysis?
- No — two ordinary downloads (XAU/USD and XAG/USD, same timeframe, same range) and a division. Every licence tier reaches both series over their full history; the Pro tier’s Parquet export makes the DuckDB path faster on long ranges.
Related markets
- Forex Metals historical data · 18 instruments
Related guides
- Download Gold (XAU/USD) Price History
- Gold Tick Data (XAU/USD): What You Get, and How Big It Is
- Backtesting a Gold Strategy on Historical Data
- How to Use MarketData Hub — The Complete Guide
- Historical Market Data CSV & JSON Format Explained
- Backtesting a Trading Strategy with Historical Data
- Download EUR/USD Price History
- How Far Back Does Historical Market Data Go?