npx claudepluginhub brainbytes-dev/everything-claude-tradingThis skill uses the workspace's default tool permissions.
name: time-series-analysis
Provides Ktor server patterns for routing DSL, plugins (auth, CORS, serialization), Koin DI, WebSockets, services, and testApplication testing.
Conducts multi-source web research with firecrawl and exa MCPs: searches, scrapes pages, synthesizes cited reports. For deep dives, competitive analysis, tech evaluations, or due diligence.
Provides demand forecasting, safety stock optimization, replenishment planning, and promotional lift estimation for multi-location retailers managing 300-800 SKUs.
name: time-series-analysis description: Time series analysis for financial data — ARIMA, GARCH, cointegration, stationarity. Use when modeling financial time series.
Most statistical models require stationarity. Financial prices are non-stationary (unit root); returns are generally stationary.
Augmented Dickey-Fuller (ADF) test:
KPSS test:
Achieving stationarity:
ARIMA(p, d, q): AutoRegressive Integrated Moving Average
Step 1: Plot the series. Visual inspection for trends, seasonality, breaks.
Step 2: Test stationarity (ADF, KPSS). Difference if needed (d = 0 or 1).
Step 3: Examine ACF/PACF of stationary series to identify p (AR order) and q (MA order).
Step 4: Fit candidate models. Use AIC/BIC for model selection.
Step 5: Diagnostic checks:
- Ljung-Box test on residuals (H0: no autocorrelation, want p > 0.05)
- Normality test on residuals (Jarque-Bera)
- Plot residual ACF — should be white noise
Step 6: Forecast with confidence intervals.
Practical note: ARIMA rarely produces profitable trading signals on raw returns due to low signal-to-noise ratio. More useful for modeling spreads, basis, or macro variables.
Volatility clustering is the dominant stylized fact of financial returns: large moves follow large moves.
GARCH(1,1):
sigma_t^2 = omega + alpha * epsilon_{t-1}^2 + beta * sigma_{t-1}^2
alpha: reaction to recent shock (typically 0.05-0.15)
beta: persistence of volatility (typically 0.80-0.95)
alpha + beta < 1: covariance stationarity required
alpha + beta close to 1: high persistence (near-IGARCH)
EGARCH (Exponential GARCH):
GJR-GARCH (Glosten-Jagannathan-Runkle):
Model selection guidance:
Two non-stationary series are cointegrated if a linear combination is stationary. Critical for pairs trading and spread modeling.
Engle-Granger two-step method:
Step 1: Regress y1_t = alpha + beta * y2_t + epsilon_t (OLS)
Step 2: Test residuals epsilon_t for stationarity (ADF test)
Use Engle-Granger critical values (NOT standard ADF critical values)
Step 3: If residuals are stationary, series are cointegrated
Step 4: Beta is the hedge ratio; epsilon_t is the spread
Johansen method (preferred for multiple series):
Financial time series often contain regime changes that invalidate models estimated on full samples.
Chow test: Tests for a break at a known date. Compare unrestricted model (separate regressions before/after) vs restricted (single regression).
Bai-Perron test: Detects multiple unknown break dates. Estimates break locations and confidence intervals. Essential for understanding when relationships change.
CUSUM test: Monitors cumulative sum of recursive residuals. Detects gradual structural change.
Series: [Asset/Spread Name]
Frequency: Daily | Period: 2010-01-01 to 2024-12-31 | N = 3,780
--- Stationarity ---
ADF Statistic: -2.85 (p = 0.051) [Borderline]
KPSS Statistic: 0.42 (p = 0.08) [Borderline]
Action: First-difference (log returns)
Post-diff ADF: -42.1 (p < 0.001) [Stationary]
--- Autocorrelation (Returns) ---
Lag 1 ACF: -0.03 (not significant)
Ljung-Box(10): p = 0.32 (no serial correlation)
--- Autocorrelation (Squared Returns) ---
Lag 1 ACF: 0.18 (significant)
Ljung-Box(10): p < 0.001 (volatility clustering present)
--- GARCH(1,1) Fit ---
omega: 0.000003 alpha: 0.08 beta: 0.90
Persistence (a+b): 0.98
Half-life of vol shock: 34 days
AIC: -18,452
--- Residual Diagnostics ---
Ljung-Box(10) on std residuals: p = 0.45 (adequate)
Jarque-Bera on std residuals: p < 0.001 (fat tails remain)
Recommendation: Use Student-t innovations for better tail fit
Pair: [Asset A] vs [Asset B]
Period: [Start] to [End]
Engle-Granger:
Hedge ratio (beta): 1.32
ADF on residuals: -3.85 (p = 0.003) [Cointegrated]
Half-life of spread: 14 days
Johansen (Trace):
r=0: stat=22.4, cv(5%)=15.5 [Reject: at least 1 cointegrating vector]
r=1: stat=3.1, cv(5%)=3.8 [Fail to reject: exactly 1 vector]
Spread stationarity confirmed. Proceed with mean-reversion strategy.
Before deploying a time series model in production: