abaquant.portfolio.solvers

Import path: abaquant.portfolio.solvers

Domain: Portfolio construction, optimization, backtesting, risk metrics, and stress testing.

Purpose

Shared constrained numerical solvers for portfolio weights.

When to use it

Use this package to transform return histories and covariance estimates into weights, then evaluate those weights out of sample and under explicit scenarios.

Public objects

  • function: normalize_weights — Clip weights to bounds and normalize them to sum to one.

  • function: solve_slsqp_weights — Solve a constrained portfolio-weight problem using SciPy SLSQP.

Detailed reference

Shared constrained numerical solvers for portfolio weights.

Purpose

The module contains feasibility normalization and SLSQP wrappers used by higher-level allocation routines.

Conventions

Weight vectors follow the package convention of summing to one. Bounds are decimal allocation limits.

Scope and limitations

The historical failure behavior of the solver wrapper is documented at the callable level.

References

[ 1 ] Markowitz, H. (1952), “Portfolio Selection”.

abaquant.portfolio.solvers.normalize_weights(weights, min_weight, max_weight)

Clip weights to bounds and normalize them to sum to one.

Parameters:
  • weights (np.ndarray) – Portfolio weights, either a mapping keyed by asset or an ordered numeric vector as documented by the callable.

  • min_weight (float) – Lower allocation bound applied to each asset weight.

  • max_weight (float) – Upper allocation bound applied to each asset weight.

Returns:

Numeric array ordered consistently with the supplied strikes, time grid, assets, or state labels.

Return type:

numpy.ndarray

abaquant.portfolio.solvers.solve_slsqp_weights(objective, n_assets, min_weight, max_weight, bounds=None, constraints=None, x0=None)

Solve a constrained portfolio-weight problem using SciPy SLSQP.

Parameters:
  • objective (Callable[[np.ndarray], float]) – Objective function passed to the numerical optimizer.

  • n_assets (int) – Number of assets in the allocation problem.

  • min_weight (float) – Lower allocation bound applied to each asset weight.

  • max_weight (float) – Upper allocation bound applied to each asset weight.

  • bounds (Sequence[tuple[float, float]] | None, default=None) – Allocation bounds in the format accepted by the underlying optimizer.

  • constraints (Sequence[dict] | tuple[dict, ...] | None, default=None) – Constraint specification passed to the numerical optimizer.

  • x0 (np.ndarray | None, default=None) – Optional initial point for numerical optimization.

Returns:

Result of the solve slsqp weights calculation.

Return type:

np.ndarray