correlation-analysis
金融資産間の相関関係を、期間を区切った変動やグループ化、リスクの高まりやすさ、状況に応じた変化などを分析し、投資判断やリスク管理に役立てるSkill。
📜 元の英語説明(参考)
Cross-asset correlation analysis including rolling correlation, hierarchical clustering, tail dependence, and regime-dependent correlation
🇯🇵 日本人クリエイター向け解説
金融資産間の相関関係を、期間を区切った変動やグループ化、リスクの高まりやすさ、状況に応じた変化などを分析し、投資判断やリスク管理に役立てるSkill。
※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。
下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o correlation-analysis.zip https://jpskill.com/download/10401.zip && unzip -o correlation-analysis.zip && rm correlation-analysis.zip
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/10401.zip -OutFile "$d\correlation-analysis.zip"; Expand-Archive "$d\correlation-analysis.zip" -DestinationPath $d -Force; ri "$d\correlation-analysis.zip"
完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。
💾 手動でダウンロードしたい(コマンドが難しい人向け)
- 1. 下の青いボタンを押して
correlation-analysis.zipをダウンロード - 2. ZIPファイルをダブルクリックで解凍 →
correlation-analysisフォルダができる - 3. そのフォルダを
C:\Users\あなたの名前\.claude\skills\(Win)または~/.claude/skills/(Mac)へ移動 - 4. Claude Code を再起動
⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。
🎯 このSkillでできること
下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。
📦 インストール方法 (3ステップ)
- 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
- 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
- 3. 展開してできたフォルダを、ホームフォルダの
.claude/skills/に置く- · macOS / Linux:
~/.claude/skills/ - · Windows:
%USERPROFILE%\.claude\skills\
- · macOS / Linux:
Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。
詳しい使い方ガイドを見る →- 最終更新
- 2026-05-18
- 取得日時
- 2026-05-18
- 同梱ファイル
- 1
📖 Skill本文(日本語訳)
※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。
相関分析
分散評価、リスク管理、ペア取引シグナルの生成、およびポートフォリオ構築のためのクロスアセット相関分析。
相関が重要な理由
相関は、資産がどのように連動するかを測定します。暗号資産市場では、これは以下にとって重要です。
- 分散: 相関のある資産を保有しても、分散効果は得られません。実質的に、1つの集中したポジションを保有していることになります。
- リスク管理: ポートフォリオのリスクは、個々の資産のボラティリティだけでなく、相関構造にも依存します。
- ペア取引: 一時的に乖離した相関の高い資産は、平均回帰の機会を生み出します。
- ポートフォリオ構築: 最適な配分には、正確な相関の推定が必要です。
- クラッシュ保護: テール依存性を理解することで、資産が一緒にクラッシュするかどうかを明らかにします。
相関メソッド
ピアソン相関
正規性を仮定した線形相関。最も一般的ですが、暗号資産には最もロバストではありません。
import pandas as pd
import numpy as np
# 常にリターンで計算し、価格では計算しない
returns_a = prices_a.pct_change().dropna()
returns_b = prices_b.pct_change().dropna()
pearson_corr = returns_a.corr(returns_b) # デフォルトは Pearson
- 範囲: -1 (完全な逆相関) から +1 (完全な同方向への動き)
- 仮定: 線形関係、正規分布のリターン、外れ値なし
- 制限: 暗号資産のリターンは裾が重い — ピアソンは極端な同方向への動きを過小評価します。
スピアマンの順位相関
値をランクに変換し、ランクに対してピアソンを計算します。単調な(線形だけでなく)関係を捉えます。
spearman_corr = returns_a.corr(returns_b, method='spearman')
- 外れ値や非線形関係に対してよりロバストです。
- 裾の重いリターン分布のため、暗号資産に適しています。
- 正規性が成り立つ場合、ピアソンよりもわずかに検出力が低くなります。
ケンドールのタウ相関
一致するペアと不一致のペアをカウントします。外れ値に対して最もロバストです。
kendall_corr = returns_a.corr(returns_b, method='kendall')
- 3つの方法の中で外れ値に対して最もロバストです。
- 大規模なデータセットでは計算に時間がかかります。
- 小さなサンプルや大きく歪んだデータに最適です。
ローリング相関
静的な相関は、レジームの変化を隠します。ローリング相関は、関係がどのように進化するかを明らかにします。
ウィンドウベースのローリング相関
# ローリングピアソン相関
rolling_corr = returns_a.rolling(window=60).corr(returns_b)
# さまざまな時間軸のための複数のウィンドウ
windows = {
'short': 20, # ~1ヶ月の取引日
'medium': 60, # ~3ヶ月
'long': 120, # ~6ヶ月
}
for label, w in windows.items():
df[f'corr_{label}'] = returns_a.rolling(w).corr(returns_b)
EWMA 相関
指数加重 — 最近の変化により敏感です。
def ewma_correlation(x: pd.Series, y: pd.Series, span: int = 60) -> pd.Series:
"""2つのリターン系列間の EWMA 相関を計算します。"""
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)
一般的なウィンドウ
| ウィンドウ | 日数 | ユースケース |
|---|---|---|
| Short | 20 | 戦術的な取引、ペアのエントリー/イグジット |
| Medium | 60 | 戦略的配分、レジーム検出 |
| Long | 120 | ポートフォリオ構築、戦略的配分 |
相関行列分析
完全な行列の計算
# 複数の資産のリターン行列を構築する
returns = pd.DataFrame({
'BTC': btc_returns,
'ETH': eth_returns,
'SOL': sol_returns,
'AVAX': avax_returns,
})
# 相関行列 (ピアソン)
corr_matrix = returns.corr()
# スピアマン (暗号資産に適している)
spearman_matrix = returns.corr(method='spearman')
固有値分解
相関行列を分解して、推進要因を特定します。
eigenvalues, eigenvectors = np.linalg.eigh(corr_matrix.values)
# 降順にソート
idx = eigenvalues.argsort()[::-1]
eigenvalues = eigenvalues[idx]
eigenvectors = eigenvectors[:, idx]
# 最初の固有値 = 市場要因 (最も分散を説明する)
# 後続の固有値 = セクター/スタイル要因
market_factor_pct = eigenvalues[0] / eigenvalues.sum() * 100
- 最初の固有ベクトル: 市場要因 — これが支配的な場合 (>60% の分散)、すべてが一緒に動きます。
- 後続の固有ベクトル: セクターまたはスタイルの要因
- 小さな固有値: ノイズ/個別リスク
最小分散ポートフォリオ
from numpy.linalg import inv
cov_matrix = returns.cov()
ones = np.ones(len(cov_matrix))
inv_cov = inv(cov_matrix.values)
# 最小分散ウェイト
weights = inv_cov @ ones / (ones @ inv_cov @ ones)
階層型クラスタリング
相関の類似性によって資産をグループ化し、自然なクラスターを特定します。
from scipy.cluster.hierarchy import linkage, fcluster
from scipy.spatial.distance import squareform
# 相関を距離に変換
dist_matrix = np.sqrt(2 * (1 - corr_matrix.values))
np.fill_diagonal(dist_matrix, 0)
# 階層型クラスタリング
condensed = squareform(dist_matrix)
linkage_matrix = linkage(condensed, method='ward')
# しきい値でカットしてクラスターを取得
clusters = fcluster(linkage_matrix, t=1.0, criterion='distance')
アプリケーション:
- セクター検出: 同じクラスター内の資産は同様に動作します。
- 分散: 最大限の分散のために、クラスターごとに1つの資産を選択します。
- リスク配分: 個々の資産ではなく、クラスター全体にリスク予算を配分します。
テール依存性
通常の相関は、クラッシュ時の同方向への動きを過小評価します。テール依存性は、資産が同時に極端なリターンを経験する頻度を測定します。
下方テール依存性
def tail_dependence(x: pd.Series, y: pd.Series, quantile: float = 0.05) -> float:
"""下方テール依存性係数を推定します。
分位数 q に対して P(Y < q | X < q) を測定します。
値が高いほど、資産が一緒にクラッシュする頻度が高くなります。
"""
threshold_x = x.quantile(quantile)
threshold_y = y.quantile( 📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開
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.
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.
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.
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
# 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.
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
| Window | Days | Use Case |
|---|---|---|
| Short | 20 | Tactical trading, pairs entry/exit |
| Medium | 60 | Strategy allocation, regime detection |
| Long | 120 | Portfolio construction, strategic allocation |
Correlation Matrix Analysis
Computing the Full Matrix
# 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.
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
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.
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
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
Regime-Dependent Correlation
Correlation is not constant — it changes with market regime.
| Regime | Typical Correlation | Implication |
|---|---|---|
| Bull (trending up) | 0.4–0.7 | Moderate — some diversification works |
| Range-bound | 0.2–0.5 | Lower — best diversification environment |
| Bear (crash) | 0.8–0.95 | Very high — diversification fails |
| Recovery | 0.5–0.7 | Declining from crash highs |
Detecting Correlation Regime Shifts
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
| Pair | Normal Range | Notes |
|---|---|---|
| BTC / ETH | 0.7–0.9 | Highest among majors |
| BTC / SOL | 0.6–0.85 | SOL more volatile, slightly less correlated |
| BTC / Altcoin | 0.5–0.8 | Varies by market cap and sector |
| Meme / BTC | 0.2–0.5 | Lower normal correlation |
| Meme / Meme | 0.1–0.4 | Low normal but high tail dependence |
| Stablecoin / BTC | -0.1–0.1 | Should 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 methodsreferences/portfolio_applications.md— Diversification metrics, pairs trading, risk decomposition
Scripts
scripts/correlation_matrix.py— Multi-asset correlation matrix, clustering, diversification metricsscripts/rolling_correlation.py— Rolling correlation, regime detection, tail dependence analysis