Loading...
Loading...
Compare original and translation side by side
Response language: match the user's input language — Simplified Chinese / Traditional Chinese / English.
响应语言:匹配用户输入语言——简体中文 / 繁体中文 / 英文。
longbridge-factor-researchlongbridge-pairs-tradinglongbridge-factor-researchlongbridge-pairs-tradingpip install statsmodels scipy numpy pandaspip install statsmodels scipy numpy pandaslongbridge kline --help
longbridge kline <SYMBOL> --period day --count 252 --format jsoncloser_t = ln(P_t / P_{t-1})longbridge 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')from statsmodels.tsa.stattools import adfuller
result = adfuller(series, autolag='AIC')
**Interpretation**:
- p < 0.05 → reject unit root → series is stationary.
- p ≥ 0.05 → fail to reject → series has unit root → difference the series.
- Log prices: usually non-stationary. Log returns: usually stationary.
**结果解读**:
- p < 0.05 → 拒绝单位根假设 → 序列平稳。
- p ≥ 0.05 → 无法拒绝假设 → 序列存在单位根 → 需对序列进行差分处理。
- 对数价格:通常非平稳。对数收益率:通常平稳。from statsmodels.tsa.stattools import coint
t_stat, p_value, critical_values = coint(series_A, series_B)from statsmodels.tsa.stattools import coint
t_stat, p_value, critical_values = coint(series_A, series_B)
**Johansen (multivariate)**:
```python
from statsmodels.tsa.vector_ar.vecm import coint_johansen
result = coint_johansen(df, det_order=0, k_ar_diff=1)
**Johansen法(多变量)**:
```python
from statsmodels.tsa.vector_ar.vecm import coint_johansen
result = coint_johansen(df, det_order=0, k_ar_diff=1)
Report: test statistic, p-value, critical values, and cointegrating vector.
输出内容:检验统计量、p值、临界值以及协整向量。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)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 | |
statsmodels.api.OLS| 检验方法 | 用途 | 命令 |
|---|---|---|
| Durbin-Watson | 检验残差的序列自相关性 | |
| Breusch-Pagan | 检验异方差性 | |
| Jarque-Bera | 检验残差的正态性 | |
| VIF | 检验多重共线性 | |
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, hiimport 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, hiundefinedundefined| 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 | |
| 检验方法 | 适用场景 | 函数 |
|---|---|---|
| 单样本t检验 | 因子IC均值是否>0? | |
| 双样本t检验 | 多头组合收益率是否>空头组合? | |
| F检验/方差分析 | 不同分位数组合的收益率是否存在差异? | |
| Mann-Whitney U检验 | t检验的非参数替代方法 | |
longbridge kline --help
longbridge kline <SYMBOL> --period day --count 252 --format jsonlongbridge 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 |
| 场景 | 简体回复 | 繁体回覆 | English reply |
|---|---|---|---|
| 请安装 longbridge-terminal 或检查 MCP 配置。 | 請安裝 longbridge-terminal 或檢查 MCP 配置。 | Install longbridge-terminal or check MCP config. |
| 请运行 | 請執行 | Run |
| 数据不足(<30个观测值) | 样本量过小,统计结论可靠性有限,建议延长数据期。 | 樣本量過小,建議延長數據期。 | Sample too small; extend the data period for reliable results. |
| GARCH所需ARCH模块缺失 | 请运行 | 請執行 | Run |
longbridge-factor-researchlongbridge-pairs-tradinglongbridge-correlationlongbridge-volatility-strategylongbridge-factor-researchlongbridge-pairs-tradinglongbridge-correlationlongbridge-volatility-strategyskills/longbridge-quant-stats/
└── SKILL.mdskills/longbridge-quant-stats/
└── SKILL.md