Metadata-Version: 2.4
Name: numfolio
Version: 0.1.1
Author-email: agdiiura <andreadiiura@gmail.com>
License: MIT License
        
        Copyright (c) 2025 Andrea
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/agdiiura/numfolio
Project-URL: Documentation, https://numfolio.readthedocs.io/en/stable/index.html
Project-URL: Repository, https://github.com/agdiiura/numfolio.git
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: joblib>=1.3.2
Requires-Dist: pandas>=2.2.1
Requires-Dist: numpy>=1.22
Requires-Dist: scikit-learn>=1.5.0
Requires-Dist: scipy>=1.12.0
Requires-Dist: arch>=6.3.0
Requires-Dist: numba>0.59.0
Provides-Extra: build
Requires-Dist: ruff>=0.11.0; extra == "build"
Requires-Dist: colorama>=0.4.6; extra == "build"
Requires-Dist: coverage>=7.0; extra == "build"
Requires-Dist: isort>=6.0.0; extra == "build"
Requires-Dist: pre-commit>=4.0.0; extra == "build"
Requires-Dist: setuptools-git-versioning>=1.13.4; extra == "build"
Requires-Dist: unittest-xml-reporting>=3.2.0; extra == "build"
Provides-Extra: docs
Requires-Dist: mkdocs>=1.6.0; extra == "docs"
Requires-Dist: mkdocstrings[python]==0.30.0; extra == "docs"
Dynamic: license-file

# 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:
```bash
pip install numfolio
```
Now you can test the installation... In a python shell:

```python
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:

```python
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:

```python
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:

```python
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)
```
