Analyze stock correlations to find related companies and trading pairs. Use when the user asks about correlated stocks, related companies, sector peers, trad…
npx clawhub@latest install stock-correlationStock Correlation analyzes how stocks move together using historical price data sourced from Yahoo Finance via yfinance. It routes your request to the right analysis — from discovering which peers co-move with a single ticker, to deep-diving into a specific pair's relationship, clustering a group by correlation structure, or tracking how correlation shifts over time and across market regimes. Install it when you need data-driven insight into stock relationships for research, portfolio construction, or risk awareness.
npx clawhub@latest install stock-correlationClick the Install button at the top of this page for one-click setup
Automatically classifies your request and routes to one of four specialized analyses: Co-movement Discovery (single ticker), Return Correlation (specific pair), Sector Clustering (basket), or Realized Correlation (time-varying). Ambiguous requests default to sensible fallbacks — single ticker goes to discovery, two tickers go to pairwise analysis.
Given one ticker, dynamically builds a 15–30 stock peer universe by screening same-industry and adjacent-industry stocks via yf.screen() and yf.EquityQuery — no hardcoded lists. Returns a ranked table of the top correlated peers with company names, correlation values, and a brief explanation of why each link likely exists.
Computes Pearson correlation, beta, R-squared, 60-day rolling correlation statistics (mean, min, max, std dev), and current log-price spread z-score for any two tickers. The spread z-score highlights when a pair has diverged unusually far from its historical relationship.
Builds a full correlation matrix for a group of tickers and applies hierarchical clustering (Ward linkage via scipy, with a fallback to average-correlation sorting) to reorder the matrix and surface natural groupings. Identifies the strongest pairs, weakest pairs, and outlier tickers that may serve as diversifiers.
Computes rolling correlations across 20-, 60-, and 120-day windows and breaks correlation down by market regime — up days, down days, high-volatility days, and large drawdown days. Highlights whether correlation spikes during stress, a critical consideration for risk management and hedging.
Every response includes the lookback period used, number of observations, any tickers dropped for insufficient data, and standard reminders that correlation is not causation and past correlation does not guarantee future co-movement. No trades are ever recommended.
Ask "what moves with NVDA?" before a major earnings event. The skill screens sector and adjacent-industry peers, ranks them by realized correlation, and explains the likely link — helping you identify stocks that may react to NVDA's print even without reporting themselves.
Provide two tickers like AMD and NVDA. The skill returns correlation, beta, R-squared, rolling correlation stability, and the current spread z-score — giving you the quantitative foundation to assess whether a mean-reversion or pairs-trading idea has historical support.
Supply a basket of holdings and receive a clustered correlation matrix that reveals which positions are effectively moving together and which genuinely diversify the portfolio. Outlier tickers with low average group correlation are flagged as potential diversifiers.
Ask "how has the correlation between LITE and COHR changed over time?" The skill computes rolling correlations across multiple windows and breaks results down by regime, showing whether the relationship tightens during sell-offs — the "correlations go to 1 in a crisis" effect that matters most for hedging.
yfinance, pandas, numpy (auto-installed by the skill if missing)scipy for hierarchical clustering in Sub-Skill C (skill falls back gracefully if unavailable)npx clawhub@latest install stock-correlationLog in to write a review
No reviews yet. Be the first to share your experience!