quantlab

QuantLab: A quantitative research and computational toolkit covering option pricing, portfolio optimization, GARCH volatility modeling, and yield curve analysis.

Installation

Review the source and dependencies with a prompt. A package is available to download.

Install with an AI assistant

Copy the prompt so your assistant can review the pinned revision and dependencies first.

View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "quantlab" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-c8e32138d798b1b5f8a5d23842f0ce6db802aabaeb6926b19182b475b2aea5c5. Verify the upstream source and version against https://skillhub.cn/skills/user_053d27d0/quantlab before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.

Source and setup

skillhub.cn

Setup guidance pending

See the original source for supported tools, dependencies, and permissions.

Installation test pending

QuantLab: A quantitative research and computational toolkit covering option pricing, portfolio optimization, GARCH volatility modeling, and yield curve analysis.

0 Downloads

Introduction source: third_party · user_053d27d0 · 1.0.0 Reference

SkillPi interpretation

Tasks
Translation pending; see source documentation.
Inputs and outputs
Translation pending; see source documentation.
Testing
Not tested

Browse files

Browse files at the source ↗

Original SKILL.md

Open original ↗
Frontmatter
name: quantlab
description: 金融工程工具包,覆盖期权定价(BS/二叉树/Heston/MC)、组合优化(Markowitz/Black-Litterman/Risk Parity)、风险管理(VaR/CVaR/Kupiec回测)、波动率建模(GARCH/GJR/EGARCH)、收益率曲线(bootstrap/Nelson-Siegel),纯 NumPy 实现零外部优化库依赖。触发词:量化金融、期权定价、组合优化、VaR、GARCH、收益率曲线。

QuantLab 金融工程工具包

能力边界

✅ 支持的能力

  • 期权定价:Black-Scholes(含完整手动正态分布函数,零 SciPy 依赖)、Binomial Tree、Heston 随机波动率、Monte Carlo 仿真,全部支持欧式看涨/看跌
  • 投资组合优化:Markowitz 均值-方差有效前沿(KKT 解析解,无需 cvxopt/scipy.optimize)、Black-Litterman 模型(融合主观观点+市场均衡收益)、Risk Parity(等风险贡献)组合
  • 风险管理:Historical VaR / Parametric VaR / Monte Carlo VaR 三种方法论、Conditional VaR (Expected Shortfall)、Kupiec POF 检验 + Christoffersen 独立性检验
  • 波动率建模:GARCH(1,1)、GJR-GARCH(非对称杠杆效应)、EGARCH,MLE 极大似然估计手动梯度下降,零外部优化库依赖
  • 收益率曲线:Bootstrap 票息剥离法、Nelson-Siegel 模型拟合
  • 希腊字母:Delta / Gamma / Vega / Theta / Rho 完整一阶希腊字母
  • 隐含波动率:Newton-Raphson 数值求解

❌ 不支持的能力

  • 美式/亚式/障碍等奇异期权(仅欧式期权)
  • 实时市场数据接入与交易执行
  • 高频数据处理和微观结构分析
  • 因子模型(Fama-French / BARRA)归因
  • 机器学习/深度学习预测模块
  • GUI 或 Web 可视化界面

触发条件

当用户提及以下关键词或意图时,应优先调用本 Skill:

  • "期权定价"、"BS公式"、"二叉树定价"、"Heston模型"、"蒙特卡洛期权"
  • "投资组合优化"、"Markowitz"、"马科维茨"、"有效前沿"、"Black-Litterman"、"Risk Parity"、"风险平价"
  • "VaR计算"、"风险价值"、"CVaR"、"Expected Shortfall"、"风险度量"
  • "GARCH模型"、"波动率建模"、"波动率预测"、"EGARCH"、"GJR-GARCH"
  • "收益率曲线"、"债券收益率"、"Nelson-Siegel"、"bootstrap"
  • "金融工程工具"、"量化工具箱"、"定价库"

使用方法

期权定价

from quantlab.options.black_scholes import black_scholes_price, black_scholes_greeks

price = black_scholes_price(S=100, K=105, T=0.5, r=0.03, sigma=0.2, option_type='call')
greeks = black_scholes_greeks(S=100, K=105, T=0.5, r=0.03, sigma=0.2)

组合优化

from quantlab.portfolio.markowitz import efficient_frontier, min_variance_portfolio

# 有效前沿
returns_grid, risks_grid = efficient_frontier(expected_returns, cov_matrix, n_points=100)

# 最小方差组合
weights = min_variance_portfolio(cov_matrix)

from quantlab.portfolio.black_litterman import black_litterman
weights_bl = black_litterman(market_caps, cov_matrix, risk_aversion, views, view_confidences)

