correlation-analysis

Analyze market data for correlation, cointegration, and cross-market linkages using statistical tests.

2|Updated May 13, 2026
One-click install
npx skills add https://github.com/thanhtai040805/AI_Invest --skill correlation-analysis-thanhtai040805
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: correlation-analysis
Source: https://github.com/thanhtai040805/AI_Invest/tree/main/ai-engine/app/domain/services/quant/skills_data/correlation-analysis
Command: npx skills add https://github.com/thanhtai040805/AI_Invest --skill correlation-analysis-thanhtai040805

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires pandas, numpy, scipy, statsmodels, matplotlib, and includes scripts (resource) and references (resource) and assets (resource) components.

What problem does it solve?

This Skill provides in-depth correlation and cointegration analysis, uncovering hidden patterns in market data for informed decision-making.

Core Features & Use Cases

  • Co-Movement Discovery: Identify highly correlated assets for pairs trading and substitute identification.
  • Deep Return-Correlation Analysis: Perform a comprehensive analysis including Pearson, Spearman, and Kendall correlations, Beta/R², rolling correlation, and spread Z-Score.
  • Sector Clustering: Run hierarchical clustering on correlation matrices to discover sector structures and portfolio diversification.
  • Realized Correlation: Compute rolling correlation and analyze conditional correlation by market regime.
  • Cointegration Analysis: Use Engle-Granger and Johansen tests to assess long-run equilibrium relationships.
  • Cross-Market Linkage Analysis: Analyze cross-market correlations and lead-lag relationships between different markets.
  • Pair-Trading Signal Generation: Generate signals for pair trading based on correlation and cointegration analysis.

Quick Start

Activate the correlation-analysis skill to perform a full correlation analysis on the 'market_data.csv' file.

Frequently Asked Questions about correlation-analysis

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I test for cointegration between two assets for pairs trading?

Cointegration testing for pairs trading uses Engle-Granger and Johansen tests to assess long-run equilibrium relationships between assets. This identifies statistically valid pairs whose price spreads mean-revert over time.

What is the best way to calculate rolling correlation across market data in Python?

Rolling correlation across market data is calculated using pandas and numpy to compute moving window Pearson or Spearman coefficients. This reveals how asset co-movement dynamics evolve, allowing analysis of conditional correlation by market regime.

Does this correlation analysis approach use Pearson, Spearman, and Kendall methods?

Yes, deep return-correlation analysis uses Pearson, Spearman, and Kendall correlation methods alongside Beta, R-squared, and spread Z-Score calculations to provide a comprehensive statistical view of asset relationships.

Can I use hierarchical clustering on a correlation matrix to find sector structures?

Yes, hierarchical clustering runs on correlation matrices to discover sector structures. Grouping assets by their return correlations helps identify natural market clusters and optimize portfolio diversification.

How do I analyze cross-market linkages and lead-lag relationships?

Cross-market linkage analysis examines correlations and lead-lag relationships between different markets using statsmodels. This uncovers how price movements in one market statistically predict or follow movements in another.

Do I need statsmodels and scipy to run Johansen tests for market analysis?

Yes, running Johansen tests for market analysis requires statsmodels and scipy. These dependencies provide the underlying statistical methods needed for cointegration tests and data manipulation alongside pandas and numpy.