$npx skillfedfor your agent

pyportfolioopt

Financial portfolio optimization in python

Worth itPyPI FinancialReleased Feb 2026195.2K downloads / mopermissive licensePure Python

Decision gist · record as of 2026-08-14

pure-Python wheel — pyportfolioopt-1.6.0-py3-none-any.whl
v1.6.0 · released 2026-02-26 · 6 runtime deps: cvxpy, numpy, pandas, scikit-base, scikit-learn, scipy

Yes. PyPortfolioOpt is actively maintained, has no known vulnerabilities, installs with low friction, and is licensed permissively under MIT. It provides a well-documented, scikit-learn-inspired interface to classical portfolio optimization methods suitable for both prototyping and production use. Install it if you need to compute optimal asset allocations from expected returns and risk estimates.AI-flagged interpretation of the facts on this page — verify before relying

Before you install

  • Low install friction with a pure-Python wheel distribution.
  • Active maintenance with a recent release in February 2026 and continuous commits; the repository has 5964 stars and is not archived.

License · maintenance · safety

permissive license (permissive) — MIT License permits free use, modification, and distribution with minimal restrictions, making it suitable for both commercial and open-source projects.

last release 2026-02-26 (169 days) · last repo commit 2026-07-07 · 5,964 stars

0 known vulnerabilities (OSV.dev, 2026-08-14) · 195,241 downloads/mo, #9,819 on PyPI

Verify before relying

pip install pyportfolioopt

import pandas as pd
from pyportfolioopt import EfficientFrontier
from pyportfolioopt import risk_models, expected_returns

df = pd.read_csv("stock_prices.csv", parse_dates=True, index_col="date")
mu = expected_returns.mean_historical_return(df)
S = risk_models.sample_cov(df)
ef = EfficientFrontier(mu, S)
raw_weights = ef.max_sharpe()
print(ef.portfolio_performance(verbose=True))
  • Whether the package requires specific versions of cvxpy, numpy, pandas, scikit-learn, or scipy beyond what pip resolves automatically
  • Performance characteristics when optimizing portfolios with hundreds or thousands of assets
  • Whether all optimization methods (mean-variance, Black-Litterman, Hierarchical Risk Parity) are equally mature or if some are experimental
Same gist for agents: .md · .json

What it is and what it does

PyPortfolioOpt is a Python library for computing mathematically optimal portfolio allocations given historical asset prices or expected returns and risk estimates. It implements classical portfolio optimization methods rooted in Markowitz's efficient frontier theory, allowing investors to find allocations that maximize risk-adjusted returns such as Sharpe ratio or minimize portfolio volatility for a target return. The library depends on cvxpy for convex optimization, numpy and scipy for numerical computation, pandas for data handling, and scikit-learn and scikit-base for its extensible architecture.

The package is designed for both casual investors prototyping allocation strategies and professionals building quantitative trading systems. It handles the full workflow from computing expected returns and covariance matrices from historical data, through optimization with optional constraints, to converting continuous weights into discrete share counts for actual trading. The library is inspired by scikit-learn's design philosophy, emphasizing ease of use alongside extensibility for custom objective functions and risk models.

Use it for

  • Compute optimal long-only portfolio weights that maximize Sharpe ratio given historical stock price data
  • Convert theoretical portfolio weights into discrete share counts and dollar allocations for a fixed investment amount
  • Implement Black-Litterman allocation to incorporate subjective market views alongside historical return estimates
  • Optimize asset allocation subject to custom constraints such as sector limits or position size bounds
  • Backtest multi-asset strategies by computing efficient frontiers and comparing risk-return tradeoffs
  • Prototype quantitative trading strategies that combine multiple alpha sources into a single risk-efficient portfolio

Worth the install?

AI-flagged interpretation of the facts on this page. Verify before relying on it.

Worth it

Yes.

PyPortfolioOpt is actively maintained, has no known vulnerabilities, installs with low friction, and is licensed permissively under MIT. It provides a well-documented, scikit-learn-inspired interface to classical portfolio optimization methods suitable for both prototyping and production use. Install it if you need to compute optimal asset allocations from expected returns and risk estimates.

Install

pyportfolioopt on PyPI

Before you install

Low install friction with a pure-Python wheel distribution. Active maintenance with a recent release in February 2026 and continuous commits; the repository has 5964 stars and is not archived.

License in practice

MIT License permits free use, modification, and distribution with minimal restrictions, making it suitable for both commercial and open-source projects.

Quickstart

pip install pyportfolioopt

import pandas as pd
from pyportfolioopt import EfficientFrontier
from pyportfolioopt import risk_models, expected_returns

