Agent skill

Correlation Analysis

by agiprolabs in agiprolabs/claude-trading-skills

Cross-asset correlation analysis including rolling correlation, hierarchical clustering, tail dependence, and regime-dependent correlation

MITAuto-check passed

Install Correlation Analysis

skills CLI
$ npx skills add agiprolabs/claude-trading-skills --skill correlation-analysis -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install agiprolabs/claude-trading-skills correlation-analysis --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/agiprolabs/claude-trading-skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/correlation-analysis .claude/skills/correlation-analysis && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
correlation-analysis
GitHub stars
410
Token cost
~2.4k tokens
SKILL.md length
651 words
Files
5 (incl. scripts, references)
Skills in repo
68
Repo updated
First seen
Licence
MIT

At a glance

Cross-asset correlation analysis including rolling correlation, hierarchical clustering, tail dependence, and regime-dependent correlation

  • SKILL.md covers Why Correlation Matters, Correlation Methods, Rolling Correlation and Correlation Matrix Analysis, plus 6 more sections
  • Runs Python scripts from its folder

What it does

Correlation Analysis is an agent skill from agiprolabs/claude-trading-skills. Cross-asset correlation analysis including rolling correlation, hierarchical clustering, tail dependence, and regime-dependent correlation

Its SKILL.md is about 2.4k tokens, which your agent loads only when the skill is triggered. The skill folder holds 6 other files, including scripts and reference files (for example `references/methodology.md`, `references/portfolio_applications.md` and `scripts/correlation_matrix.py`).

The repository describes itself as: 68 trading, DeFi, and quantitative finance Agent Skills. Works with Claude Code, Cursor, Codex, Gemini CLI, and 30+ other tools. The licence is MIT.

Example prompts

  • “/correlation-analysis”

Requirements

  • Python 3

What it can do on your machine

Read from SKILL.md and the folder at commit 981e1d7. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Ships 2 files in scripts/ (Python), which the agent can run.

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Correlation Analysis loads about 2.4k tokens when it runs, and up to ~6k if it reads all its reference files. Until then it costs about 40 tokens; SKILL.md has 651 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~40
When it runs · the whole SKILL.md, loaded when a task matches
~2.4k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~6k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); the scripts in this folder are not scanned.

SKILL.md

The full file from agiprolabs/claude-trading-skills at commit 981e1d7, republished under its MIT licence (© agiprolabs). 651 words, ~2,393 tokens.

