optimalportfolios

Author: Artur Sepp / First recorded: 2026-08-09

OptimalPortfolios is a Python library for multi-asset portfolio construction and rolling backtesting. At each rebalancing date it turns dated risk estimates, expected returns and constraints into target weights under a chosen objective: risk budgets, maximum diversification, minimum variance, maximum Sharpe, tracking error against a benchmark, or expected utility under fat-tailed returns. Holdings simulation, transaction costs and reporting belong to qis, and sparse factor estimation to FactorLasso; optimalportfolios is the reference implementation of the ROSAA framework of Sepp, Ossa and Kastenholz (2026).

Software citation: CITATION.cff.

Start here

  1. Install optimalportfolios and choose its optional features. The core installation command is python -m pip install optimalportfolios.

  2. Run the offline quickstart: EWMA covariance, constrained minimum-variance weights and a qis backtest with explicit trade timing and costs, on a fixture shipped in the wheel.

  3. Keep the conventions and glossary at hand. Return basis, estimation and rebalancing grids, covariance units, weight states, notation and solver defaults are defined there once for every page.

  4. Browse the analytics gallery for reproducible exhibits, or the examples guide for complete workflows and their data requirements.

The portfolio in one picture

At each rebalancing date \(t\), optimalportfolios chooses the target weights

\[ w_t^{\star} = \arg\max_{w \in \mathcal{C}_t} U(w; \hat{\mu}_t, \hat{\Sigma}_t, w^{\mathrm{bm}}, w_{t^-}), \qquad \hat{\Sigma}_t = \beta_t \Sigma_{F,t} \beta_t^{\top} + D_t . \]

Here \(U\) is the objective, \(\mathcal C_t\) the set of admissible weights, \(\hat\mu_t\) the expected returns or alphas where the objective uses them, \(w^{\mathrm{bm}}\) a benchmark and \(w_{t^-}\) the current holdings drifted to \(t\). The covariance \(\hat\Sigma_t\) is either an EWMA estimate or the factor model on the right, with loadings \(\beta_t\), factor covariance \(\Sigma_{F,t}\) and residual covariance \(D_t\). The construction runs through the steps below.

        flowchart TB
    subgraph estimate ["Estimate at each rebalancing date"]
        direction LR
        A["Prices and<br/>metadata"] --> B["Estimation grid<br/>cadences, ragged histories"]
        B --> C["Risk model<br/>EWMA or factor covariance"]
        B --> D["Expected returns<br/>signals and CMAs"]
    end
    subgraph construct ["Construct and simulate"]
        direction LR
        E["Objective and<br/>constraints"] --> F["Solve and check<br/>the outcome"] --> G["Dated target<br/>weights"] --> H["qis backtest<br/>drift, lag and costs"]
    end
    estimate --> construct
    

In words: prices are sampled on an estimation grid that respects each asset’s cadence and history; a risk model and, for the objectives that need them, expected returns are estimated from information available at the rebalancing date; the objective is solved under the constraints and its outcome checked; and the dated target weights are passed to qis, which simulates the holdings with price drift, implementation lag and transaction costs.

Data and estimation grids

Risk models

Expected returns and signals

  • Alpha signals: momentum, low beta, residual momentum and reversal, carry and managers’ alpha, with cross-sectional and within-cluster scoring.

  • Signal diagnostics and alpha-rank portfolios: the rank information coefficient and its stability, quantile portfolios, per-component diagnostics and the rank profiler.

Portfolio objectives

Constraints and solving

Backtesting and costs

Applications

Case studies report the evidence of the research papers in context: the study design, the configuration in package terms, the paper’s results, and what the study does and does not show.

Implementation and reference

Research papers

The methods are described in the following papers. The research papers page lists which page uses which paper and how to reproduce each one.

  • Sepp, A., Ossa, I. and Kastenholz, M. (2026). Robust Optimization of Strategic and Tactical Asset Allocation for Multi-Asset Portfolios. The Journal of Portfolio Management, 52(4), 86–120.

  • Sepp, A. (2023). Optimal Allocation to Cryptocurrencies in Diversified Portfolios. Risk, October 2023; SSRN 4217841.

  • Sepp, A., Hansen, E. and Kastenholz, M. (2026). Capital Market Assumptions and Strategic Asset Allocation Using Multi-Asset Tradable Factors. Working paper, SSRN 6785958.

Cite a paper for its method, and the software records for the packages an implementation uses: optimalportfolios, qis and FactorLasso.

Project resources