Coverage for src/cvx/risk/cvar/__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"""Conditional Value at Risk (CVaR) models for portfolio optimization.
3This subpackage provides the CVar class for CVaR-based risk estimation.
4CVaR, also known as Expected Shortfall, measures the expected loss in the
5tail of the return distribution.
7Example:
8 >>> import numpy as np
9 >>> from cvx.risk.cvar import CVar
10 >>> # Create CVaR model
11 >>> model = CVar(alpha=0.95, n=100, m=5)
12 >>> # Update with historical returns
13 >>> np.random.seed(42)
14 >>> returns = np.random.randn(100, 5)
15 >>> model.update(
16 ... returns=returns,
17 ... lower_assets=np.zeros(5),
18 ... upper_assets=np.ones(5)
19 ... )
20 >>> w = np.ones(5) / 5
21 >>> cvar = model.estimate(w)
22 >>> isinstance(cvar, float)
23 True
25"""
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.
31from .cvar import CVar as CVar