df = pd.read_csv("stock_prices.csv", parse_dates=True, index_col="date")
mu = expected_returns.mean_historical_return(df)
S = risk_models.sample_cov(df)
ef = EfficientFrontier(mu, S)
raw_weights = ef.max_sharpe()
print(ef.portfolio_performance(verbose=True))

Verify before relying

  • Whether the package requires specific versions of cvxpy, numpy, pandas, scikit-learn, or scipy beyond what pip resolves automatically
  • Performance characteristics when optimizing portfolios with hundreds or thousands of assets
  • Whether all optimization methods (mean-variance, Black-Litterman, Hierarchical Risk Parity) are equally mature or if some are experimental

Package facts

Licensepermissive license permissive
Python supportNot specified
Install frictionLow. Pure-Python wheel
Runtime dependencies
6 packages
cvxpynumpypandasscikit-basescikit-learnscipy
MaintenanceActively maintained 169 days since the last release
Last repo commit
First released
Downloads195,241 / month, #9,819 on PyPI 30-day window, as of 2026-08-14
Known vulnerabilitiesNone known OSV.dev, checked 2026-08-14
Classifiers
Development Status :: 4 - BetaEnvironment :: ConsoleIntended Audience :: Financial and Insurance IndustryIntended Audience :: Science/ResearchLicense :: OSI Approved :: MIT LicenseNatural Language :: EnglishOperating System :: OS IndependentProgramming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Topic :: Office/Business :: FinancialTopic :: Office/Business :: Financial :: Investment

Evidence: pyportfolioopt-1.6.0-py3-none-any.whl

Tags

Capabilities
portfolio optimizationmean-variance optimizationefficient frontierasset allocationBlack-LittermanSharpe ratio optimizationrisk-adjusted returnsportfolio weights
Topics
portfolio-optimizationquantitative-financeconvex-optimization
PyPI keywords
financeportfoliooptimizationquantinvesting

Let your AI agent find packages like this

Example. Real query, live index.

You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.

wish › “mean-variance optimization”

  • pyportfoliooptPyPortfolioOpt implements portfolio optimization methods including…
  • skfolioskfolio is a Python library for portfolio optimization and risk…
  • riskfolio-libRiskfolio-Lib builds optimized investment portfolios using…

Give your agent the search over MCP, or paste the wish link into any chat.

More Financial packages

statsmodels Worth it
PyPI · Scientific/Engineering · released Dec 2025

statsmodels provides statistical models, inference methods, and descriptive statistics for Python, complementing scipy with regression, time series, discrete choice, survival analysis, and multivariate methods.

Install it if you need publication-quality statistical models, hypothesis tests, or time series analysis beyond what scipy or pandas provide.

BSD-3-Clausecompiled wheel · 3.9+
45.7Mdownloads / mo
holidays Worth it
PyPI · Python Modules · released Aug 2026

Generates country- and subdivision-specific government holiday calendars on demand, supporting 250 country codes with optional language localization and holiday categories.

MITpure Python · 3.10+
30.7Mdownloads / mo
yfinance With conditions
PyPI · Libraries · released Aug 2026

Fetches financial and market data from Yahoo Finance's public APIs, including ticker information, historical prices, and live streaming data.

However, do not use it for commercial applications or high-volume data collection without confirming compliance with Yahoo's terms of service.

Apache-2.0pure Python
29.2Mdownloads / mo
bokeh Worth it
PyPI · Scientific/Engineering · released Jul 2026

Bokeh is an interactive visualization library that creates browser-based plots, dashboards, and data applications from Python code, with support for large and streaming datasets.

Install it if you need browser-based interactivity.

BSD-3-Clausepure Python · 3.10+
12.1Mdownloads / mo
python-stdnum Worth it
PyPI · Python Modules · released Jan 2026

Parses, validates, and reformats standard numbers and codes across many countries and industries—tax IDs, bank accounts, identity numbers, VAT codes, and financial identifiers.

Install it if you validate or reformat standardized numbers.

LGPL-2.0-or-laterpure Python · 3.8+
6.2Mdownloads / mo
numpy-financial With conditions
PyPI · Software Development · released Oct 2019

Provides elementary financial functions (IRR, NPV, PMT, and others) that were deprecated and removed from NumPy, offering a dedicated replacement for financial calculations.

However, given the aging status (no releases since 2019) and unclear compatibility with modern Python and recent numpy versions, verify that it works with your target…

BSD-3-Clausepure Python · 3.5+aging
5.9Mdownloads / mo

See also riskfolio-lib · skfolio · quantstats · py-vollib · py-lets-be-rational · vollib · empyrical-reloaded · backtesting · pyomo