Skip to main content

Python library for PME (Public Market Equivalent) calculation

Project description

pypme – Python library for PME (Public Market Equivalent) calculation

Based on the Modified PME method.

Example

from pypme import verbose_xpme
from datetime import date

pmeirr, assetirr, df = verbose_xpme(
    dates=[date(2015, 1, 1), date(2015, 6, 12), date(2016, 2, 15)],
    cashflows=[-10000, 7500],
    prices=[100, 120, 100],
    pme_prices=[100, 150, 100],
)

Will return 0.5525698793027238 and 0.19495150355969598 for the IRRs and produce this dataframe:

Example dataframe

Notes:

  • The cashflows are interpreted from a transaction account that is used to buy from an asset at price prices.
  • The corresponding prices for the PME are pme_prices.
  • The cashflows is extended with one element representing the remaining value, that's why all the other lists (dates, prices, pme_prices) need to be exactly 1 element longer than cashflows.

Variants

  • xpme: Calculate PME for unevenly spaced / scheduled cashflows and return the PME IRR only. In this case, the IRR is always annual.
  • verbose_xpme: Calculate PME for unevenly spaced / scheduled cashflows and return vebose information.
  • pme: Calculate PME for evenly spaced cashflows and return the PME IRR only. In this case, the IRR is for the underlying period.
  • verbose_pme: Calculate PME for evenly spaced cashflows and return vebose information.

Garbage in, garbage out

Note that the library will only perform essential sanity checks and otherwise just works with what it gets, also with nonsensical data. E.g.:

from pypme import verbose_pme

pmeirr, assetirr, df = verbose_pme(
    cashflows=[-10, 500], prices=[1, 1, 1], pme_prices=[1, 1, 1]
)

Results in this df and IRRs of 0:

Garbage example df

References

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

pypme-0.1.2.tar.gz (4.7 kB view hashes)

Uploaded Source

Built Distribution

pypme-0.1.2-py3-none-any.whl (4.7 kB view hashes)

Uploaded Python 3

Supported by

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