abaquant.portfolio.efficient_frontier

Import path: abaquant.portfolio.efficient_frontier

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

Purpose

Markowitz efficient-frontier and random-portfolio calculations.

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: markowitz_frontier — Trace the constrained Markowitz efficient frontier over target returns.

  • function: monte_carlo_portfolios — Generate a random fully invested portfolio cloud.

Detailed reference

Markowitz efficient-frontier and random-portfolio calculations.

Purpose

The module traces constrained minimum-variance portfolios across a target-return grid and generates random fully invested portfolio clouds.

Conventions

Expected returns and covariance are annualized inputs. The allow_short flag controls whether the optimizer enforces non-negative weights.

Scope and limitations

Numerical solutions depend on the supplied covariance matrix and SciPy optimizer convergence.

References

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

abaquant.portfolio.efficient_frontier.markowitz_frontier(mean_returns, cov_matrix, n_points=50, allow_short=False)

Trace the constrained Markowitz efficient frontier over target returns.

Parameters:
  • mean_returns (pd.Series) – Expected-return vector ordered consistently with the covariance matrix.

  • cov_matrix (pd.DataFrame) – Square covariance matrix ordered consistently with the asset order.

  • n_points (int, default=50) – Number of target-return points used to trace the frontier.

  • allow_short (bool, default=False) – Whether negative portfolio weights are allowed by the optimizer.

Returns:

Tabular result with the index, column schema, units, and missing-value treatment defined by the module convention.

Return type:

pandas.DataFrame

Notes

This is an analytical in-sample calculation. It does not by itself model transaction costs, execution effects, taxes, or future return uncertainty.

abaquant.portfolio.efficient_frontier.monte_carlo_portfolios(mean_returns, cov_matrix, n_portfolios=3000, rf=0.0, allow_short=False, seed=42)

Generate a random fully invested portfolio cloud.

Parameters:
  • mean_returns (pd.Series) – Expected-return vector ordered consistently with the covariance matrix.

  • cov_matrix (pd.DataFrame) – Square covariance matrix ordered consistently with the asset order.

  • n_portfolios (int, default=3000) – Number of random portfolios to generate.

  • rf (float, default=0.0) – Risk-free rate under the function annualization convention.

  • allow_short (bool, default=False) – Whether negative portfolio weights are allowed by the optimizer.

  • seed (int | None, default=42) – Optional pseudo-random seed for reproducible simulation.

Returns:

Tabular result with the index, column schema, units, and missing-value treatment defined by the module convention.

Return type:

pandas.DataFrame

Notes

This is an analytical in-sample calculation. It does not by itself model transaction costs, execution effects, taxes, or future return uncertainty.