← Back to Documentation

Portfolio Optimizer

Portfolio Optimizer estimates allocations from historical data. Different modes answer different questions: one in-sample allocation, a full frontier of efficient portfolios, a walk-forward allocation process, or a Black-Litterman estimate that combines market equilibrium with explicit views.

Access: Sign in required (Free or Pro)

Open Portfolio Optimizer →

Modes

ModeWhat It ReturnsWhat The Historical Window Means
Mean-VarianceOne allocation optimized for the selected objective.Used to estimate expected returns and covariance directly from the full sample.
Efficient FrontierA set of efficient portfolios across the risk-return curve.Used to estimate the same inputs as mean-variance mode.
BacktestRealized walk-forward metrics and the latest resulting allocation.Split into repeated trailing windows for re-optimization.
Black-LittermanPosterior expected returns and one resulting allocation.Used to estimate the covariance matrix and equilibrium inputs.

Choose The Right Optimizer Mode

QuestionMode
What is the single best allocation for a given objective?Mean-Variance
What are the efficient allocations across the risk-return curve?Efficient Frontier
How would periodic re-optimization have performed historically?Backtest
How do explicit views change the allocation relative to market equilibrium?Black-Litterman

Mean-Variance and Efficient Frontier are in-sample estimates from the full date range. Backtest mode splits the window into walk-forward steps. Black-Litterman combines equilibrium with user views.

The optimizer returns an allocation estimate. Use the handoff to Portfolio Backtest when you need a full historical result with charts, tables, and saved-analysis support.

Shared Inputs

  • Tickers: the asset universe being optimized.
  • Date range: the historical sample used by the selected mode.
  • Price mode: total-return or raw-price return construction.
  • Risk-free rate: used in Sharpe and Sortino calculations and in tangency-portfolio calculations.
  • Constraints: long-only versus shorting, leverage allowance, and other mode-specific controls.

Backtest Mode Inputs

  • Rolling window: trailing history used at each re-optimization step.
  • Rebalance frequency: how often the allocation is updated in the walk-forward process.
  • Max holdings: upper bound on the number of included assets.
  • Minimum included weight: smallest weight that may remain in the resulting allocation.

Read The Outputs

  • Weights: the allocation implied by the selected mode and settings.
  • Frontier points: efficient portfolios traced across the risk-return surface.
  • Mode-specific metrics: such as realized walk-forward metrics in backtest mode or posterior-return details in Black-Litterman mode.

The optimizer returns an allocation estimate, not a portfolio backtest by itself. Use the handoff back into Portfolio Backtest when you want a full historical result view with charts, tables, and saved-analysis support.

Optimization Objectives

Each objective tells the optimizer what to prioritize:

  • Maximum Sharpe Ratio: finds the portfolio on the efficient frontier with the highest risk-adjusted return (excess return per unit of volatility). This is the classic tangency portfolio from modern portfolio theory.
  • Minimum Volatility: finds the global minimum variance portfolio. Ignores expected returns and focuses on the lowest-variance allocation in the feasible set.
  • Risk Parity: equalizes the risk contribution of each asset. Instead of targeting a specific return/risk level, it ensures every asset contributes the same amount of risk to the total portfolio.
  • Maximum Return: maximizes expected return subject to a volatility ceiling you specify. Set a target volatility (e.g. 15%) and the optimizer finds the highest-returning portfolio that stays at or below that risk level.
  • Minimum CVaR: minimizes Conditional Value at Risk (expected shortfall) at the 95% confidence level. CVaR measures the average loss in the worst 5% of days, making it more sensitive to tail risk than volatility.
  • Maximum Sortino Ratio: like maximum Sharpe, but only penalizes downside volatility. Upside volatility (prices going up more than expected) is not counted as risk.

The Efficient Frontier

