forecast-sector-relative-return-from-yield-spread

forecast-sector-relative-return-from-yield-spread is a skill for Claude Code, Codex from fatfingererr/macro-skills. It costs 75 tokens per session (4,057 once invoked), scanned A, original, MIT.

A market-analysis tool that studies the gap between short- and long-term U.S. Treasury yields and compares it with the relative performance of Nasdaq 100 and healthcare stocks. It tests whether the yield gap consistently leads later performance differences.

In plain words
What is it for?
Scanning lead times, testing correlations and regressions, comparing different historical periods, estimating relative-return direction, and expressing results as plain-language probabilities and ranges.
Why use it?
It helps check whether a commonly used economic signal has a stable relationship with which type of stocks performs better. The analysis uses future returns rather than misleading price levels.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Scanning lead times, testing correlations and regressions, comparing different historical periods, estimating relative-return direction, and expressing results as plain-language probabilities and ranges.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/fatfingererr/macro-skills/forecast-sector-relative-return-from-yield-spread
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add fatfingererr/macro-skills --skill forecast-sector-relative-return-from-yield-spread
Clone the repo
git clone --depth 1 https://github.com/fatfingererr/macro-skills

Made for: Claude Code, Codex.

Its marketplace also offers this one on its own, as the plugin forecast-sector-relative-return-from-yield-spread/plugin install forecast-sector-relative-return-from-yield-spread after adding the marketplace above.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for forecast-sector-relative-return-from-yield-spread

