본문으로 건너뛰기
Skillpedia
분석 및 스프레드시트37k · #7506

correlation-regime

하는 일

이 스킬은 자산들이 함께 움직이는 강도가 시간에 따라 어떻게 바뀌는지 추적하고, 급락 때 가장 먼저 움직인 자산을 찾습니다. 분산 투자가 언제 효과를 잃는지 알고 싶은 위험 관리자와 트레이더를 위한 스킬입니다.

사용하는 경우

  • ✓시장이 강하게 연동된 상태로 들어갔는지 알고 싶을 때.
  • ✓위기나 급락 때 어떤 자산이 가장 먼저 움직였는지 알고 싶을 때.
  • ✓시장과의 관계가 조용히 바뀐 자산을 찾고 싶은 경우.

스킬 링크

https://github.com/HKUDS/Vibe-Trading/blob/main/agent/src/skills/correlation-regime/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/HKUDS/Vibe-Trading/blob/main/agent/src/skills/correlation-regime/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“최근 암호화폐 시장이 강하게 연동된 상태에 들어섰는지, 그리고 최근 급락을 이끈 자산이 있었는지 알려 주세요.”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

에이전트는 자산들이 시간에 따라 얼마나 연결되어 있는지 추적하고, 빈번한 전환을 막는 히스테리시스 방식으로 국면을 표시합니다. 위기 때 먼저 움직인 자산을 살펴보고, 각 판단에 확신 수준을 붙이며, 원인이 불분명하면 그렇다고 밝힙니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

Correlation-Regime Detection and Crisis Attribution

Overview

The correlation-analysis skill answers "how correlated are these assets?" — a snapshot. This skill answers the temporal questions a snapshot cannot:

  1. When did the market fuse into one highly-correlated bloc, and when did it release? (Mode 1 — regime detection)
  2. What does a fused regime mean for position sizing? (Mode 2 — risk context)
  3. Who moved first when a crisis broke — is there a nameable trigger asset? (Mode 3 — first-mover attribution)
  4. Who quietly rewired their relationship to the rest of the market, even without a violent move? (Mode 4 — rewiring leaderboard)

The methodology comes from an open-source streaming pipeline (see References) whose public repository pins the regime machinery's math and an eight-event historical replay regression (COVID, May-2021, China ban, Nov-2021 top, LUNA, FTX, SVB, yen-carry — 17 crypto symbols, 1-minute bars) that its CI reproduces bit-for-bit. The finer-grained numbers quoted in this skill — 13 fused/defused regime cycles on the continuous 2020–2024 tape at a ~0.008/day calm false-alarm rate, and zero wrong culprit names across 10 labeled crises (2 held out-of-sample), including naming FTT roughly two days before the November 2022 collapse — are the author's unpublished internal replays on that same pipeline and are not independently verifiable. All of it is historical replay, never live results, and the method is market-agnostic even though the validation tape is crypto.

What this skill is NOT: a trade-timing signal. The same validation program tested regime-based exits head-to-head against a plain price stop and lost — correlation regimes cannot time tops, and the give-up cost of selling into a crash is a property of the tape, not of any signal. Use these modes for risk context, monitoring, and post-hoc attribution; never present them as buy/sell triggers.


Mode 1: Correlation-Regime Detection (Edge Density + Hysteresis)

Use case: Maintain a live, causal answer to "is the market currently one bloc?" Diversification quietly disappears when pairwise correlations fuse; a regime state machine turns that into an explicit, monitorable state with few false alarms.

Workflow

1. Compute rolling-window pairwise correlations of returns
2. Reduce each correlation matrix to one number: edge density
   = fraction of asset pairs with |ρ| ≥ edge_threshold
3. Smooth the density series with a TRAILING window (causal — see warning below)
4. Run a hysteresis (Schmitt-trigger) state machine over the smoothed series:
   enter FUSED when density ≥ enter_threshold, exit only when ≤ exit_threshold
5. Emit regime state + transition timestamps for monitoring / reporting

Two thresholds with a dead band between them are the entire trick: a single threshold chatters (fires dozens of times as density oscillates around it), while hysteresis yields a handful of clean regime cycles per market cycle.

import numpy as np
import pandas as pd


def compute_edge_density(
    returns: pd.DataFrame,
    corr_window: int = 60,
    edge_threshold: float = 0.5,
) -> pd.Series:
    """Reduce rolling correlation matrices to an edge-density series.

    Edge density is the fraction of distinct asset pairs whose rolling
    |correlation| clears ``edge_threshold`` — a scalar "how fused is the
    market" gauge in [0, 1].

    Args:
        returns: Multi-asset return matrix, columns are symbols
        corr_window: Rolling window length (bars) for pairwise correlation
        edge_threshold: |ρ| level at which a pair counts as an "edge"

    Returns:
        Edge-density series aligned to ``returns.index`` (NaN during warmup)
    """
    n_assets = returns.shape[1]
    n_pairs = n_assets * (n_assets - 1) // 2
    upper_mask = np.triu(np.ones((n_assets, n_assets), dtype=bool), k=1)

    density = pd.Series(np.nan, index=returns.index)
    for i in range(corr_window, len(returns) + 1):
        corr = returns.iloc[i - corr_window:i].corr().abs().to_numpy()
        density.iloc[i - 1] = float((corr[upper_mask] >= edge_threshold).sum()) / n_pairs
    return density


def detect_regimes(
    density: pd.Series,
    smooth_window: int = 5,
    enter_threshold: float = 0.65,
    exit_threshold: float = 0.45,
) -> pd.DataFrame:
    """Hysteresis (Schmitt-trigger) regime state machine on smoothed density.

    The market is FUSED once smoothed density reaches ``enter_threshold`` an
자주 묻는 질문

강한 연동이 위험에 무엇을 뜻하나요?

자산들이 함께 움직이면 분산 효과가 약해지므로, 이 스킬로 노출 수준을 조정할 수 있습니다.

원인이 불분명하다고 말할 수 있나요?

네. 판단은 원인 확정, 거시 요인 주도, 모호함, 근거 부족에 따른 판단 보류 중 하나로 표시될 수 있습니다.

미래 시점의 데이터를 참조하나요?

아닙니다. 평활화는 인과적이므로 각 시점에 이미 알 수 있었던 정보만 사용합니다.

상세 정보

작성자의 원본 설명

Correlation-regime detection and crisis attribution — edge-density regime states with hysteresis, causal (no look-ahead) smoothing, regime-aware exposure context, first-mover crisis attribution with honest NAME / MACRO / AMBIGUOUS / ABSTAIN verdicts, and a correlation-rewiring leaderboard that catches slow bleed-outs

repo: HKUDS/Vibe-Trading

인기도

GitHub 스타
37k
순위
#7506
라이선스
MIT
업데이트
2026. 11. 1.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