Every time you optimize, the tool also computes the efficient frontier, the curve of all portfolios that offer the highest possible return for each level of risk. The chart shows:

  • Frontier curve (indigo line): the set of optimal portfolios. Points below this curve are suboptimal (you could get more return for the same risk, or less risk for the same return).
  • Max Sharpe portfolio (red star): the tangency portfolio where a line from the risk-free rate is tangent to the frontier. This point has the steepest risk-return tradeoff.
  • Min Volatility portfolio (green diamond): the leftmost point on the frontier, representing the lowest-possible risk allocation.
  • Individual assets (colored circles): each asset plotted at its own risk-return coordinates. These typically lie below the frontier, showing the diversification benefit of combining assets.

Hover over any point on the frontier to see the exact portfolio weights, return, volatility, and Sharpe ratio for that allocation.

Cash Overlay And Borrowing Spread

The cash overlay mode extends the efficient frontier to model explicit lending and borrowing. Instead of assuming all capital must be invested in risky assets, the frontier includes three regimes:

  • Net cash (lending): when risky-asset allocation is below 100%, idle capital earns the cash rate. Portfolio volatility scales linearly with the risky allocation fraction, producing the lending segment of the capital market line.
  • Fully invested: the standard Markowitz frontier where all capital is allocated to risky assets.
  • Borrowing (leverage): when risky-asset allocation exceeds 100%, borrowed capital costs the cash rate plus the borrow spread. This creates the borrowing segment of the capital market line, which is flatter than the lending segment due to the higher cost of leverage.

The asymmetry between lending and borrowing rates creates a kinked capital market line rather than the single straight line in textbook models. The tangency portfolio (maximum Sharpe point) is identified on the lending segment, representing the optimal risky portfolio to combine with cash.

Each frontier point is labeled with its allocation category (net cash, fully invested, or borrowing) so you can see where your selected portfolio falls on the leverage spectrum.

Understanding The Metrics

After optimization, six metrics summarize the optimal portfolio:

  • Expected Return: annualized return estimated from historical daily returns (or your forward-looking inputs). Expressed as a percentage (e.g. 8.5% means the portfolio is expected to return 8.5% per year).
  • Volatility: annualized standard deviation of returns. Measures the total variability of the portfolio. A volatility of 12% means daily returns have a standard deviation of about 0.76% (12% / sqrt(252)).
  • Sharpe Ratio: (return - risk-free rate) / volatility. Negative Sharpe means the portfolio underperforms the risk-free rate.
  • Sortino Ratio: like Sharpe but uses only downside deviation in the denominator.
  • Daily CVaR 95%: the average daily loss in the worst 5% of historical trading days. For example, a CVaR of 2.1% means that on the worst 5% of days, the portfolio lost an average of 2.1%.
  • Rebalancing Bonus: the diversification return from periodic rebalancing. Positive values mean that a rebalanced portfolio would have earned a return premium over a buy-and-hold approach with the same initial weights. Larger bonuses indicate more diversification benefit.

Price Modes

  • Total Return: uses adjusted prices that include dividends and distributions.
  • Raw: uses unadjusted closing prices.

Constraints

  • Short selling: allows negative asset weights.
  • Leverage: allows total gross exposure above 100% where the mode supports it.
  • Target volatility: applies in objectives that require a risk target.

Advanced Constraints (Backtest Mode)

Backtest mode supports optional metric and turnover constraints under the Advanced Constraints panel. These are checked against the final walk-forward result.

  • Metric floors: require minimum values for metrics such as CAGR or Sharpe ratio. Values use the same units as the results table (percent for return and volatility metrics, raw numbers for ratios).
  • Metric ceilings: require maximum values for metrics such as volatility or max drawdown.
  • Per-asset bounds: set minimum and maximum weight constraints on individual assets.
  • Max turnover: cap the one-way turnover per rebalance. When a rebalance would exceed the cap, the previous weights are retained for that period.

Contradictory constraints (floor exceeding ceiling on the same metric, or duplicate entries) are rejected before the optimizer runs. When no feasible portfolio satisfies all metric constraints, the response includes the best unconstrained result along with a warning identifying which constraint was violated.

Covariance Estimation

The optimizer estimates covariance from the selected historical sample. When the data-to-asset ratio is low, shrinkage is applied to stabilize the estimate.

