correlation-analysis

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

By agiprolabs · 365 installs

npx skills add agiprolabs/claude-trading-skills --skill correlation-analysis

Source repository · Upstream listing

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. 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. 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. 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 EWMA Correlation Exponentially weighted — more responsive to recent changes. 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 Eigenvalue Decomposition Decompose the correlation matrix to identify driving factors. 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 Hierarchical Clustering Group assets by correlation similarity to identify natural clusters. 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 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 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 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