2.2 KiB
Weekly Gold Gate
Use this package to calculate and monitor the weekly DFII20 gold rule.
The rule compares consecutive available 20-year TIPS real yields. A weekly increase of at most 10 basis points selects long gold.
Performance summary
The table reports only GLD and gold-strategy returns. The long-only rule holds T-bill cash during risk-off weeks.
| Return stream | Window | CAGR | Sharpe | Sortino | Maximum drawdown | Hit rate |
|---|---|---|---|---|---|---|
| Weekly real-20Y gate, long-only | 2006-11-17 through 2026-06-12 | 12.14% | 0.700 | 0.962 | -30.46% | 63.41% |
| Weekly real-20Y gate, long/short | 2006-11-17 through 2026-06-12 | 13.66% | 0.729 | 1.120 | -28.06% | 56.85% |
| GLD buy and hold | 2006-11-17 through 2026-06-12 | 9.75% | 0.522 | 0.756 | -44.74% | 55.28% |
Sharpe and Sortino use excess returns over weekly T-bill cash. Hit rate uses weekly strategy returns.
The comparison does not include commissions or live execution effects. It is historical research result.
Requirements
- Python 3.10 or later
- An EODHD API key for GLD refreshes
- Network access to the FRED
DFII20CSV source
Create a virtual environment. Then install the package dependencies:
python -m venv .venv
.venv\Scripts\python.exe -m pip install -r requirements.txt
Place the EODHD key in eodhd_api.key at the package root. Do not commit or share this file.
Use the gate
The function accepts a daily real-yield series and GLD trading dates:
import pandas as pd
from src.gates.gold_real_yield import compute_weekly_real_yield_gate
state = compute_weekly_real_yield_gate(
real_yield=real_yield_series,
trading_dates=gld_trading_dates,
as_of=pd.Timestamp("2026-06-12"),
)
The returned dictionary contains the yield change, threshold, and long-only and long/short states.
Run the monitor
Refresh GLD and DFII20. Then print the latest weekly state:
.venv\Scripts\python.exe scripts\live\gold_gate_monitor.py
Use existing cache files for an offline check:
.venv\Scripts\python.exe scripts\live\gold_gate_monitor.py --no-refresh
The script reports the long-only and long/short states.