Forward-Looking Parameters

The API can override historical expected returns, volatilities, and correlations with externally supplied assumptions. When those overrides are present, the optimizer uses them instead of the historical estimates.

Black-Litterman Optimization

Black-Litterman (BL) is an alternative to classic mean-variance optimization that blends market equilibrium with your personal views. Instead of relying entirely on historical returns (which are noisy), BL starts with the returns implied by current market-cap weights (the "equilibrium") and then tilts toward your views.

Switch to BL mode using the Strategy toggle at the top of the optimizer form. The optimizer interface changes to show BL-specific inputs described below.

How it works

  1. Equilibrium prior: BL reverse-engineers the expected returns that would make the market-cap-weighted portfolio optimal (via π = δΣw). These "implied returns" are the starting point.
  2. Investor views: you overlay your own beliefs (e.g. "SPY will return 10%" or "SPY will outperform BND by 3%") with a confidence level. BL combines these views with the equilibrium using Bayesian math.
  3. Posterior returns: the result is a set of blended expected returns that respect both the market consensus and your views. High-confidence views tilt the posterior more; low-confidence views barely change it.
  4. Optimal weights: the optimizer uses these posterior returns to find the best portfolio weights. With no views, you get back the market-cap weights (a sanity check).

Inputs

  • Tau (τ): uncertainty scalar on the equilibrium prior (default 0.05, range 0.01-0.5). Smaller values trust the market equilibrium more; larger values let views have more influence. A common rule of thumb is τ = 1/T where T is the number of years of data.
  • Risk Aversion (δ): controls the equilibrium return magnitude (default 2.5, range 0.5-10). Higher values imply the market demands more return per unit of risk. Standard estimates for equity markets range from 2 to 4.
  • Long-only constraint: when enabled (the default), all weights are constrained to [0, 1]. When disabled, the optimizer uses the analytic unconstrained solution (allowing short positions) while still requiring weights sum to 100%.
  • Market-Cap Weights: the equilibrium starting point. Choose "Auto-fetch" to pull market caps from yFinance (with a fallback for ETFs/tickers without market-cap data), or "Manual" to enter custom weights that sum to 100%.

Views

Views are the core of Black-Litterman. Each view has:

  • Absolute view: "Asset X will return Y% annualized." For example, "SPY returns 10%" at 80% confidence.
  • Relative view: "Asset X will outperform Asset Y by Z%." For example, "SPY outperforms BND by 3%" at 70% confidence.
  • Confidence (0.01-0.99): how sure you are about the view. Higher confidence tilts the posterior more. A confidence of 0.5 is a moderate belief; 0.9 is very strong conviction.

Views with incomplete fields (no asset selected or no return entered) are automatically skipped. You can have up to 20 views.

Results

The BL results panel shows three tabs:

  • Weights: the optimal portfolio weights from the BL posterior.
  • Returns: equilibrium vs. posterior returns for each asset, with the shift highlighted in green (positive) or red (negative).
  • View Attribution: shows how each individual view independently shifts weights relative to the equilibrium. Note that these per-view effects are not additive since BL blending is non-linear.

Saved Analyses And Handoffs

Save the current optimizer run when you want to reopen the same mode, inputs, and result later. Use the resulting weights in Portfolio Backtest when you want to test that allocation in a full backtest workflow.

Limitations And Caveats

  • Estimation error: optimal weights are only as reliable as the return and covariance estimates. Historical data may not represent future relationships, especially during market condition changes (e.g. rising vs. falling rate environments).
  • Concentration risk: mean-variance optimization can produce extreme allocations (e.g. 90% in one asset). This is a known issue when expected return estimates are noisy. Risk parity avoids this by ignoring expected returns.
  • Transaction costs: the optimizer does not account for trading costs, bid-ask spreads, or taxes. Frequent rebalancing to maintain optimal weights may erode returns in practice.
  • Stationarity assumption: the optimizer assumes that return distributions are stationary (the same in the future as in the past). Correlations between assets can change significantly, especially during market crises when correlations tend to spike toward 1.0.