correlation-regime
Skill này làm gì
Skill này theo dõi sự thay đổi trong mức độ các tài sản chuyển động cùng nhau theo thời gian, và tìm tài sản dẫn đầu trong một đợt bán tháo đột ngột. Skill dành cho người quản lý rủi ro và trader muốn biết khi nào đa dạng hóa đang thất bại.
Khi nào nên dùng
- ✓Khi bạn muốn biết thị trường đã chuyển sang trạng thái tương quan cao hay chưa.
- ✓Khi bạn muốn biết tài sản nào di chuyển đầu tiên trong khủng hoảng hoặc đợt giảm đột ngột.
- ✓Khi bạn muốn phát hiện các tài sản có quan hệ với thị trường đã thay đổi âm thầm.
Liên kết skill
https://github.com/HKUDS/Vibe-Trading/blob/main/agent/src/skills/correlation-regime/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Gần đây thị trường crypto có chuyển sang trạng thái tương quan cao không, và có tài sản nào dẫn đầu đợt bán tháo gần đây không?”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Agent theo dõi mức độ kết nối giữa các tài sản theo thời gian, đánh dấu các trạng thái bằng phương pháp trễ (hysteresis) để tránh đổi trạng thái liên tục. Sau đó nó xem các tài sản dẫn đầu trong khủng hoảng và gắn nhãn độ tin cậy cho từng kết luận, kể cả khi nguyên nhân chưa rõ.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
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:
- When did the market fuse into one highly-correlated bloc, and when did it release? (Mode 1 — regime detection)
- What does a fused regime mean for position sizing? (Mode 2 — risk context)
- Who moved first when a crisis broke — is there a nameable trigger asset? (Mode 3 — first-mover attribution)
- 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
Câu hỏi thường gặp
Tương quan cao nghĩa là gì đối với rủi ro?
Khi các tài sản cùng chuyển động, đa dạng hóa yếu đi, nên skill có thể giúp bạn điều chỉnh mức độ phơi nhiễm.
Skill có thể nói nguyên nhân chưa rõ không?
Có. Kết luận có thể là đã xác định, do vĩ mô, chưa rõ ràng, hoặc không đưa ra kết luận khi bằng chứng chưa đủ mạnh.
Skill có nhìn trước về thời gian không?
Không. Phép làm mượt chỉ dùng thông tin đã có tại mỗi thời điểm.
Chi tiết
Mô tả gốc của tác giả
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
Độ phổ biến
- Sao GitHub
- 37k
- Vị trí xếp hạng
- #7506
- Giấy phép
- MIT
- Cập nhật
- 1/11/2026
Bình luận
- …
Thêm skill từ kho mã này
vibe-trading
37kCho agent của bạn bộ công cụ nghiên cứu tài chính đầy đủ: backtest, phân tích nhân tố, định giá quyền chọn và dữ liệu thị trường nhiều nước.
adr-hshare
37kChỉ cho agent của bạn cách so sánh giá của một công ty Trung Quốc được niêm yết ở nhiều thị trường, như ADR ở Mỹ và cổ phiếu ở Hồng Kông.
akshare
37kCho agent của bạn lấy dữ liệu thị trường miễn phí: cổ phiếu Trung Quốc và toàn cầu, tương lai, ngoại hối, chỉ số kinh tế, không cần API key.
alpha-zoo
37kCho agent của bạn duyệt thư viện nhân tố cổ phiếu dựng sẵn và kiểm tra cả một nhóm nhân tố dự đoán lợi nhuận tốt đến đâu trên thị trường đã chọn.
Skill tương tự
gitcrawl
394kCho phép agent của bạn tìm trong kho lưu trữ issue và pull request GitHub, gom các mục trùng lặp và kiểm tra trạng thái hiện tại trên GitHub.
slacrawl
394kCho phép agent của bạn tìm và đếm tin nhắn trong kho lưu trữ Slack cục bộ, kiểm tra kho đó mới đến mức nào và làm mới khi cần.
goplaces
394kGiúp agent của bạn tìm địa điểm, lấy chi tiết và đánh giá, và xác định tên địa điểm bằng Google Places, với đầu ra JSON cho script.