Skip to main content

Collection of algorithms for online portfolio selection

Project description


The purpose of this package is to put together different online portfolio selection algorithms and provide unified tools for their analysis. If you do not know what online portfolio is, look at Ernest Chan blog, CASTrader or a recent survey by Bin Li and Steven C. H. Hoi.

In short, the purpose of online portfolio is to choose portfolio weights in every period to maximize its final wealth. Examples of such portfolios could be Markowitz portfolio or Universal portfolio. Currently there is an active research in the are of online portfolios and even though its results are mostly theoretic, algorithms for practical use starts to appear.

Several algorithms from the literature are currently implemented, based on the available literature and my understanding. Contributions or corrections are more than welcomed.


There is an IPython notebook explaining the basic use of the library. Paul Perry followed up on this and made a comparison of all algorithms on more recent ETF datasets. Also see the most recent notebook about modern portfolio theory. There's also an interesting discussion about this on Quantopian.

The original authors of some of the algorithms recently published their own implementation on github - On-Line Portfolio Selection Toolbox in MATLAB.

If you are more into R or just looking for a good resource about Universal Portfolios, check out blog and package logopt by Marc Delvaux.

If you don't want to install the package locally, you can run both notebooks with Binder - modern-portfolio-theory.ipynb Binder or On-line portfolios.ipynb Binder


pip install universal-portfolios


It uses poetry to manage dependencies. Run poetry install to install virtual environment and then poetry shell to launch it.

Exporting dependencies to requirements.txt file is done via

poetry export --without-hashes -f requirements.txt > requirements.txt
poetry export --dev --without-hashes -f requirements.txt > test-requirements.txt

this is needed for


poetry run python -m pytest --capture=no --ff -x tests/ -k test_bias

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for universal-portfolios, version 0.4.1
Filename, size File type Python version Upload date Hashes
Filename, size universal_portfolios-0.4.1-py3-none-any.whl (4.3 MB) File type Wheel Python version py3 Upload date Hashes View
Filename, size universal-portfolios-0.4.1.tar.gz (4.2 MB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page