Critical Line Weights
Calculate the corner portfolios of the efficient frontier with the critical line algorithm of Markowitz (1956).
These are the exact points where an asset enters or leaves the portfolio. Between two neighbouring corners the efficient weights move along a straight line, so the corners describe the whole long-only (or bounded) frontier without a grid of target returns. The minimum variance portfolio (the last corner) and the maximum Sharpe ratio portfolio follow from them exactly.
Every efficient portfolio minimizes ½ \(w' \Sigma w - \lambda \mu' w\) subject to the weights summing to one and lying between their bounds, for some \(\lambda \geq 0\), the risk tolerance (the inverse of the risk aversion). The algorithm starts at the portfolio with the highest expected return (\(\lambda\) = ∞) and lowers \(\lambda\). For the assets strictly between their bounds (the free assets F, the others B are at a bound) the first-order conditions are a linear system:
\[\Sigma_{\text{FF}} w_{F} + \gamma 1 = \lambda \mu_{F} - \Sigma_{\text{FB}} w_{B}\] \[\text{1'w}_{F} = 1 - \text{1'w}_{B}\]so the weights are affine in \(\lambda\) until a free asset reaches a bound or the gradient \((\Sigma w)_{j} - \lambda \mu_{j} + \gamma\) of a bound asset changes sign, which frees it. That \(\lambda\) is a corner. On the line between two corners the Sharpe ratio has a single stationary point, which gives the maximum Sharpe ratio portfolio in closed form.
Also known as: CLA, corner portfolios, turning points of the efficient frontier.
Example · AAPL, MSFT, JNJ, XOM · 2021 to 2025
Install the Finance Toolkit with pip install financetoolkit -U, then call get_critical_line_weights:
from financetoolkit import Toolkit
toolkit = Toolkit(
["AAPL", "MSFT", "JNJ", "XOM"],
api_key="FINANCIAL_MODELING_PREP_KEY",
start_date="2021-01-01",
end_date="2025-12-31",
)
toolkit.portfolio.get_critical_line_weights().drop(columns="Sharpe Ratio")
Or, with the Finance Toolkit MCP set up, ask an AI assistant such as Claude or ChatGPT:
What are the corner portfolios of the efficient frontier of Apple, Microsoft, Johnson & Johnson and ExxonMobil, based on 2021 to 2025?
Which returns:
| Portfolio | Lambda | Expected Return | Volatility | AAPL | MSFT | JNJ | XOM |
|---|---|---|---|---|---|---|---|
| Corner 1 | 0.7508 | 0.2911 | 0.2702 | 0.0000 | 0.0000 | 0.0000 | 1.0000 |
| Corner 2 | 0.2405 | 0.2591 | 0.2031 | 0.0000 | 0.3583 | 0.0000 | 0.6417 |
| Corner 3 | 0.2240 | 0.2578 | 0.2016 | 0.0103 | 0.3619 | 0.0000 | 0.6278 |
| Corner 4 | 0.0000 | 0.1577 | 0.1350 | 0.0211 | 0.2166 | 0.5822 | 0.1801 |
| Minimum Variance | 0.0000 | 0.1577 | 0.1350 | 0.0211 | 0.2166 | 0.5822 | 0.1801 |
| Maximum Sharpe | 0.1470 | 0.2234 | 0.1670 | 0.0140 | 0.3120 | 0.2001 | 0.4740 |
6 rows
Parameters
get_critical_line_weights accepts the following parameters.
| Parameter | Type | Description | Example |
|---|---|---|---|
period | str | The frequency of the returns. Options are: “daily” (daily returns), “weekly” (weekly returns), “monthly” (monthly returns), “quarterly” (quarterly returns), “yearly” (yearly returns). Defaults to “daily”. | "weekly" |
covariance | str | The estimator of the covariance matrix. Options are: “sample” (the sample covariance, ddof=1), “ledoit_wolf” (shrunk towards the scaled identity, Ledoit and Wolf, 2004), “ledoit_wolf_constant_correlation” (shrunk towards the average correlation, Ledoit and Wolf, 2004), “ledoit_wolf_single_factor” (shrunk towards the covariance that the benchmark as a single factor implies, Ledoit and Wolf, 2003), “oas” (Oracle Approximating Shrinkage, Chen et al., 2010), “shrunk” (a fixed 10% towards the scaled identity), “semicovariance” (the co-movement below a zero return, Estrada, 2008), “exponential” (exponentially weighted, recent periods weigh most, RiskMetrics), “denoised” (the eigenvalues of the correlation matrix that random returns could produce averaged, Laloux et al., 2000), “denoised_spectral” (those eigenvalues set to zero), “denoised_shrink” (the noise correlations shrunk towards their diagonal, López de Prado, 2020), “gerber” (co-movements beyond half a standard deviation, Gerber et al., 2022), “factor” (the covariance of the Fama and French five factor model with OLS loadings, Fama and French, 1993), “minimum_covariance_determinant” (the reweighted covariance of the half of the periods with the smallest covariance determinant, robust to outliers, Rousseeuw and Van Driessen, 1999), “jlogo” (the sparse inverse covariance on the TMFG planar graph of the correlations, Barfuss et al., 2016), “geodesic” (10% towards the scaled identity along the geodesic of the positive definite matrices, Bhatia, 2007), “regime_adjusted_ew” (exponentially weighted with a half-life of 40 periods, rescaled by the recent realized against predicted risk, Paleologo, 2025), “nercome” (eigenvectors from one part of the periods and the variances along them from the other, averaged over random splits, Lam, 2016), “ccc_garch” (the next-period covariance of GARCH(1, 1) volatilities with constant correlations, Bollerslev, 1990), “mm” (the robust MM-estimator, Maronna et al., 2019), “rocke” (Rocke’s robust S-estimator, Maronna et al., 2019). Defaults to “sample”. | "sample" |
covariance_span | int | The span in periods of the exponentially weighted covariance; the weight of a period halves after about span / 2.9 periods. Defaults to 180. | 180 |
expected_returns | str | The estimator of the expected returns. Options are: “mean” (the historical average), “geometric” (the compounded average), “exponential” (the exponentially weighted average, recent periods weigh most), “exponential_geometric” (that average compounded over a year), “capm” (the returns the Capital Asset Pricing Model implies from each asset’s beta to the benchmark, Sharpe, 1964), “bayes_stein” (the averages shrunk towards that of the minimum variance portfolio, Jorion, 1986), “james_stein” (the averages shrunk towards their grand mean, James and Stein, 1961), “bodnar_okhrin_parolya” (the averages and their grand mean combined with optimal weights, Bodnar, Okhrin and Parolya, 2019). Defaults to “mean”. | "mean" |
expected_returns_span | int | The span in periods of the exponentially weighted expected returns. Defaults to 180. | 180 |
minimum_weight | float | dict[str, float] | The lowest weight of every asset, or per asset, e.g. {“AAPL”: 0.05} (the others keep 0); a negative value allows short positions. Defaults to 0. | 0 |
maximum_weight | float | dict[str, float] | The highest weight of every asset, or per asset, e.g. {“AAPL”: 0.3} (the others keep 1). Defaults to 1. | 1 |
include_benchmark | bool | Whether to include the benchmark as an asset. Defaults to False. | True |
rounding | int | None | The number of decimals to round the results to. Defaults to None, which uses the Toolkit’s rounding. | 2 |
show_columns | str | list[str] | None | The columns to keep, a name or a list of names, matched on every column level, or the rows when no column has those names (such as the line items of a financial statement). Names that do not exist are logged, and when none exist the result is returned in full. Defaults to None, which keeps every column. | None, which keeps every column |
References
- Paper Markowitz, H. (1956). “The Optimization of a Quadratic Function Subject to Linear Constraints.” Naval Research Logistics Quarterly, 3(1-2), 111-133.
- Paper Bailey, D. H. and López de Prado, M. (2013). “An Open-Source Implementation of the Critical-Line Algorithm for Portfolio Optimization.” Algorithms, 6(1), 169-196.
- Library Referenced against PyPortfolioOpt’s CLA