xiaohongshu
xiaohongshu
change-point-detection
Use when segmenting time-series into regimes, detecting structural breaks, or constructing context sets for few-shot learning. Covers GP-CPD algorithms, Matérn kernels, likelihood ratio tests, regime identification, market state transitions, volatility regime changes, and trend reversals in finan...
Full skill instructions
Comprehensive guide for detecting regime changes in financial time-series using Gaussian Process change-point detection (GP-CPD), essential for segmenting markets into stationary periods and improving trading strategies.
Activate this skill when:
A regime change (or change-point) is a point in time where the statistical properties of a time-series shift significantly.
Examples in Finance:
Why Detect Them?
A Gaussian Process defines a distribution over functions:
# GP is fully specified by mean and covariance functions
y ~ GP(μ(x), k(x, x'))
where:
- μ(x): mean function (often 0)
- k(x, x'): covariance (kernel) function
Matérn 3/2 Kernel (recommended for financial data):
k(r) = σ² * (1 + √3*r/ℓ) * exp(-√3*r/ℓ)
where:
- r = |x1 - x2|
- ℓ: length_scale (how quickly correlation decays)
- σ²: variance (overall scale)
Properties:
See IMPLEMENTATION.md for kernel implementations.
The Change-Point (CP) kernel models a transition between two GPs:
k_CP(x1, x2) = σ(x1) * σ(x2) * k1(x1, x2)
+ (1-σ(x1)) * (1-σ(x2)) * k2(x1, x2)
where σ(x) = sigmoid((x - t_cp) / sigma) is transition function
Key Insight:
See IMPLEMENTATION.md for code.
Compare two models:
Detection Steps:
severity = L_C / (L_M + L_C)severity ≥ threshold, declare change-pointSeverity Interpretation:
severity = 0.5: No evidence for change-point (models equally good)severity = 0.9: Strong evidence for change-pointseverity = 0.95: Very strong evidence for change-pointSee IMPLEMENTATION.md for full algorithm.
Recursively apply GP-CPD to segment entire time-series:
Process:
Constraints:
min_length: Minimum regime length (typically 5 days)max_length: Maximum regime length (21 or 63 days)See IMPLEMENTATION.md for implementation.
Create high-quality context sets for few-shot learning:
Strategy:
Performance Impact (from X-Trend paper):
Why It Works:
See IMPLEMENTATION.md for code.
lookback_window (ℓ_lbw):
- 21 days (1 month): Good balance of speed and robustness
- 63 days (3 months): More robust but slower detection
- Trade-off: Shorter = faster detection, Longer = less noise
threshold (ν):
- 0.90: Detect most regime changes (more sensitive)
- 0.95: Detect only strong regime changes (more specific)
- 0.99: Very conservative (few, strong changes only)
Recommendation:
- For max_length = 21: Use ν = 0.90
- For max_length = 63: Use ν = 0.95
min_length = 5: # Minimum 5 days for meaningful regime
max_length = 21 or 63:
- 21 (1-month): Shorter, more granular regimes
- 63 (3-month): Longer, more stable regimes
from sklearn.gaussian_process import GaussianProcessRegressor
from sklearn.gaussian_process.kernels import Matern
class FinancialCPD:
def __init__(self, lookback=21, threshold=0.9):
self.lookback = lookback
self.threshold = threshold
def detect_changepoint(self, prices):
"""Detect change-point in price window."""
gp_m, L_M = self.fit_matern_gp(prices)
t_cp, L_C = self.fit_changepoint_gp(prices)
severity = L_C / (L_M + L_C)
if severity >= self.threshold:
return t_cp, severity
else:
return None, severity
def segment(self, prices, min_len=5, max_len=63):
"""Segment entire time-series into regimes."""
# See IMPLEMENTATION.md for full code
See IMPLEMENTATION.md for complete implementation.
def visualize_regimes(prices, regimes):
"""Plot time-series with colored regime segments."""
# See IMPLEMENTATION.md for full visualization code
See IMPLEMENTATION.md for plotting code.
Identify regime changes that cause momentum losses:
See IMPLEMENTATION.md for implementation.
Choose trading strategy based on current regime characteristics:
See IMPLEMENTATION.md for code.
✅ Use Matérn 3/2 kernel for financial data (better than RBF or OU) ✅ Set reasonable lookback (21 days is good default) ✅ Enforce min/max lengths to avoid trivial or excessive regimes ✅ Validate on multiple assets to tune threshold ✅ Move past change-point to avoid corrupting next regime's representation ✅ Use for context construction in few-shot learning
❌ Don't use RBF kernel - too smooth for financial data ❌ Don't set lookback too small - noisy detections ❌ Don't set lookback too large - delayed detection ❌ Don't ignore severity - it indicates confidence ❌ Don't allow overlapping regimes - each point in one regime only
Based on X-Trend paper results:
Few-Shot Learning:
Why It Works:
When implementing GP-CPD:
L_C / (L_M + L_C)few-shot-learning-finance - Using CPD for context constructionfinancial-time-series - Returns and momentum factors to analyzex-trend-architecture - Attending over regime segmentsLast Updated: Based on X-Trend paper (March 2024) Skill Type: Domain Knowledge + Implementation Line Count: ~290 (under 500-line rule ✅)
xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience