Skip to main content

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

perfattr-0.2.0.tar.gz (77.2 kB view details)

Uploaded Source

Built Distribution

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

perfattr-0.2.0-py3-none-any.whl (42.1 kB view details)

Uploaded Python 3

File details

Details for the file perfattr-0.2.0.tar.gz.

File metadata

  • Download URL: perfattr-0.2.0.tar.gz
  • Upload date:
  • Size: 77.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for perfattr-0.2.0.tar.gz
Algorithm Hash digest
SHA256 dd466502d6933b39dabb6d9179de55adf40aac8bbd4a5cc44bb7ee4cabaf2933
MD5 ee2504c7a1c68b7d165638c93a85219b
BLAKE2b-256 1ed5a5bac3c14bf195f05f1bb93bd09e81b8e1a708880870d0b25a50c00a3e32

See more details on using hashes here.

Provenance

The following attestation bundles were made for perfattr-0.2.0.tar.gz:

Publisher: publish.yml on JohnDReynolds/perfattr

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file perfattr-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: perfattr-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 42.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for perfattr-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4eaa104579dc046b0c37cad6912730c7f693eff128c1c484103899b3b612ecdc
MD5 ad428885673c769119dbb532546d7d65
BLAKE2b-256 94442673d673bd5a56dfa20a2b339c6f579ea4375d7e025c1d0eb8c0886067bd

See more details on using hashes here.

Provenance

The following attestation bundles were made for perfattr-0.2.0-py3-none-any.whl:

Publisher: publish.yml on JohnDReynolds/perfattr

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.3.0

2 files

0.2.2

2 files

0.2.1

2 files

This release

0.2.0 This release

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page