风险测量的目标与期限
原能力
按投资目标和期限测量组合风险,保留压力情景及退出限制。(合同附件 R7 14.2)
首选项目
Empyrical(Apache-2.0)。 Empyrical
匹配范围
波动、回撤、尾部风险计算模块。
源码
Empyrical · def annual_volatility(
empyrical/stats.py · 487–500 行。 在 GitHub 查看源码 · 许可证与声明
源码片段
def annual_volatility(returns,
period=DAILY,
alpha=2.0,
annualization=None,
out=None):
"""
Determines the annual volatility of a strategy.
Parameters
----------
returns : pd.Series or np.ndarray
Periodic returns of the strategy, noncumulative.
- See full explanation in :func:`~empyrical.stats.cum_returns`.
period : str, optional
- # Copyright 2016 Quantopian, Inc.
Empyrical · def max_drawdown(
empyrical/stats.py · 352–365 行。 在 GitHub 查看源码 · 许可证与声明
源码片段
def max_drawdown(returns, out=None):
"""
Determines the maximum drawdown of a strategy.
Parameters
----------
returns : pd.Series or np.ndarray
Daily returns of the strategy, noncumulative.
- See full explanation in :func:`~empyrical.stats.cum_returns`.
out : array-like, optional
Array to use as output buffer.
If not passed, a new array will be created.
Returns
- # Copyright 2016 Quantopian, Inc.
PyPortfolioOpt · class EfficientCVaR
pypfopt/efficient_frontier/efficient_cvar.py · 15–28 行。 在 GitHub 查看源码 · 许可证与声明
源码片段
class EfficientCVaR(EfficientFrontier):
"""
The EfficientCVaR class allows for optimization along the mean-CVaR frontier, using the
formulation of Rockafellar and Ursayev (2001).
Instance variables:
- Inputs:
- ``n_assets`` - int
- ``tickers`` - str list
- ``bounds`` - float tuple OR (float tuple) list
- ``returns`` - pd.DataFrame
- ``expected_returns`` - np.ndarray
实现与验收要点
定义风险目标、持有期限、估计窗口和独立验证。