— No reviews yet
0 installs
15 views
0.0% view→install
Install
$ agentstack add skill-mahmoud20138-tradecraft-correlation-regime-switcher ✓ scanned · ✓ verified — works with Claude Code, Cursor, and more.
Security review
✓ PassedNo issues found. Passed automated security review. · v0.1.0 How review works →
- ✓ Prompt-injection patterns
- ✓ Secret / credential exfiltration
- ✓ Dangerous shell & filesystem operations
- ✓ Untrusted network calls
- ✓ Known-malicious package signatures
What it can access
- ✓ Network access No
- ✓ Filesystem access No
- ✓ Shell / process execution No
- ✓ Environment & secrets No
- ✓ Dynamic code execution No
From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.
Are you the author of Correlation Regime Switcher? Claim this listing to set pricing, connect Stripe payouts, and keep 70% of every sale.
Sign up to claimAbout
Correlation Regime Switcher
import pandas as pd
import numpy as np
class CorrelationRegimeSwitcher:
REGIME_STRATEGIES = {
"normal_correlation": {
"description": "Correlations at historical norms",
"strategies": ["trend_following", "carry_trade", "mean_reversion_pairs"],
"risk_level": "NORMAL",
},
"correlation_breakdown": {
"description": "Historical correlations breaking down",
"strategies": ["single_pair_momentum", "volatility_selling"],
"risk_level": "ELEVATED — reduce correlated positions",
},
"correlation_spike": {
"description": "All assets moving together (crisis mode)",
"strategies": ["safe_haven_only", "volatility_buying", "cash"],
"risk_level": "HIGH — correlation=1 means no diversification benefit",
},
"decorrelation": {
"description": "Assets becoming uncorrelated — dispersion rising",
"strategies": ["pairs_trading", "relative_value", "basket_trades"],
"risk_level": "OPPORTUNITY — dispersion creates relative value trades",
},
}
@staticmethod
def detect_regime(correlation_matrix: pd.DataFrame, historical_avg_corr: float) -> dict:
"""Classify current correlation regime."""
upper_tri = correlation_matrix.values[np.triu_indices_from(correlation_matrix.values, k=1)]
current_avg = np.mean(np.abs(upper_tri))
deviation = current_avg - abs(historical_avg_corr)
if current_avg > 0.8:
regime = "correlation_spike"
elif deviation > 0.15:
regime = "correlation_spike"
elif deviation dict:
"""Detect regime transitions from rolling correlation data."""
recent = rolling_corr.tail(window)
prior = rolling_corr.iloc[-(window*2):-window]
change = recent.mean() - prior.mean()
return {
"transition_detected": abs(change) > 0.2,
"direction": "CONVERGING" if change > 0.2 else "DIVERGING" if change 0.2 else "Hold current strategies",
}
Source & license
This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.
- Author: mahmoud20138
- Source: mahmoud20138/Tradecraft
- License: MIT
Install and usage instructions live in the source repository linked above.
Reviews
No reviews yet — be the first.
Write a review
Versions
- v0.1.0 Imported from the upstream source.