PromptsEdge
FreeGitHubData

Stock Correlation Analysis

Your AI finds correlated stocks, measures pairwise correlation and beta, builds correlation matrices, and tracks rolling or regime-based co-movement using Yahoo Finance data. Great for pair trading, sector analysis, and risk management.

Try asking: “Show the correlation matrix for NVDA, AMD, AVGO, and GOOGL”

himself65 on GitHub

Curated by PromptsEdge from a public repo · MIT license. All credit goes to the author.

What is this skill?

Understanding how stocks move together is essential for pair trading, hedging, sector analysis, and risk management. With this skill, your AI analyzes historical price data to find correlated peers, measure pairwise correlation and beta, cluster groups into correlation matrices, and track rolling or regime-dependent co-movement. Whether you want to discover sympathy plays, analyze sector relationships, or build a diversified portfolio, this tool gives you actionable, data-backed insights.

What you can do

  • Find correlated peers: "What stocks move with NVDA?" returns a ranked list of the most correlated tickers.
  • Pairwise correlation and beta: "Correlation between AMD and NVDA" gives Pearson correlation, beta, R-squared, and spread stats.
  • Build correlation matrices: "Correlation matrix for FAANG" shows NxN relationships and highlights clusters and outliers.
  • Track rolling or regime-based correlation: "Rolling 60-day correlation for GOOGL and AVGO" plots how co-movement changes over time.
  • Discover sector or supply-chain links: "Find sympathy plays for LITE" identifies related companies for event-driven trades.
  • Compare relative performance in drawdowns: "What else drops when COHR drops?" reveals regime-dependent correlation.

How it works

When you provide a ticker or group of tickers, your AI fetches historical price data from Yahoo Finance using yfinance. For a single ticker, it searches a curated peer universe to find the most correlated stocks. For pairs, it calculates correlation, beta, and spread statistics, and for groups, it builds a full correlation matrix with optional hierarchical clustering. Rolling and regime-based analyses track how relationships change over different periods or market conditions. Results include clear tables, charts, and actionable commentary.

Good to know

  • Requires Python 3.8+; yfinance, pandas, and numpy are auto-installed if missing.
  • For sector clustering, scipy is optional (for advanced clustering).
  • Works on all platforms with code execution (Claude Code, Claude.ai, etc.).
  • Reference files document peer universe construction and fallback strategies.