Skip to main content

Keep calm and optimize.

Project description


[![Build Status](](
[![Coverage Status](](
[![Code Health](](
[![Requirements Status](](
[![Gitter chat](](

> [Zipline][1] compatible extension of Portfolio, with analytics superpowers.
> Inspired by [PortfolioAnalytics][6] R package.

The project provides several portfolio optimizations that compute optimal
assets allocation regarding a various set of factors and constraints. Currently
you will get the following implementations :

* [General optimization problem with solvers][7]
* [Global Minimum Variance][8]
* [Kelly criterion][9]

To learn more about the API, check [the full documentation][3].

This project is currently part of the **intuition project**, signup for [the
private beta][2] and/or [clone your own hedge fund][4].

Finally, the whole thing is compatible with [zipline backtester][1].


$ # Before I setup a package on pypi, yo can get it from source
$ git clone
$ cd portfolio && make
... blablabla it compiles a lot of maths ...

A taste of it

# Download some historical data
from import get_data_google
ohlc_data = get_data_google(['adsk', 'ctxs', 'fb', 'nflx', 'qcom'], start='2013/01/01', end='2013/12/01')
data = ohlc_data['Close']

# Now let's optimize our portfolio weights
from portfolio.optimizations.solvers import SolverPortfolio
import portfolio.objectives as objective
import portfolio.constraints as constraint

portfolio = SolverPortfolio(objective.risk)
# Forbid short positions
# Invest every cent of our cash

# Get optimal weights in %
pf.optimize(['ctxs', 'fb', 'nflx', 'qcom', 'adsk'], data)
{'adsk': 0.49,
'ctxs': 0.04,
'fb': 0.17,
'nflx': 0.0,
'qcom': 0.29}


Contributors are happily welcome, [here is a place to start][10].


Copyright 2014 Xavier Bruhiere.

*Portfolio* is available under the [Apache License, Version 2.0][5].


Project details

Release history Release notifications

This version
History Node


Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
portfolio-analytics-0.0.1.tar.gz (6.2 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page