API Reference¶
The public interface of fast_minimum_variance:
fast_minimum_variance
¶
fast_minimum_variance — fast solvers for the minimum-variance portfolio.
Problem(X, target=None, B=None, c=None, alpha=0.0, rho=0.0, mu=None, target_lr=None, pcg_lr=None)
¶
Create a long-only minimum-variance portfolio optimisation problem.
Returns a :class:_MinVarProblem (shrinking active-set) for the long-only
minimum-variance problem, optionally with a balance system (B, c) in
place of the default budget constraint.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
X
|
ndarray
|
Returns matrix of shape |
required |
target
|
ndarray | None
|
Optional |
None
|
B
|
ndarray | None
|
Balance system |
None
|
c
|
ndarray | None
|
Balance RHS |
None
|
alpha
|
float
|
Shrinkage intensity; only active when |
0.0
|
rho
|
float
|
Return tilt strength (Markowitz mean-variance). |
0.0
|
mu
|
ndarray | None
|
Expected returns vector |
None
|
target_lr
|
tuple[float, ndarray, ndarray] | None
|
Low-rank factored target |
None
|
pcg_lr
|
tuple[float, ndarray, ndarray] | None
|
RMT preconditioner |
None
|
Returns:
| Type | Description |
|---|---|
_MinVarProblem
|
A solver instance with |
_MinVarProblem
|
|
_MinVarProblem
|
|
Examples:
>>> import numpy as np
>>> X = np.random.default_rng(42).standard_normal((500, 20))
>>> w, _ = Problem(X).solve_kkt()
>>> float(round(w.sum(), 8))
1.0
>>> bool((w >= 0).all())
True
A two-sleeve balance system — each half of the universe holds half of the budget:
>>> B = np.zeros((2, 20)); B[0, :10] = 1.0; B[1, 10:] = 1.0
>>> w, _ = Problem(X, B=B, c=np.array([0.5, 0.5])).solve_kkt()
>>> [float(round(s, 8)) for s in B @ w]
[0.5, 0.5]
>>> bool((w >= -1e-6).all())
True