Skillsstock-correlation
S

stock-correlation

Analyze stock correlations to find related companies and trading pairs. Use when the user asks about correlated stocks, related companies, sector peers, trading pairs, or how two or more stocks move together. Triggers: "what correlates with NVDA", "find stocks related to AMD", "correlation between AAPL and MSFT", "what moves with", "sector peers", "pair trading", "correlated stocks", "when NVDA drops what else drops", "stocks that move together", "beta to", "relative performance", "supply chain partners", "correlation matrix", "co-movement", "related tickers", "sympathy plays", "semiconductor peers", "hedging pair", "realized correlation", "rolling correlation", or any request about stocks that move in tandem or inversely. Also triggers for well-known pairs like AMD/NVDA, GOOGL/AVGO, LITE/COHR. If only one ticker is provided, infer the user wants correlated peers.

Stock Correlation - Stock Correlation Analysis and Related Stock Lookup Skill

Skill Overview

Stock Correlation is a stock correlation analysis skill based on historical price data from yfinance. Given one or more stock symbols, it automatically calculates return correlation coefficients to help identify stocks that move together, measure the strength of the relationship between two stocks, and observe how correlation changes under different market conditions. For research and educational purposes only; this does not constitute investment advice.

Use Cases

  1. Want to know “which stocks rise and fall together with a particular stock”: Provide just one stock symbol (for example, NVDA), and the skill will dynamically build a peer stock universe, rank the most correlated stocks by correlation coefficient, and explain why each stock may be correlated—whether due to industry similarities, upstream or downstream supply-chain relationships, or overlapping customers.
  2. Want to understand the relationship between two stocks in depth: Provide two symbols (for example, AMD and NVDA) to obtain the correlation coefficient, Beta, R-squared, rolling correlation range, and spread Z-score, helping assess how close and stable the relationship is and whether it currently deviates from its historical norm.
  3. Want to understand the internal structure of an entire sector: Pass in a group of stock symbols (for example, a group of semiconductor stocks or FAANG stocks) to generate a complete correlation matrix and perform hierarchical clustering, identifying closely related clusters, diversified outliers, and the strongest and weakest correlation pairs.

Core Features

  1. Co-movement Discovery: Instead of using a hard-coded stock list, the skill uses the yfinance Screener at runtime to filter peers based on the target’s industry. If the industry sample contains fewer than 10 stocks, it automatically expands the search to the broader sector. It then supplements the candidate pool with related industries based on company business descriptions, removes duplicates, and outputs the top 10 positively correlated stocks along with notable negatively correlated stocks (potential hedging candidates).
  2. In-Depth Pairwise Correlation Analysis (Return Correlation): Based on daily log returns, the skill calculates the Pearson correlation coefficient, Beta (the sensitivity of B to A), R-squared, the mean, extremes, and standard deviation of the 60-day rolling correlation, as well as the Z-score of the log-price spread. A spread Z-score above +2 or below −2 generally indicates that the current relationship has deviated from its historical pattern. A correlation coefficient above 0.80 indicates strong co-movement, 0.50–0.80 indicates moderate correlation, and below 0.50 indicates weak correlation.
  3. Correlation Matrix Clustering and Conditional Correlation (Sector Clustering / Realized Correlation): For a group of stocks, the skill generates a complete correlation matrix and reorders it using hierarchical clustering to identify internally highly correlated stock clusters, diversified outliers, and the strongest and weakest pairs. It also supports rolling correlations over multiple windows (20/60/120 days) and can split the analysis by market conditions—up days, down days, high-volatility days, and crash days with a single-day decline exceeding 2%—to calculate correlations separately and observe the common phenomenon that “correlations tend to converge toward 1 during crises.”

Frequently Asked Questions

Do I need to prepare the data myself? Are A-shares and Hong Kong stocks supported?

No data preparation is required. The skill automatically downloads historical prices through yfinance. By default, it uses one year of daily data and adjusted-for-splits-and-dividends prices, so it can analyze any market for which yfinance provides data, primarily U.S. stocks, as well as some Hong Kong and A-share symbols. Note that yfinance is not an official data source and is not affiliated with Yahoo. Some securities may be automatically excluded due to insufficient data; the results will indicate which stocks were dropped and the actual number of trading days used.

Does a high correlation mean that two stocks have a causal relationship?

No. A correlation coefficient only describes the degree to which two stocks move together; it does not mean that one stock causes the other to rise or fall. They may simply be driven by the same industry or macroeconomic factors. In addition, historical correlation does not guarantee that the relationship will continue in the future. Correlation structures can change significantly when market styles rotate. Shorter lookback windows produce noisier estimates, while longer windows are smoother but may obscure recent changes in the relationship. Therefore, correlation can only serve as a clue, not a conclusion.

Can the analysis results be used directly as buy or sell recommendations?

No. This skill only provides data and statistical metrics; it does not make specific trading recommendations or forecast stock prices. Its practical uses are to support research: identifying which peers may move following a company’s earnings announcement (co-moving stocks), finding highly correlated pairs whose spreads have deviated from the mean (pairs trading), screening for low-correlation assets to reduce portfolio volatility (diversification), finding negatively correlated instruments (hedging), and understanding sector rotation. Investment decisions require independent judgment based on fundamentals, valuation, and personal risk tolerance.