from quantlab.portfolio.risk_parity import risk_parity_weights
weights_rp = risk_parity_weights(cov_matrix)

风险管理

from quantlab.risk.var import historical_var, parametric_var, mc_var, historical_cvar

# 历史 VaR
var_95 = historical_var(returns, alpha=0.05)

# 蒙特卡洛 CVaR
cvar = historical_cvar(returns, alpha=0.05)

波动率建模

from quantlab.volatility.garch import garch_fit, garch_forecast

params = garch_fit(returns)
vol_forecast = garch_forecast(params, returns, horizon=10)

收益率曲线

from quantlab.yield_curve.bootstrap import bootstrap_curve
from quantlab.yield_curve.nelson_siegel import fit_nelson_siegel

spot_rates = bootstrap_curve(bond_prices, bond_coupons, bond_maturities)
params_ns = fit_nelson_siegel(maturities, yields)

输出示例

组合优化输出:

Markowitz Efficient Frontier (N=5 assets):
  Min Variance Portfolio:  Return=6.20%  Risk=12.40%
  Max Sharpe Portfolio:    Return=8.15%  Risk=14.30%  Sharpe=0.57
  Tangency Portfolio:      Return=7.80%  Risk=13.60%

VaR 报告:

95% VaR (Historical):  -2.45%  (Daily)
95% VaR (Parametric):  -2.38%  (Daily)
95% CVaR:              -3.12%  (Daily)
Kupiec POF p-value:     0.342  (Model accepted at 5%)

FAQ

Q: QuantLab 和 option-pricer 有什么区别? A: QuantLab 是更全面的金融工程工具包,覆盖期权定价、组合优化、风险管理、波动率建模、收益率曲线五大领域。option-pricer 专注于期权定价,侧重多模型对比和交互可视化。两者可互补使用。

Q: 组合优化为什么不需要 cvxopt? A: Markowitz 均值-方差优化使用 KKT 条件推导的闭式解析解,直接在 NumPy 中求解线性方程组,避免了依赖外部二次规划求解器。

Q: GARCH 参数估计可靠吗? A: GARCH 模型使用手动实现的 BHHH(Berndt-Hall-Hall-Hausman)类梯度下降算法进行 MLE 极大似然估计,收敛性和稳定性经过充分测试。

Q: Black-Scholes 为什么不依赖 SciPy? A: 正态分布 CDF 和 PDF 使用手动实现的误差函数(erf)逼近公式,精度达 1e-15,完全消除了对 scipy.stats 的依赖,便于轻量级部署。

Q: 支持哪些 Python 版本? A: Python 3.8+,仅依赖 NumPy。部分模块(如 Heston)可选依赖 SciPy 的积分函数。

技术栈

  • 核心依赖: NumPy(唯一强制依赖)
  • 可选依赖: SciPy(Heston 积分 / 高级优化)
  • 实现方式: 纯 NumPy,所有算法手动实现,最小外部依赖
  • 测试框架: pytest
  • 语言: Python 3.8+

Current listing version

1.0.0

Verify the source revision ↗

Safety and assessment details

Quality assessment

Out of 100 · Assessment report from SkillPi LAB.

Scenario Value95/100

Highlights

  • 提供量化金融领域专业工具包,覆盖期权定价、组合优化、风险管理、波动率建模、收益率曲线五大核心领域
  • 解决金融工程高频刚需任务,显著提升专业用户建模与分析效率
  • 纯 NumPy 实现零外部优化库依赖,部署轻量且稳定
Trigger Precision95/100

Highlights

  • 触发词精准完整,覆盖'期权定价'、'Markowitz'、'VaR'、'GARCH'等关键词及多种变体
  • 边界清晰,不易与其他 Skill 重叠或误触
Structure and Standards95/100

Highlights

  • 结构完整清晰,包含能力边界、触发条件、使用方法、输出示例、FAQ、技术栈等模块
  • 提供端到端代码示例,便于用户快速上手
Execution Reliability95/100

Highlights

  • 工具来源明确,参数说明清晰,覆盖主要异常场景
  • 技术实现可靠,使用 KKT 解析解和手动梯度下降,避免外部依赖风险
Evidence Verifiability (mean of the first four)95/100

The arithmetic mean of the first four original scores, rounded to a whole number.

Static text checks

100 / 100 · skillpi-20261123-no-r3-v1

No current rules matched the text.

This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.

Permissions and checks before use

Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.

These common operations were not identified in the main document. This does not mean no permissions or risks exist.

These notices grant no permissions. Your host tool must still confirm file changes, secrets, external transfers or costs as needed.

Security rating and access scope

safe · Static evidence review; not a runtime safety guarantee.

Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.