Coverage for src/cvx/risk/portfolio/__init__.py: 100%
1 statements
« prev ^ index » next coverage.py v7.14.1, created at 2026-07-22 10:34 +0000
« prev ^ index » next coverage.py v7.14.1, created at 2026-07-22 10:34 +0000
1"""Portfolio optimization models.
3This subpackage provides functions for creating portfolio optimization problems
4using various risk models. Problems are solved directly with the Clarabel solver.
6Example:
7 >>> import numpy as np
8 >>> from cvx.risk.sample import SampleCovariance
9 >>> from cvx.risk.portfolio import minrisk_problem
10 >>> from cvx.core.variable import Variable
11 >>> model = SampleCovariance(num=3)
12 >>> model.update(
13 ... cov=np.eye(3),
14 ... lower_assets=np.zeros(3),
15 ... upper_assets=np.ones(3)
16 ... )
17 >>> weights = Variable(3)
18 >>> problem = minrisk_problem(model, weights)
19 >>> problem.solve()
20 >>> bool(abs(sum(weights.value) - 1.0) < 1e-5)
21 True
23Functions:
24 minrisk_problem: Create a minimum-risk portfolio optimization problem
26"""
27# Copyright (c) 2025 Jebel Quant Research
28#
29# Licensed under the MIT License. See the LICENSE file in the project root
30# for the full license text.
32from .min_risk import minrisk_problem as minrisk_problem