finance-sentiment
Fetch normalized stock sentiment across Reddit, X.com, financial news, and Polymarket from the Adanos Finance API: buzz score,…
Analyze how stocks move together using Yahoo Finance price history (yfinance): find correlated peers for a ticker, measure correlation, beta, and spread between specific tickers, cluster a group into a correlation matrix, and track rolling or regime-dependent correlation. Use
Claude Code
$ npx -y skills add himself65/finance-skills --skill stock-correlation --agent claude-code
Codex
$ npx skills add himself65/finance-skills --skill stock-correlation -a codex -y
Cursor
$ npx skills add himself65/finance-skills --skill stock-correlation -a cursor -y
Gemini CLI
$ npx skills add himself65/finance-skills --skill stock-correlation -a gemini-cli -y
GitHub Copilot
$ npx skills add himself65/finance-skills --skill stock-correlation -a github-copilot -y
OpenCode
$ npx skills add himself65/finance-skills --skill stock-correlation -a opencode -y
Windsurf
$ npx skills add himself65/finance-skills --skill stock-correlation -a windsurf -y
name: stock-correlation description: > Analyze how stocks move together using Yahoo Finance price history (yfinance): find correlated peers for a ticker, measure correlation, beta, and spread between specific tickers, cluster a group into a correlation matrix, and track rolling or regime-dependent correlation. Use this skill whenever the user asks what moves with a stock, what else drops when it drops, related tickers or sympathy plays, sector or supply-chain peers, pair trading or hedging pairs, beta or relative performance, correlation matrices, co-movement, or rolling/realized correlation — including well-known pairs like AMD/NVDA, GOOGL/AVGO, or LITE/COHR. With a single ticker, assume the user wants its correlated peers.
If your host has not already executed the shell probes below (for example, in Codex), run the commands inside the `!` wrappers with its shell tool before choosing a setup path. Use the actual output; if shell access is unavailable, report that limitation.
Finds and analyzes correlated stocks using historical price data from Yahoo Finance via [yfinance](https://github.com/ranaroussi/yfinance). Routes to specialized sub-skills based on user intent.
**Important**: This is for research and educational purposes only. Not financial advice. yfinance is not affiliated with Yahoo, Inc.
---
**Current environment status:**
!`python3 -c "exec('try:\n import yfinance, pandas, numpy\n print(f\'yfinance={yfinance.__version__} pandas={pandas.__version__} numpy={numpy.__version__}\')\nexcept Exception:\n print(\'DEPS_MISSING\')')"`If `DEPS_MISSING`, install required packages before running any code:
import subprocess, sys subprocess.check_call([sys.executable, "-m", "pip", "install", "-q", "yfinance", "pandas", "numpy"])
If all dependencies are already installed, skip the install step and proceed directly.
---
Classify the user's request and jump to the matching sub-skill section below.
| User Request | Route To | Examples | |---|---|---| | Single ticker, wants to find related stocks | **Sub-Skill A: Co-movement Discovery** | "what correlates with NVDA", "find stocks related to AMD", "sympathy plays for TSLA" | | Two or more specific tickers, wants relationship details | **Sub-Skill B: Return Correlation** | "correlation between AMD and NVDA", "how do LITE and COHR move together", "compare AAPL vs MSFT" | | Group of tickers, wants structure/grouping | **Sub-Skill C: Sector Clustering** | "correlation matrix for FAANG", "cluster these semiconductor stocks", "sector peers for AMD" | | Wants time-varying or conditional correlation | **Sub-Skill D: Realized Correlation** | "rolling correlation AMD NVDA", "when NVDA drops what else drops", "how has correlation changed" |
If ambiguous, default to **Sub-Skill A** (Co-movement Discovery) for single tickers, or **Sub-Skill B** (Return Correlation) for two tickers.
| Parameter | Default | |---|---| | Lookback period | `1y` (1 year) | | Data interval | `1d` (daily) | | Correlation method | Pearson | | Minimum correlation threshold | 0.60 | | Number of results | Top 10 | | Return type | Daily log returns | | Rolling window | 60 trading days |
---
**Goal**: Given a single ticker, find stocks that move with it.
You need 15-30 candidates. **Do not use hardcoded ticker lists** — build the universe dynamically at runtime. See `references/sector_universes.md` for the full implementation. The approach:
1. **Screen same-industry stocks** using `yf.screen()` + `yf.EquityQuery` to find stocks in the same industry as the target 2. **Broaden to sector** if the industry screen returns fewer than 10 peers 3. **Add thematic/adjacent industries** — read the target's `longBusinessSummary` and screen 1-2 related industries (e.g., a semiconductor company → also screen semiconductor equipment) 4. **Combine, deduplicate, remove target ticker**
import yfinance as yf
import pandas as pd
import numpy as np
def discover_comovement(target_ticker, peer_tickers, period="1y"):
all_tickers = [target_ticker] + [t for t in peer_tickers if t != target_ticker]
data = yf.download(all_tickers, period=period, auto_adjust=True, progress=False)
# Extract close prices — yf.download returns MultiIndex (Price, Ticker) columns
closes = data["Close"].dropna(axis=1, thresh=max(60, len(data) // 2))
# Log returns
returns = np.log(closes / closes.shift(1)).dropna()
corr_series = returns.corr()[target_ticker].drop(target_ticker, errors="ignore")
# Rank by absolute correlation
ranked = corr_series.abs().sort_values(ascending=False)
result = pd.DataFrame({
"Ticker": ranked.index,
"Correlation": [round(corr_series[t], 4) for t in ranked.index],
})
return result, returnsShow a ranked table with company names and sectors (fetch via `yf.Ticker(t).info.get("shortName")`). Values below are illustrative:
| Rank | Ticker | Company | Correlation | Why linked | |---|---|---|---|---| | 1 | AMD | Advanced Micro Devices | 0.82 | Same industry — GPU/CPU | | 2 | AVGO | Broadcom | 0.78 | AI infrastructure peer |
Include:
---
**Goal**: Deep-dive into the relationship between two (or a few) specific tickers.
import yfinance as yf
import pandas as pd
import numpy as np
def return_correlation(ticker_a, ticker_b, period="1y"):
data = yf.download([ticker_a, ticker_b], period=period, auto_adjust=True, progress=FalsA collection of agent skills for financial analysis and trading, following the Agent Skills open standard. Visit skills.himself65.com for documentation, demos, and setup instructions.
Fetch normalized stock sentiment across Reddit, X.com, financial news, and Polymarket from the Adanos Finance API: buzz score,…
Query Fintel (fintel.io) institutional market data through its REST API or official MCP server. Use this skill whenever the user…
Check the live status of the Strait of Hormuz from the Hormuz Strait Monitor dashboard: open, restricted, or closed status,…
Read Hyperliquid (app.hyperliquid.xyz) perp and spot market data through opencli and Hyperliquid's public info API: mark, oracle,…
Query TradingView market data through the bundled tradingview MCP server without a desktop app or login. Use whenever the user…
Read the user's local TradingView desktop app through opencli: quotes, options chains with greeks and per-strike IV, options…
Use this skill to extract structured Markdown/JSON from PDFs and document images—tables with cell-level precision, formulas as…
Estimates intracellular metabolic fluxes from steady-state carbon-13 isotope-tracing measurements using validated atom maps,…