perfattr
perfattr is a small, auditable portfolio performance-attribution calculation
library built with pandas and NumPy.
The package provides a reusable Brinson-Fachler calculation core and a portable preparation layer for source-period weights and returns. Portfolio accounting, vendor schemas, and presentation remain outside the package boundary.
The calculation core accepts one or more prepared reporting periods and provides
input validation, universe equalization, Brinson-Fachler allocation and selection,
logarithmic contribution linking, Carino active-effect linking, cumulative and
full-horizon results, and financial reconciliation. The completed initial roadmap is
recorded in _extras/perfattr_roadmap_1.md. The
portable preparation work is governed by
_extras/perfattr_roadmap_2.md, while later candidates
are kept in the noncommitted
_extras/perfattr_roadmap_3.md. The complete portable
calculation contract is defined in docs/specification.md,
and the roadmap 2 preparation contract is in
docs/preparation_specification.md.
import pandas as pd
from perfattr import calculate_attribution, prepare_attribution
portfolio = pd.DataFrame(
[
{
"from_date": "2024-01-01",
"thru_date": "2024-01-31",
"identifier": "Equity",
"weight": 0.60,
"return": 0.04,
},
{
"from_date": "2024-01-01",
"thru_date": "2024-01-31",
"identifier": "Bonds",
"weight": 0.40,
"return": 0.01,
},
]
)
benchmark = pd.DataFrame(
[
{
"from_date": "2024-01-01",
"thru_date": "2024-01-31",
"identifier": "Equity",
"weight": 0.50,
"return": 0.03,
},
{
"from_date": "2024-01-01",
"thru_date": "2024-01-31",
"identifier": "Bonds",
"weight": 0.50,
"return": 0.015,
},
]
)
prepared = prepare_attribution(portfolio, benchmark)
result = calculate_attribution(prepared.portfolio, prepared.benchmark)
print(result.period_detail)
Canonical CSV inputs can be loaded with read_performance_csv; optional mapping and
classification readers are also available at the package root.
Development
Create and activate a virtual environment:
python3 -m venv .venv
source .venv/bin/activate
Install the package and development dependencies:
python -m pip install --editable ".[dev]"
Run the initial checks:
python -m pytest
python -m pylint src/perfattr tests scripts
python -m pyright
Run the four roadmap performance workloads:
python scripts/benchmark_core.py --samples 5
python scripts/benchmark_core.py --samples 5 --input-form authoritative
Add --workload monthly_121260 --profile to inspect one workload's cumulative
call profile. The benchmark methodology and initial observations are recorded in
docs/performance.md.
License
perfattr is distributed under the MIT License.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file perfattr-0.2.1.tar.gz.
File metadata
- Download URL: perfattr-0.2.1.tar.gz
- Upload date:
- Size: 78.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b66f7845144d8fb495b5f59e5aeb615d57699b51803576e917c6a8989b0a21f2
|
|
| MD5 |
52abdfa0194979df31ba48af66acb0f2
|
|
| BLAKE2b-256 |
2c1a50d4f0ca923728f8d3baf01ebfefcd46e955a41dbabcfa15e268abc17ad9
|
Provenance
The following attestation bundles were made for perfattr-0.2.1.tar.gz:
Publisher:
publish.yml on JohnDReynolds/perfattr
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
perfattr-0.2.1.tar.gz -
Subject digest:
b66f7845144d8fb495b5f59e5aeb615d57699b51803576e917c6a8989b0a21f2 - Sigstore transparency entry: 2713310143
- Sigstore integration time:
-
Permalink:
JohnDReynolds/perfattr@2c8a057e9f0ae414eeac40160e429d6105ccff15 -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/JohnDReynolds
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@2c8a057e9f0ae414eeac40160e429d6105ccff15 -
Trigger Event:
release
-
Statement type:
File details
Details for the file perfattr-0.2.1-py3-none-any.whl.
File metadata
- Download URL: perfattr-0.2.1-py3-none-any.whl
- Upload date:
- Size: 43.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7fe66344363f845bb2701422dc4b72a920c65039165fae3ab0e203c9a0ef487f
|
|
| MD5 |
879c15be68d524201e884bb195d639a8
|
|
| BLAKE2b-256 |
78d075efb08bc882a64de587d155ff5ee4d6c4b63fd9c6d87617236ae8422a0d
|
Provenance
The following attestation bundles were made for perfattr-0.2.1-py3-none-any.whl:
Publisher:
publish.yml on JohnDReynolds/perfattr
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
perfattr-0.2.1-py3-none-any.whl -
Subject digest:
7fe66344363f845bb2701422dc4b72a920c65039165fae3ab0e203c9a0ef487f - Sigstore transparency entry: 2713310190
- Sigstore integration time:
-
Permalink:
JohnDReynolds/perfattr@2c8a057e9f0ae414eeac40160e429d6105ccff15 -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/JohnDReynolds
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@2c8a057e9f0ae414eeac40160e429d6105ccff15 -
Trigger Event:
release
-
Statement type: