Skip to main content

PyVest is a Python library that provides tools for investment analysis.

Project description

PyVest

PyVest is a Python library that provides tools for investment analysis.

Risk-return trade-off graph

PyVest can be used to easily create graphs of risk-return trade-off. Given a set of risky and/or non-risky assets, the following objects can be represented on a two-dimensional graph of the expected return vs the standard deviation:

  • Feasible portfolios
  • Minimum variance portfolio (MVP)
  • Efficient frontier
  • Tangency portfolio
  • Capital allocation line (CAL)
  • Optimal portfolio of an investor
  • Indifference curves of an investor

Example 1: No risk-free asset

Import the class InvestmentUniverse:

from pyvest import InvestmentUniverse

Define the names of the assets:

assets = ['KO', 'MSFT']

Define the expected returns corresponding to each asset:

mu = [8, 14]

Define the variance-covariance matrix of the assets:

cov = [[3**2, 0],
       [0, 6**2]]

Construct the InvestmentUniverse corresponding to those assets:

investment_universe = InvestmentUniverse(assets, mu, cov)

Calculate the feasible portfolios:

investment_universe.calculate_feasible_portfolios()

Calculate the MVP:

investment_universe.calculate_mvp()

Calculate the efficient frontier:

investment_universe.calculate_efficient_frontier()

Plot the risk-return trade-off graph of the investment universe:

investment_universe.plot()

Example 2: With a risk-free asset

The risky assets are defined as above:

from pyvest import InvestmentUniverse

assets = ['KO', 'MSFT']
mu = [8, 14]
cov = [[3**2, 0],
       [0, 6**2]]

A risk-free asset of 2% is added to the investment universe:

investment_universe_with_r_f = InvestmentUniverse(assets, mu, cov, r_f=2)

The feasible portfolios, the MVP and the efficient frontier are calculated as above:

investment_universe_with_r_f.calculate_feasible_portfolios()
investment_universe_with_r_f.calculate_mvp()
investment_universe_with_r_f.calculate_efficient_frontier()

Calculate the tangency portfolio:

investment_universe_with_r_f.calculate_tangency_portfolio()

Calculate the CAL:

investment_universe_with_r_f.calculate_cal()

Plot the risk-return trade-off graph of the investment universe with a risk-free asset:

investment_universe_with_r_f.plot()

Project details


Download files

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

Source Distribution

pyvest-0.0.7.tar.gz (42.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyvest-0.0.7-py3-none-any.whl (50.2 kB view details)

Uploaded Python 3

File details

Details for the file pyvest-0.0.7.tar.gz.

File metadata

  • Download URL: pyvest-0.0.7.tar.gz
  • Upload date:
  • Size: 42.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.1

File hashes

Hashes for pyvest-0.0.7.tar.gz
Algorithm Hash digest
SHA256 d4a63fe48e5c73364dccda16343c5b9cf20bd535488213066c6f16f2519c8d3f
MD5 a1ff67ce5892710d0bdb46a5a859ade9
BLAKE2b-256 26ab0f668da5e62cf30ffae872cc8faf46a7f8443d433f92199f8cea50c7645a

See more details on using hashes here.

File details

Details for the file pyvest-0.0.7-py3-none-any.whl.

File metadata

  • Download URL: pyvest-0.0.7-py3-none-any.whl
  • Upload date:
  • Size: 50.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.1

File hashes

Hashes for pyvest-0.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 795a918999e6cef9f548343c77ef6558f17ddcf61d4a61115dfba4242df9099c
MD5 55cccd3d2acfd3f6f4d10d37170cc05a
BLAKE2b-256 56ec43f19088aef3d85226f46c58d957d1545d6ccaab02849e7407aa2b0c1a0a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page