Skip to main content

A python-based application that produces multi-period attribution, contribution, and benchmark-relative ex-post risk statistics.

Project description

portfolio-performance-analytics

portfolio-performance-analytics (ppar) is a python package that produces holdings-based multi-period performance attribution, contribution, and benchmark-relative ex-post risk statistics.

License

Table of Contents


Description

portfolio-performance-analytics is a python package (https://pypi.org/project/ppar/) that produces holdings-based multi-period performance attribution, contribution, and benchmark-relative ex-post risk statistics. It uses the Brinson-Fachler methodology for calculating attribution effects, and uses the Carino method for logarithmically-smoothing cumulative effects over multi-period time frames.


Features

The below sample outputs portray a large-cap alpha strategy that has achieved a high active return of 1737 bps over the benchmark. In the total lines of the Economic Sector Attribution reports, you can see that this active return can be broken down into 359 bps in sector allocation and 1378 bps in selecting securities. From the Risk Statistics report, you can see that this has been accomplished with a lower downside probabilty than the benchmark (29% vs 36%), and a higher annualized sharpe ratio than the benchmark (2.02 vs 1.27). The largest contributor to active performance was in the Information Technology Sector. Although the portfolio was slightly under-allocated in the Information Technology sector (by -0.05%), it did an excellent job of selecting securities for a total active contribution of 431 bps in the sector.

  • Attribution & Contribution:
Overall Attribution by Economic Sector Chart


Overall Contribution by Economic Sector Chart


Sub-Period Attribution Effects by Economic Sector Chart


Sub-Period Returns Chart


Active Contributions by Economic Sector Chart


Total Attribution Effects by Economic Sector Chart


Cumulative Attribution Effect by Economic Sector Chart


Cumulative Returns


Cumulative Attribution by Economic Sector Table


Overall Attribution by Economic Sector Table


Overall Attribution by Security Table


  • Ex-Post Risk Statistics:
Risk Statistics

Inputs

The inputs required to produce the analytics fall into three categories:

  1. Periodic "classification-level" weights and returns for a portfolio and its benchmark. A "classification" can be any category such as region, country, economic sector, industry, security, etc. The weights and returns must satisfy the formula: SumOf(weights * returns) = Total Return. They will typically be beginning-of-period weights and period returns. (Required)
  2. Classification items and descriptions. (Optional)
  3. Mappings from the classification scheme of the weights and returns to a reporting classification. (Optional)

The input data may be provided directly as either:

  1. Pandas DataFrames.
  2. Polars DataFrames.
  3. Python dictionaries (for Classifications and Mappings).
  4. csv files.

For sample input data sources, please refer to the python script demo.py and the ppar/demo_data directory. Once the input data has been provided, then the analytics may be requested using different calculation parameters, time-periods, and frequencies:

  1. Daily (or for whatever data frequency is provided).
  2. Monthly
  3. Quarterly
  4. Yearly

Typically, a user will develop their own "data source" functions that provide the data in one of the above formats. The python script "demo.py" has sample data source functions.


Outputs

The outputs are represented by different views and charts. See Features above. They may be delivered in different formats:

  1. csv files
  2. html strings
  3. json strings
  4. Pandas DataFrames
  5. png files
  6. Polars DataFrames
  7. Python "great tables"
  8. xml strings

Users can also develop their own "presentation layer" using the various output formats as the inputs to their presentation layer.


Installation

pip install ppar


Usage

python demo.py


Technical

Being built on top of Polars dataframes, ppar is able to efficiently process large datasets through parallel processing, vectorization, lazy evaluation, and using Apache Arrow as its underlying data format.


Enhancements

Future enhancements may include:

  1. Break out the interaction (cross-product) effect. It is currently included in the selection effect.
  2. Break out the currency effect.
  3. Break out the long and short sides.
  4. Add additional multi-period smoothing algorithms (e.g. Menchero).
  5. Support time-series of risk-free rates (as opposed to a single annual rate).
  6. Calculate additional risk statistics.

Support

If you find this project helpful, consider sponsoring it at https://github.com/sponsors/JohnDReynolds to help keep it going!

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

ppar-0.1.3.tar.gz (312.0 kB view details)

Uploaded Source

Built Distribution

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

ppar-0.1.3-py3-none-any.whl (314.4 kB view details)

Uploaded Python 3

File details

Details for the file ppar-0.1.3.tar.gz.

File metadata

  • Download URL: ppar-0.1.3.tar.gz
  • Upload date:
  • Size: 312.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.1

File hashes

Hashes for ppar-0.1.3.tar.gz
Algorithm Hash digest
SHA256 d19e17bd7508796dae1f21efdcd0b02cf620bf5cb24a72a421321b2f99c890ab
MD5 d5917e0d52d6b90f943e6297b462d50a
BLAKE2b-256 dc68e67db648ccc061d475d83fa713c8aa36582e0fe8ded170a9851d765f6a1c

See more details on using hashes here.

File details

Details for the file ppar-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: ppar-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 314.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.1

File hashes

Hashes for ppar-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 811f9cedc4d096cf77b3bc0200b8c5bbc8b38b6dcd6afdf98035447f271ad159
MD5 a803065d989f1e5ee094fef9b59d1ace
BLAKE2b-256 b79d232c376485adbde9408dd4dcbaf9a143bda745c4b19ab37ba653248a7331

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