Skip to main content

No project description provided

Project description

numfolio ⚡

Portfolio performance accelerated by Numba

A lightweight, flexible Python package for analyzing portfolio returns, risk metrics, and correlations using modern statistical and machine learning methods.


🚀 Features

✅ Bootstrapped metric estimation (e.g., Sharpe Ratio, Sortino Ratio)

✅ Automatic Scorecard Generation with time-based aggregation (Yearly, Quarterly, Monthly)

✅ Covariance and Correlation estimation with robust shrinkage methods

✅ Parallel computation for scalability

✅ Clean, consistent API inspired by scikit-learn & pandas


🔧 Installation

To install the package the simplest procedure is:

pip install numfolio

Now you can test the installation... In a python shell:

import numfolio as nf

nf.__version__

Optional dependencies are docs for documentation and build for development. To install optional dependencies pip install numfolio[docs,build].

📚 Example Usage

1. Compute Scorecard from PnL or Returns:

import pandas as pd
from numfolio import get_scorecard

# Sample PnL data
dates = pd.date_range("2025-01-01", periods=60, freq="D")
pnl = pd.Series(range(100, 160), index=dates)

df = pd.DataFrame({"pnl": pnl})

scorecard = get_scorecard(df, freq="M")
print(scorecard)

2. Estimate Bootstrapped Sharpe Ratio:

import numpy as np
from numfolio import bootstrap_metric

# Generate fake returns
returns = np.random.default_rng().normal(0, 1, 100)

bootstrapped = bootstrap_metric(returns, metric="sharpe_ratio", n_bootstraps=500)
print("Bootstrapped Sharpe Ratios:", bootstrapped[:5])

3. Estimate Correlation Matrix:

import pandas as pd
import numpy as np
from numfolio import estimate_correlation

dates = pd.date_range("2025-01-01", periods=100, freq="D")
returns = pd.DataFrame(np.random.default_rng().normal(0, 1, (100, 3)), columns=["A", "B", "C"], index=dates)

correlation = estimate_correlation(returns, method="ledoit_wolf", n_bootstraps=200)
print(correlation)

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

numfolio-0.0.3.tar.gz (13.8 kB view details)

Uploaded Source

Built Distribution

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

numfolio-0.0.3-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

Details for the file numfolio-0.0.3.tar.gz.

File metadata

  • Download URL: numfolio-0.0.3.tar.gz
  • Upload date:
  • Size: 13.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for numfolio-0.0.3.tar.gz
Algorithm Hash digest
SHA256 0d119de7c004bf6fd19621e87da1b2d3289506cf2a7f2cb88e1e03181247f95b
MD5 8f394055500336c1959e927b957d9de5
BLAKE2b-256 36f1399b315c7b137016f7798f8b9975885b2ba48986d8a986dea0312613a998

See more details on using hashes here.

Provenance

The following attestation bundles were made for numfolio-0.0.3.tar.gz:

Publisher: python-publish.yml on agdiiura/numfolio

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

File details

Details for the file numfolio-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: numfolio-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 11.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for numfolio-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 5665de53d4a059de836927fab6f681744c9a3323d4ae06cca69b57d3682b1f5a
MD5 23ab03358ead5925a75a7aaa79a27ed9
BLAKE2b-256 9b07915ec97f4a1c4003122c9345183a5b5e20a4350d5ad974555306e6e5dca6

See more details on using hashes here.

Provenance

The following attestation bundles were made for numfolio-0.0.3-py3-none-any.whl:

Publisher: python-publish.yml on agdiiura/numfolio

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

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