| 15 | /// assumes daily rows; for intraday rows the figures are per 252 rows, but the weights do |
| 16 | /// not depend on that constant. Expected returns are preserved. Exactly equal forecasts |
| 17 | /// produce one minimum-variance frontier portfolio via a constrained QP solver, with |
| 18 | /// `lambda = 0`; nearly equal forecasts retain their original ordering. |
| 19 | /// `max_sharpe` searches only the efficient frontier. With negative expected returns, |
| 20 | /// a dominated portfolio outside that frontier can have a higher Sharpe ratio. |
| 21 | /// |
| 22 | /// Parameters |
| 23 | /// ---------- |
| 24 | /// asset_prices : list[list[float]] | None, default None |
| 25 | /// Prices, one inner list per observation (oldest first) and one column per asset. |
| 26 | /// Required unless both `expected_returns` and `covariance_matrix` are given. |
| 27 | /// expected_returns : list[float] | None, default None |
| 28 | /// Expected return per asset. When given it is used instead of an estimate from prices. |
| 29 | /// covariance_matrix : list[list[float]] | None, default None |
| 30 | /// `N x N` covariance. When given it is used instead of an estimate from prices. |
| 31 | /// weight_bounds_lower : float | None, default None |
| 32 | /// Lower bound on every weight; None means 0. |
| 33 | /// weight_bounds_upper : float | None, default None |
| 34 | /// Upper bound on every weight; None means 1. |
| 35 | /// resample_by : str | None, default None |
| 36 | /// For prices only, positional resampling (case-insensitive): `"W"`/`"week"`/`"weekly"` |
| 37 | /// keeps every 5th row (`step = 5`), `"M"`/`"month"`/`"monthly"` every 21st |
| 38 | /// (`step = 21`); anything else, or None, keeps every row (`step = 1`). |
| 39 | /// solution : str | None, default None |
| 40 | /// `"cla_turning_points"` (the default when None), `"min_volatility"`, `"max_sharpe"` |
| 41 | /// (maximises `mu'w / sigma` along the efficient frontier) or `"efficient_frontier"` |
| 42 | /// (about 100 points along the frontier). |
| 43 | /// calculate_expected_returns : str, default "mean" |
| 44 | /// How expected returns are estimated from prices: `"mean"` (mean periodic return) or |
| 45 | /// `"exponential"` (exponentially weighted mean, span 500, seeded at the first return). |
| 46 | /// Ignored when `expected_returns` is given. |
| 47 | /// |
| 48 | /// Returns |
| 49 | /// ------- |
| 50 | /// dict[str, list] |
| 51 | /// `weights`: the requested portfolios, one list of `N` weights each, in input column |
| 52 | /// order (every turning point, maximum return first, for `"cla_turning_points"`; one |
| 53 | /// portfolio for `"min_volatility"` and `"max_sharpe"`; the frontier points for |
| 54 | /// `"efficient_frontier"`). `lambdas`: the risk-aversion parameter at each turning point, |
| 55 | /// infinite first and falling to 0 (only 0 for exactly equal forecasts). `efficient_frontier_means` and |
| 56 | /// `efficient_frontier_sigma`: the expected return and volatility of each frontier point |
| 57 | /// (empty unless `solution="efficient_frontier"`). |
| 58 | /// |