Download SKILL.mdSave it as .claude/skills/correlation-analysis/SKILL.md (or your agent's skills folder). This skill also uses 4 other files; get the full folder from GitHub.
name
correlation-analysis
description
Cross-asset correlation analysis including rolling correlation, hierarchical clustering, tail dependence, and regime-dependent correlation

Correlation Analysis

Cross-asset correlation analysis for diversification assessment, risk management, pairs trading signal generation, and portfolio construction.

Why Correlation Matters

Correlation measures how assets move together. In crypto markets this is critical for:

  • Diversification: holding correlated assets provides no diversification benefit — you are effectively holding one concentrated position
  • Risk management: portfolio risk depends on the correlation structure, not just individual asset volatility
  • Pairs trading: highly correlated assets that temporarily diverge create mean-reversion opportunities
  • Portfolio construction: optimal allocation requires accurate correlation estimates
  • Crash protection: understanding tail dependence reveals whether assets crash together

Correlation Methods

Pearson Correlation

Linear correlation assuming normality. Most common but least robust for crypto.

python
import pandas as pd
import numpy as np

# Always compute on returns, never on prices
returns_a = prices_a.pct_change().dropna()
returns_b = prices_b.pct_change().dropna()

pearson_corr = returns_a.corr(returns_b)  # default is Pearson
  • Range: -1 (perfect inverse) to +1 (perfect co-movement)
  • Assumes: linear relationship, normally distributed returns, no outliers
  • Limitation: crypto returns are heavy-tailed — Pearson underestimates extreme co-movement
Spearman Rank Correlation

Converts values to ranks, then computes Pearson on ranks. Captures monotonic (not just linear) relationships.

python
spearman_corr = returns_a.corr(returns_b, method='spearman')
  • More robust to outliers and non-linear relationships
  • Better for crypto due to heavy-tailed return distributions
  • Slightly lower power than Pearson when normality holds
Kendall Tau Correlation

Counts concordant vs discordant pairs. Most robust to outliers.

python
kendall_corr = returns_a.corr(returns_b, method='kendall')
  • Most robust to outliers of the three methods
  • Computationally slower on large datasets
  • Best for small samples or heavily skewed data

Rolling Correlation

Static correlation hides regime changes. Rolling correlation reveals how relationships evolve.

Window-Based Rolling Correlation
python
# Rolling Pearson correlation
rolling_corr = returns_a.rolling(window=60).corr(returns_b)

# Multiple windows for different time horizons
windows = {
    'short': 20,    # ~1 month of trading days
    'medium': 60,   # ~3 months
    'long': 120,    # ~6 months
}
for label, w in windows.items():
    df[f'corr_{label}'] = returns_a.rolling(w).corr(returns_b)
EWMA Correlation

Exponentially weighted — more responsive to recent changes.

python
def ewma_correlation(x: pd.Series, y: pd.Series, span: int = 60) -> pd.Series:
    """Compute EWMA correlation between two return series."""
    cov_xy = x.mul(y).ewm(span=span).mean() - x.ewm(span=span).mean() * y.ewm(span=span).mean()
    std_x = x.ewm(span=span).std()
    std_y = y.ewm(span=span).std()
    return cov_xy / (std_x * std_y)
Typical Windows
WindowDaysUse Case
Short20Tactical trading, pairs entry/exit
Medium60Strategy allocation, regime detection
Long120Portfolio construction, strategic allocation

Correlation Matrix Analysis

Computing the Full Matrix
python
# Build return matrix for multiple assets
returns = pd.DataFrame({
    'BTC': btc_returns,
    'ETH': eth_returns,
    'SOL': sol_returns,
    'AVAX': avax_returns,
})

# Correlation matrix (Pearson)
corr_matrix = returns.corr()

# Spearman (better for crypto)
spearman_matrix = returns.corr(method='spearman')
Eigenvalue Decomposition

Decompose the correlation matrix to identify driving factors.

python
eigenvalues, eigenvectors = np.linalg.eigh(corr_matrix.values)

# Sort descending
idx = eigenvalues.argsort()[::-1]
eigenvalues = eigenvalues[idx]
eigenvectors = eigenvectors[:, idx]

# First eigenvalue = market factor (explains most variance)
# Subsequent eigenvalues = sector/style factors
market_factor_pct = eigenvalues[0] / eigenvalues.sum() * 100
  • First eigenvector: the market factor — when this dominates (>60% variance), everything moves together
  • Subsequent eigenvectors: sector or style factors
  • Small eigenvalues: noise / idiosyncratic risk
Minimum Variance Portfolio
python
from numpy.linalg import inv

cov_matrix = returns.cov()
ones = np.ones(len(cov_matrix))
inv_cov = inv(cov_matrix.values)

# Minimum variance weights
weights = inv_cov @ ones / (ones @ inv_cov @ ones)

Hierarchical Clustering

Group assets by correlation similarity to identify natural clusters.

python
from scipy.cluster.hierarchy import linkage, fcluster
from scipy.spatial.distance import squareform

# Convert correlation to distance
dist_matrix = np.sqrt(2 * (1 - corr_matrix.values))
np.fill_diagonal(dist_matrix, 0)

# Hierarchical clustering
condensed = squareform(dist_matrix)
linkage_matrix = linkage(condensed, method='ward')

# Cut at threshold to get clusters
clusters = fcluster(linkage_matrix, t=1.0, criterion='distance')

Applications:

  • Sector detection: assets in the same cluster behave similarly
  • Diversification: select one asset per cluster for maximum diversification
  • Risk allocation: allocate risk budget across clusters, not individual assets

Tail Dependence

Normal correlation understates co-movement during crashes. Tail dependence measures how often assets experience extreme returns simultaneously.

Lower Tail Dependence
python
def tail_dependence(x: pd.Series, y: pd.Series, quantile: float = 0.05) -> float:
    """Estimate lower tail dependence coefficient.

    Measures P(Y < q | X < q) for quantile q.
    Higher values mean assets crash together more often.
    """
    threshold_x = x.quantile(quantile)
    threshold_y = y.quantile(quantile)
    joint_extreme = ((x < threshold_x) & (y < threshold_y)).sum()
    marginal_extreme = (x < threshold_x).sum()
    return joint_extreme / marginal_extreme if marginal_extreme > 0 else 0.0
Crypto-Specific Tail Behavior

In crypto markets, tail dependence typically exceeds normal correlation:

  • Normal correlation of 0.6 between two altcoins might have tail dependence of 0.8
  • During market panics, correlations spike toward 1.0 across all risk assets
  • This means diversification benefits disappear exactly when needed most
Show full SKILL.md (247 more words)Show less

Regime-Dependent Correlation

Correlation is not constant — it changes with market regime.

RegimeTypical CorrelationImplication
Bull (trending up)0.4–0.7Moderate — some diversification works
Range-bound0.2–0.5Lower — best diversification environment
Bear (crash)0.8–0.95Very high — diversification fails
Recovery0.5–0.7Declining from crash highs
Detecting Correlation Regime Shifts
python
def correlation_zscore(rolling_corr: pd.Series, lookback: int = 252) -> pd.Series:
    """Z-score of rolling correlation vs its own history."""
    mean = rolling_corr.rolling(lookback).mean()
    std = rolling_corr.rolling(lookback).std()
    return (rolling_corr - mean) / std

# Flag regime shift when z-score exceeds threshold
zscore = correlation_zscore(rolling_corr_60d)
regime_shift = zscore.abs() > 2.0

Crypto-Specific Correlation Patterns

Typical Correlation Ranges
PairNormal RangeNotes
BTC / ETH0.7–0.9Highest among majors
BTC / SOL0.6–0.85SOL more volatile, slightly less correlated
BTC / Altcoin0.5–0.8Varies by market cap and sector
Meme / BTC0.2–0.5Lower normal correlation
Meme / Meme0.1–0.4Low normal but high tail dependence
Stablecoin / BTC-0.1–0.1Should be near zero
Key Observations
  • Most altcoins are highly correlated with BTC (0.6–0.9) — the market factor dominates
  • Meme and PumpFun tokens show lower normal correlation but higher tail dependence
  • SOL ecosystem tokens correlate strongly with SOL price
  • Stablecoins should be uncorrelated with risk assets — if correlation appears, investigate (depeg risk)
  • Correlation tends to increase during high-volatility regimes
  • New token launches may show temporarily low correlation until price discovery stabilizes

Integration with Other Skills

  • risk-management: use correlation to compute portfolio-level VaR and stress scenarios
  • portfolio-analytics: correlation matrix feeds optimal allocation algorithms
  • regime-detection: correlation regime shifts are an input to regime classification
  • cointegration-analysis: pairs with high correlation are candidates for cointegration testing
  • position-sizing: correlation-adjusted sizing prevents correlated concentration

Files

References
  • references/methodology.md — Correlation formulas, statistical tests, estimation methods
  • references/portfolio_applications.md — Diversification metrics, pairs trading, risk decomposition
Scripts
  • scripts/correlation_matrix.py — Multi-asset correlation matrix, clustering, diversification metrics
  • scripts/rolling_correlation.py — Rolling correlation, regime detection, tail dependence analysis

© agiprolabs, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 4 other files (scripts, references) in skills/correlation-analysis of agiprolabs/claude-trading-skills.

  • SKILL.md
  • references/methodology.md
  • references/portfolio_applications.md
  • scripts/correlation_matrix.py
  • scripts/rolling_correlation.py

Open the folder on GitHubat commit 981e1d7

Compare with similar skills

Correlation Analysis next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Correlation Analysis compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Correlation Analysis this skillagiprolabs/claude-trading-skills410—~2.4kAutomated safety check: PassMIT
Hierarchical Clustering Plotaipoch/medical-research-skills2k—~3.1kAutomated safety check: PassMIT
Hierarchical Taxonomy Clusteringbenchflow-ai/skillsbench1.8k—~983Automated safety check: PassApache-2.0
Correlation and Cointegration AnalysisHKUDS/Vibe-Trading35k—~10kAutomated safety check: PassMIT
AssetsBuilderIO/agent-native7.1k—~1.2kAutomated safety check: PassNone
Game Asset AuditDonchitos/Claude-Code-Game-Studios26k—~2kAutomated safety check: PassMIT

Similar skills

  • Hierarchical Clustering Plot

    aipoch/medical-research-skills

    A skill your agent uses when building a sample-level hierarchical clustering dendrogram from a bulk expression matrix and sample annotation table, especially for QC, batch inspection, or sample…

    2k GitHub stars~3.1k tokensUpdated 21 days ago
    Research & ScienceAuto-check passed
  • Hierarchical Taxonomy Clustering

    benchflow-ai/skillsbench

    Build unified multi-level category taxonomy from hierarchical product category paths from any e-commerce companies using embedding-based recursive clustering with intelligent category naming via…

    1.8k GitHub stars~983 tokensUpdated 2 mo ago
    AI & LLM EngineeringAuto-check passed
  • Finds co-moving assets and tests them for cointegration, with workflows for correlation studies, sector clustering, hedge ratios and pair-trading signals.

    35k GitHub stars~10k tokensUpdated today
    Business, Finance & HRAuto-check passed
  • Assets

    BuilderIO/agent-native

    Use Agent-Native Assets for image and video generation requests, brand-safe asset search/export, and human-in-the-loop asset selection through the hosted Assets MCP app.

    7.1k GitHub stars~1.2k tokensUpdated today
    Agent WorkflowsAuto-check passed
  • Game Asset Audit

    Donchitos/Claude-Code-Game-Studios

    Audits game assets against naming conventions, file size budgets and format standards, and finds orphaned assets and missing references.

    26k GitHub stars~2k tokensUpdated 8 days ago
    Game DevelopmentAuto-check passed
  • Vector Cluster

    ruvnet/ruflo

    Cluster code by graph community detection via npx ruvector@0.2.25 hooks graph-cluster (spectral / Louvain)

    74k GitHub stars~540 tokensUpdated today
    Auto-check: notes

More from agiprolabs/claude-trading-skills

All 68 skills in this repo
  • Backtrader

    agiprolabs/claude-trading-skills

    Event-driven backtesting with bar-by-bar execution, complex order types, multiple analyzers, and custom indicators

    410 GitHub stars~2.4k tokensUpdated 1 mo ago
    Auto-check passed
  • Birdeye API

    agiprolabs/claude-trading-skills

    Solana token market data via Birdeye — prices, OHLCV, trades, token metadata, security checks, and trader activity

    410 GitHub stars~1.8k tokensUpdated 1 mo ago
    Auto-check passed
  • Coingecko API

    agiprolabs/claude-trading-skills

    Broad crypto market data from CoinGecko covering 13,000+ tokens.

    410 GitHub stars~1.6k tokensUpdated 1 mo ago
    Auto-check passed
  • Cointegration Analysis

    agiprolabs/claude-trading-skills

    Cointegration testing for pairs trading using Engle-Granger, Johansen, and rolling stability analysis

    410 GitHub stars~2.1k tokensUpdated 1 mo ago
    Auto-check passed
  • Copy Trading

    agiprolabs/claude-trading-skills

    Wallet evaluation, monitoring, and copy-trade strategy design for Solana DEX trading

    410 GitHub stars~2.4k tokensUpdated 1 mo ago
    Auto-check passed
  • Cost Basis Engine

    agiprolabs/claude-trading-skills

    Multi-method cost basis computation including specific identification, FIFO, LIFO, HIFO, and proportional average cost with partial sell handling

    410 GitHub stars~3.1k tokensUpdated 1 mo ago
    Auto-check passed

Questions about Correlation Analysis

What does Correlation Analysis do?

Cross-asset correlation analysis including rolling correlation, hierarchical clustering, tail dependence, and regime-dependent correlation. Correlation Analysis is an agent skill from agiprolabs/claude-trading-skills.

How do I install Correlation Analysis in Claude Code?

Run `npx skills add agiprolabs/claude-trading-skills --skill correlation-analysis -a claude-code`. Or copy the skill folder (skills/correlation-analysis in agiprolabs/claude-trading-skills) into .claude/skills/correlation-analysis in your project. Claude Code loads it when a task matches its description.

How do I install Correlation Analysis in Codex?

Run `npx skills add agiprolabs/claude-trading-skills --skill correlation-analysis -a codex`. Or copy the skill folder (skills/correlation-analysis in agiprolabs/claude-trading-skills) into .agents/skills/correlation-analysis in your project. Codex loads it when a task matches its description.

Can I use Correlation Analysis in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add agiprolabs/claude-trading-skills --skill correlation-analysis -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/correlation-analysis, .gemini/skills/correlation-analysis, .github/skills/correlation-analysis and .opencode/skills/correlation-analysis in your project.

What does Correlation Analysis need to run?

Going by SKILL.md and its folder, Correlation Analysis needs Python for the scripts in its folder. Our summary lists: Python 3.

Does Correlation Analysis access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Correlation Analysis safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. The check reads SKILL.md only: the scripts in the folder are not scanned, so read them before running anything.

What licence does Correlation Analysis use?

Correlation Analysis is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Correlation Analysis use?

About 2.4k tokens (SKILL.md is roughly 9.6k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 3.6k tokens, read only when the agent opens those files.

What are the alternatives to Correlation Analysis?

Skills that share tags, products or a category with Correlation Analysis: Hierarchical Clustering Plot (aipoch/medical-research-skills, 2k stars), Hierarchical Taxonomy Clustering (benchflow-ai/skillsbench, 1.8k stars), Correlation and Cointegration Analysis (HKUDS/Vibe-Trading, 35k stars) and Assets (BuilderIO/agent-native, 7.1k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Correlation Analysis?

agiprolabs (a GitHub user) maintains it in agiprolabs/claude-trading-skills, which has 410 GitHub stars. The repository holds 68 skills in this directory. The repository was last updated on September 3, 2026.

Source: agiprolabs/claude-trading-skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.