/mvportfolio

Simple portfolio analysis and management.

Primary LanguagePythonMIT LicenseMIT

The Python Quants

Case Study

Mean-Variance Portfolio Package

Dr. Yves J. Hilpisch

The Python Quants GmbH

http://tpq.io | training@tpq.io

mvportfolio

mvportfolio is a simple Python package to analyze and manage investment portfolios according to the Mean-Variance Portfolio (MVP) theory.

Installation

From Source

Open a terminal an execute

git clone http://github.com/yhilpisch/mvportfolio
cd mvportfolio
python setup.py install

Via pip (from Github)

Open a terminal and execute

pip install git+https://github.com/yhilpisch/mvportfolio.git

Via pip (from PyPi)

Open a terminal and execute

pip install --index-url https://test.pypi.org/simple/ mvportfolio

First Steps

Some imports first.

from pylab import plt
import mvportfolio as mvp

Second, an instance of the main class MVPPortfolio.

p = mvp.MVPPortfolio(['.SPX', '.VIX'], '2017-1-1', '2018-6-30')

Third, some statistics for the equal weights portfolio.

p.weights
[0.5, 0.5]
p.portfolio_return()
0.1379220899637485
p.portfolio_volatility()
0.6462235282900842

Fourth, the minimum risk portfolio weights.

opt = p.minimum_risk_portfolio()
opt['x']
array([0.93891629, 0.06108371])

Copyright & License

© The Python Quants GmbH | MIT License.