Loading...
Loading...
Quantitative statistics framework for time-series analysis using Longbridge price data — ADF unit root test (stationarity), cointegration (Engle-Granger / Johansen), GARCH volatility modelling (conditional heteroskedasticity), regression diagnostics (Durbin-Watson / Breusch-Pagan), bootstrap confidence intervals, hypothesis tests (t-test / F-test). Requires statsmodels and scipy. Triggers: "量化统计", "ADF检验", "单位根", "协整检验", "GARCH", "自相关", "异方差", "Bootstrap", "假设检验", "量化統計", "ADF檢驗", "單位根", "協整檢驗", "異方差", "假設檢驗", "quantitative statistics", "ADF test", "unit root", "cointegration", "GARCH", "autocorrelation", "heteroskedasticity", "bootstrap", "hypothesis test", "statsmodels".
npx skill4agent add longbridge/skills longbridge-quant-statsResponse language: match the user's input language — Simplified Chinese / Traditional Chinese / English.
longbridge-factor-researchlongbridge-pairs-tradingpip install statsmodels scipy numpy pandaslongbridge kline --help
longbridge kline <SYMBOL> --period day --count 252 --format jsoncloser_t = ln(P_t / P_{t-1})from statsmodels.tsa.stattools import adfuller
result = adfuller(series, autolag='AIC')
# result: (adf_stat, p_value, lags, n_obs, critical_values, icbest)from statsmodels.tsa.stattools import coint
t_stat, p_value, critical_values = coint(series_A, series_B)
# p < 0.05 → cointegratedfrom statsmodels.tsa.vector_ar.vecm import coint_johansen
result = coint_johansen(df, det_order=0, k_ar_diff=1)
# trace statistic vs critical values at 90%/95%/99%from arch import arch_model
model = arch_model(returns * 100, vol='Garch', p=1, q=1)
res = model.fit(disp='off')
print(res.summary())pip install archfrom statsmodels.stats.diagnostic import het_arch
lm_stat, p_value, f_stat, f_p = het_arch(residuals)statsmodels.api.OLS| Test | Purpose | Command |
|---|---|---|
| Durbin-Watson | Serial autocorrelation in residuals | |
| Breusch-Pagan | Heteroskedasticity | |
| Jarque-Bera | Normality of residuals | |
| VIF | Multicollinearity | |
import numpy as np
def bootstrap_ci(data, stat_fn, n_boot=10000, ci=0.95):
boots = [stat_fn(np.random.choice(data, len(data), replace=True))
for _ in range(n_boot)]
lo = np.percentile(boots, (1 - ci) / 2 * 100)
hi = np.percentile(boots, (1 + ci) / 2 * 100)
return lo, hi
# Example: Sharpe ratio CI
sharpe_lo, sharpe_hi = bootstrap_ci(returns, lambda x: x.mean() / x.std() * np.sqrt(252))| Test | Use case | Function |
|---|---|---|
| t-test (one sample) | Is mean IC > 0? | |
| t-test (two sample) | Is long portfolio return > short portfolio? | |
| F-test / ANOVA | Are returns different across deciles? | |
| Mann-Whitney U | Non-parametric alternative to t-test | |
longbridge kline --help
longbridge kline <SYMBOL> --period day --count 252 --format json| Situation | 简体回复 | 繁體回覆 | English reply |
|---|---|---|---|
| 请安装 longbridge-terminal 或检查 MCP 配置。 | 請安裝 longbridge-terminal 或檢查 MCP 配置。 | Install longbridge-terminal or check MCP config. |
| 请运行 | 請執行 | Run |
| Insufficient data (< 30 observations) | 样本量过小,统计结论可靠性有限,建议延长数据期。 | 樣本量過小,建議延長數據期。 | Sample too small; extend the data period for reliable results. |
| ARCH module missing for GARCH | 请运行 | 請執行 | Run |
longbridge-factor-researchlongbridge-pairs-tradinglongbridge-correlationlongbridge-volatility-strategyskills/longbridge-quant-stats/
└── SKILL.md