Coverage for src / cvx / risk / portfolio / __init__.py: 100%

1 statements  

« prev     ^ index     » next       coverage.py v7.13.0, created at 2025-12-15 12:21 +0000

1"""Portfolio optimization models. 

2 

3This subpackage provides functions for creating portfolio optimization problems 

4using various risk models. 

5 

6Example: 

7 >>> import cvxpy as cp 

8 >>> import numpy as np 

9 >>> from cvx.risk.sample import SampleCovariance 

10 >>> from cvx.risk.portfolio import minrisk_problem 

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 = cp.Variable(3) 

18 >>> problem = minrisk_problem(model, weights) 

19 >>> problem.is_dcp() 

20 True 

21 

22Functions: 

23 minrisk_problem: Create a minimum-risk portfolio optimization problem 

24 

25""" 

26# Copyright 2023 Stanford University Convex Optimization Group 

27# 

28# Licensed under the Apache License, Version 2.0 (the "License"); 

29# you may not use this file except in compliance with the License. 

30# You may obtain a copy of the License at 

31# 

32# http://www.apache.org/licenses/LICENSE-2.0 

33# 

34# Unless required by applicable law or agreed to in writing, software 

35# distributed under the License is distributed on an "AS IS" BASIS, 

36# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 

37# See the License for the specific language governing permissions and 

38# limitations under the License. 

39 

40from .min_risk import minrisk_problem as minrisk_problem # noqa: F401