quant-statistics
Qué hace
Esta skill explica y aplica pruebas estadísticas que sirven para comprobar la investigación de trading y de factores. Está pensada para analistas cuantitativos que necesitan resultados fiables.
Cuándo usarla
- ✓Cuando quieres comprobar si una serie de precios es estacionaria antes de probar una estrategia.
- ✓Cuando necesitas comprobar si dos activos se mueven juntos a lo largo del tiempo.
- ✓Cuando quieres modelar la volatilidad o revisar una regresión en busca de problemas estadísticos.
Link de la skill
https://github.com/HKUDS/Vibe-Trading/blob/main/agent/src/skills/quant-statistics/SKILL.mdCópialo y pégalo en tu IA (Claude, ChatGPT o Cursor) pidiéndole que siga las instrucciones.
Cómo usar
La forma más fácil: copia el mensaje y pégalo en tu IA. Ella lee la skill y sigue las instrucciones.
Mensaje listo para pegar
Para Claude Code, Codex o Cursor: ejecútalo en la carpeta del proyecto y la skill queda instalada.
Descarga el SKILL.md y ponlo en la carpeta de skills de tu agente.
Ejemplo de qué pedirle a la IA
“Comprueba si estas dos series de precios de acciones están cointegradas antes de construir una estrategia por pares.”
5 skills nuevas por semana. 1 minuto de lectura.
Cómo funciona
Usa funciones ya hechas para pruebas como ADF, cointegración, GARCH y bootstrap, en lugar de reescribir las fórmulas. Si falta una librería necesaria, indica cuál instalar.
Contenido técnico (SKILL.md original)
Texto original del autor, en inglés, directo de GitHub.
Quantitative Statistical Methods
Overview
Common statistical methodology used in quantitative investing, covering time-series testing, volatility modeling, regression diagnostics, and statistical inference. Provides the statistical foundation for strategy development and factor research.
Implementation
Every test below is already implemented and unit-tested in src.quantlib.timeseries. Import and call it — do not retype these formulas into throwaway code, which is how sign errors and double-sqrt bugs get into results.
from src.quantlib.timeseries import (
adf_test, cointegration_test, find_hedge_ratio, compute_half_life,
granger_test, fit_garch, heteroscedasticity_test, autocorrelation_test,
vif_test, bootstrap_statistic, bootstrap_sharpe,
)
Optional backends: statsmodels powers everything except the two bootstrap helpers (which are pure numpy); arch powers fit_garch only. Neither is declared as a dependency of vibe-trading-ai, so both are imported lazily inside the functions. Importing the module always works; calling a function whose backend is missing raises an ImportError naming the package and the install command (pip install "statsmodels>=0.14" / pip install "arch>=6.0"). If you hit that error, report it to the user rather than silently substituting a different method.
Time-Series Tests
1. ADF Unit-Root Test (Stationarity Test)
Why it matters: regressing non-stationary series directly can produce spurious regression, making conclusions unreliable.
from src.quantlib.timeseries import adf_test
result = adf_test(prices['close'], significance=0.05)
# {'adf_statistic': -1.23, 'p_value': 0.65, 'lags_used': 4,
# 'is_stationary': False,
# 'critical_values': {'1%': -3.44, '5%': -2.87, '10%': -2.57}}
if not result['is_stationary']:
returns = np.log(prices['close']).diff().dropna()
adf_test(returns) # log returns are normally stationary
Decision rules:
| p-value | Conclusion | Action |
|---|---|---|
| < 0.01 | Strongly stationary | Can be used directly for regression / modeling |
| 0.01-0.05 | Stationary | Usable |
| 0.05-0.10 | Weak evidence | Difference the series and retest |
| > 0.10 | Non-stationary | Must difference or handle with cointegration |
Stationarity of common financial series:
| Series | Typical Result | Treatment |
|---|---|---|
| Price series | Non-stationary (unit root) | Use log returns |
| Log returns | Stationary | Can be used directly |
| PE / PB series | Usually non-stationary | Use changes or logs |
| Volatility series | Usually stationary | Can be used directly |
| Volume | May be non-stationary | Use logs or standardization |
2. Cointegration Test
Purpose: determine whether two non-stationary series share a long-run equilibrium relationship (the foundation of pair trading / statistical arbitrage).
from src.quantlib.timeseries import cointegration_test
result = cointegration_test(prices_a, prices_b, significance=0.05)
# {'test_statistic': -4.52, 'p_value': 0.002, 'is_cointegrated': True,
# 'critical_values': {'1%': -3.90, '5%': -3.34, '10%': -3.05}}
Both legs must be individually non-stationary (check with adf_test first) — cointegration on two already-stationary series is meaningless.
Both legs must also share one index. Two same-length series on different indices raise ValueError rather than being zipped positionally, because a positional join of, say, an A-share calendar against a US one reports cointegration between days that never coexisted. Reindex or inner-join the two legs yourself before calling.
Application in pair trading:
from src.quantlib.timeseries import find_hedge_ratio, compute_half_life
result = find_hedge_ratio(prices_a, prices_b)
# {'hedge_ratio': 2.49, 'intercept': 0.40,
# 'spread_mean': 0.40, 'spread_std': 1.73, 'half_life': 16.7}
spread = prices_a - result['hedge_ratio'] * prices_b
z_score = (spread - result['spread_mean']) / result['spread_std']
# half_life is in observation periods (days for daily bars) and is `inf`
# when the spread does not mean-revert. Sanity-check it before trading:
# a half-life longer than your holding horizon means the spread will not
# close in time, however good the cointegration p-value looks.
compute_half_life(spread)
A perfectly flat leg (a name halted for the whole window) makes the regression
degenerate, so find_hedge_ratio and `compute_half_l
Preguntas frecuentes
¿Qué es la cointegración?
Significa que dos series de precios se mueven juntas a lo largo del tiempo, aunque cada una vague por su cuenta.
¿Necesito librerías extra?
Algunas pruebas necesitan statsmodels, y GARCH necesita el paquete arch. La skill te indica cuál instalar.
¿Qué comprueba la prueba ADF?
Comprueba si una serie es estacionaria, es decir, si tiende a volver a una media estable.
Detalles
Descripción original del autor
Quantitative statistical methods: ADF unit-root / cointegration tests, GARCH volatility modeling, regression diagnostics (heteroskedasticity / autocorrelation), Bootstrap, and hypothesis testing.
repo: HKUDS/Vibe-Trading
Popularidad
- Estrellas en GitHub
- 37 mil
- Posición en el ranking
- #7545
- Licencia
- MIT
- Actualizada
- 1/11/2026
Comentarios
- …
Más skills de este repositorio
vibe-trading
37 milDa a tu agente un kit completo de investigación financiera, con backtests, análisis de factores, precios de opciones y datos de mercado de muchos mercados.
adr-hshare
37 milMuestra a tu agente cómo comparar el precio de una empresa china que cotiza en varios mercados, como un ADR estadounidense y una acción de Hong Kong.
akshare
37 milPermite a tu agente obtener datos de mercado gratuitos de acciones chinas y globales, futuros, divisas e indicadores económicos, sin necesidad de clave de API.
alpha-zoo
37 milPermite a tu agente explorar una biblioteca de factores bursátiles ya hechos y probar qué tan bien predice el rendimiento un conjunto completo de ellos en un mercado elegido.
Skills parecidas
gitcrawl
394 milPermite que tu agente busque en un archivo guardado de incidencias y pull requests de GitHub, agrupe duplicados y revise su estado actual en GitHub.
slacrawl
394 milPermite que tu agente busque y cuente mensajes en un archivo local de Slack, revise qué tan reciente es y lo actualice cuando haga falta.
goplaces
394 milAyuda a tu agente a buscar lugares, obtener sus detalles y reseñas, y resolver nombres de lugares usando Google Places, con salida JSON para scripts.