README.md
[![agentmods](https://agentmods.dev/badge/skills/fatfingererr/macro-skills/forecast-sector-relative-return-from-yield-spread/github.svg)](https://agentmods.dev/skills/fatfingererr/macro-skills/forecast-sector-relative-return-from-yield-spread)
Your own site
<a href="https://agentmods.dev/skills/fatfingererr/macro-skills/forecast-sector-relative-return-from-yield-spread"><img src="https://agentmods.dev/badge/skills/fatfingererr/macro-skills/forecast-sector-relative-return-from-yield-spread/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for forecast-sector-relative-return-from-yield-spread

Your own site · 80×15
<a href="https://agentmods.dev/skills/fatfingererr/macro-skills/forecast-sector-relative-return-from-yield-spread"><img src="https://agentmods.dev/badge/skills/fatfingererr/macro-skills/forecast-sector-relative-return-from-yield-spread.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 75 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 4,057 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00075 $0.04057
Opus 5 $0.00037 $0.02028
Sonnet 5 $0.00015 $0.00811
Haiku 4.5 $0.00007 $0.00406

Measured 12d ago against content hash 097dd0591a1a, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-12, from the pricing page.

Security

Grade A, and why

forecast-sector-relative-return-from-yield-spread scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 12d ago.

The scan reads SKILL.md. This mod also ships 3 executable files (scripts/plot_bloomberg_style.py, scripts/spread_forecaster.py, scripts/spread_plotter.py), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/forecast-sector-relative-return-from-yield-spread/SKILL.md · 368 lines

How it starts

The opening of the file, as written. The whole thing — 368 lines — stays where its author put it; the contents beside it link to each section on GitHub.

<essential_principles>

美國公債利差(Yield Spread)作為領先指標:

spread_t = short_yield_t - long_yield_t
         = US02Y_t - US10Y_t

spread 越高:短端相對更高(曲線更倒掛/更緊) spread 越低(或從負回到 0、轉正):曲線「回正/變陡」

此 spread 被認為領先反映:

  • 經濟週期預期(倒掛 → 衰退預期)
  • 風險偏好轉換(曲線變陡 → 風險偏好回升)

相對強弱比率(Ratio):

ratio_t = risk_asset_t / defensive_asset_t
        = QQQ_t / XLV_t

ratio 上升:成長股(Nasdaq)相對更強 ratio 下降:防禦股(Healthcare)相對更強(XLV 跑贏)

預測目標為「未來 H 個月的對數相對報酬」:

future_rel_return = log(ratio(t+H) / ratio(t))

正值 → Nasdaq 跑贏,負值 → XLV 跑贏

圖表的時間對齊邏輯:

  • 把 spread 往前平移 lead_months 個月
  • 目標是檢查:spread(t) 是否能解釋 ratio(t + H)

工程化寫法:

X = spread(t)
Y = future_rel_return(t, H) = log(ratio(t+H) / ratio(t))

然後做相關性/迴歸/交叉相關掃描來找「最佳領先期」。

避免直接用 ratio 水平做迴歸(有趨勢/非平穩問題),改用對數報酬。

需回答三件事:

  1. 是否真的存在穩定領先關係?

    • 掃描多個 lead(6, 12, 18, 24, 30 個月)
    • 看哪個 lead 下 corr(spread, future_rel_return) 最穩、顯著
    • 跨子樣本驗證(前半段 vs 後半段)
  2. 目前情境對應的預測方向

    • 最近 spread 水準、變化率
    • 模型預測 E[future_rel_return]
    • 分位數區間(如 80% 信心區間)
  3. 把預測翻譯成直覺語句

    • 由 future_rel_return 轉回百分比:exp(future_rel_return) - 1
    • 「未來 24 個月 XLV 相對 QQQ 勝率 X%、中位數報酬 Y%」
  • 頻率選擇:週頻(weekly)降低雜訊,建議 1wk
  • 平滑視窗:可選 13 週或 26 週移動平均
  • 回測長度:至少涵蓋 1-2 次完整景氣循環(如 2007-present)

殖利率來源:FRED(DGS2, DGS10) 資產價格來源:Yahoo Finance(QQQ, XLV)

</essential_principles>

  1. 數據整合:取得殖利率(FRED)與資產價格(yfinance)
  2. 利差計算:計算 spread = short_yield - long_yield
  3. 相對報酬計算:計算 future_rel_return = log(ratio(t+H) / ratio(t))
  4. 領先關係驗證:掃描多個 lead 找最佳相關性與穩定性
  5. 情境預測:基於當前 spread 產出未來相對報酬預測區間
  6. 輸出報告:驗證結論、預測方向、風險提示

輸出:領先關係驗證、當前預測、區間估計、歷史類比、風險提示。

<quick_start>

最快的方式:執行預設情境分析

cd skills/forecast-sector-relative-return-from-yield-spread
pip install pandas numpy yfinance matplotlib statsmodels requests  # 首次使用
python scripts/spread_forecaster.py --quick

完整分析(含領先掃描與穩定性驗證)

python scripts/spread_forecaster.py \
  --risk-ticker QQQ \
  --defensive-ticker XLV \
  --lead-months 24 \
  --lookback-years 12 \
  --output result.json

生成 Bloomberg 風格視覺化圖表

python scripts/plot_bloomberg_style.py --quick --output output/yield_spread_forecast_$(date +%Y-%m-%d).png

完整版圖表(自訂參數)

python scripts/plot_bloomberg_style.py \
  --lookback-years 18 \
  --lead-months 24 \
  --risk-ticker QQQ \
  --defensive-ticker XLV \
  --output output/yield_spread_analysis.png

輸出範例:

{
  "skill": "forecast_sector_relative_return_from_yield_spread",
  "signal_name": "US02Y_minus_US10Y_leads_QQQ_over_XLV",
  "lead_months": 24,
  "current_spread": -0.35,
  "model": {
    "type": "lagged_regression",
    "alpha": 0.02,
    "beta": -0.45,
    "corr_x_y": -0.32
  },
  "forecast": {
    "future_24m_relative_return_pct": -0.077,
    "interval_pct_80": [-0.22, 0.04],
    "interpretation": "若此關係維持,未來24個月QQQ相對XLV期望報酬為-7.7%,XLV較可能跑贏。"
  }
}

</quick_start>

  1. 快速分析 - 使用預設參數(QQQ/XLV, 24 個月領先)計算當前預測
  2. 完整分析 - 自訂參數進行領先關係驗證與情境預測
  3. 領先掃描 - 掃描多個領先期(6-30 個月)找最佳相關性
  4. 視覺化圖表 - 生成利差與相對報酬對齊圖
  5. 穩定性驗證 - 檢查領先關係在不同子樣本的一致性
  6. 方法論學習 - 了解領先關係邏輯與計算方式

請選擇或直接提供分析參數。

Read the full file on GitHub · 368 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 12d ago First seen · 368 lines · 75 tokens per session scan A 097dd0591a1a

Subscribe to this mod's changes

forecast-sector-relative-return-from-yield-spread is a skill published in the GitHub repository fatfingererr/macro-skills (3 stars, last pushed 7mo ago), licensed MIT. It adds 75 tokens to every session and 4,057 once invoked, about $0.0004 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

sector-rotation

An analysis framework for comparing industries in the Chinese A-share stock market, using business conditions, price momentum, valuation, and money flows. It produces rankings and higher- or lower-allocation suggestions.

HKUDS/Vibe-Trading · 39 tokens

strategy-pivot-designer

Detect backtest iteration stagnation and generate structurally different strategy pivot proposals when parameter tuning reaches a local optimum.

tradermonty/claude-trading-skills · 28 tokens

twitter-reader

Read Twitter/X for financial research using opencli (read-only). Use this skill whenever the user wants to read their Twitter feed, search for financial tweets, view bookmarks, look up user profiles, or gather market sentiment from Twitter/X. Triggers include: "check my feed", "search Twitter for", "show my…

himself65/finance-skills · 161 tokens

chenhao-limit-up

A framework for judging Chinese A-share stocks that have reached the daily price-rise limit, using market mood, sector leadership, and trading momentum.

questflowai/investorskills · 44 tokens

furusato

A Japanese hometown-tax donation manager for furusato nozei, a system where donations to municipalities can qualify for an income-tax or local-tax deduction. It reads donation receipts, stores donation records, and calculates deduction limits.

kazukinagata/shinkoku · 102 tokens

reading-receipt

An image-reading workflow for extracting structured information from receipts, invoices, and hometown-tax donation certificates. It can first extract text from PDFs and otherwise read their images.

kazukinagata/shinkoku · 64 tokens