Skip to content

intuition-io/portfolio

Repository files navigation

Portfolio Analytics

Build Status Coverage Status Code Health Requirements Status License Gitter chat

Zipline compatible extension of Portfolio, with analytics superpowers. Inspired by PortfolioAnalytics 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 :

To learn more about the API, check the full documentation.

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

Finally, the whole thing is compatible with zipline backtester.

Install

$ sudo apt-get install libopenblas-dev liblapack-dev gfortran
$ pip install portfolio-analytics

... blablabla it compiles a lot of maths, grab a coffee ...

Or play with it right away with docker:

$ docker run -i -t hivetech/portfolio bash

A taste of it

# Download some historical data
from pandas.io.data 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
portfolio.add_constraint(constraint.long_only())
# Invest every cent of our cash
portfolio.add_constraint(constraint.full_investment())

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

Contributing

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

License

Copyright 2014 Xavier Bruhiere.

Portfolio is available under the Apache License, Version 2.0.

Releases

No releases published

Packages

No packages published