组合选择比较
原能力
用一致的期限和约束比较配置备选,标出互有优劣或暂不可比的选择。(细化版 p.16–17)
首选项目
PyPortfolioOpt(MIT)。 PyPortfolioOpt
匹配范围
EfficientFrontier/CVaR 与约束求解形成候选对照。
源码
PyPortfolioOpt · def efficient_risk(
pypfopt/efficient_frontier/efficient_cvar.py · 201–214 行。 在 GitHub 查看源码 · 许可证与声明
源码片段
def efficient_risk(self, target_cvar, market_neutral=False):
"""
Maximise return for a target CVaR.
The resulting portfolio will have a CVaR less than the target
(but not guaranteed to be equal).
Parameters
----------
target_cvar : float
the desired conditional value at risk of the resulting portfolio.
market_neutral : bool, optional
whether the portfolio should be market neutral (weights sum to zero),
defaults to False. Requires negative lower weight bound.
CVXPY · class Problem
cvxpy/problems/problem.py · 135–148 行。 在 GitHub 查看源码 · 许可证与声明
源码片段
class Problem(u.Canonical):
"""A convex optimization problem.
Problems are immutable, save for modification through the specification
of :class:`~cvxpy.expressions.constants.parameters.Parameter`
Arguments
---------
objective : Minimize or Maximize
The problem's objective.
constraints : iterable
The constraints on the problem variables.
"""
- Copyright 2013 Steven Diamond, 2017 Akshay Agrawal
接口用法示意
portfolio = EfficientCVaR(expected_returns, returns); portfolio.efficient_risk(target_cvar)
实现与验收要点
保留不可比和硬约束、账户目标、真实行情。