Metadata-Version: 2.5
Name: portpy-quant
Version: 0.1.1
Summary: Portfolio analysis, optimization, and management with built-in, human-readable explanations of every metric, chart, model, and strategy.
Project-URL: Homepage, https://github.com/Arthur-Faugeron/PortPy
Project-URL: Documentation, https://Arthur-Faugeron.github.io/PortPy/
Project-URL: Repository, https://github.com/Arthur-Faugeron/PortPy
Project-URL: Issues, https://github.com/Arthur-Faugeron/PortPy/issues
Project-URL: Changelog, https://github.com/Arthur-Faugeron/PortPy/blob/main/CHANGELOG.md
Author-email: Arthur Lino Faugeron Jacono <faugeronarthur@gmail.com>
License: MIT License
        
        Copyright (c) 2026 Arthur Lino Faugeron Jacono
        
        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.
License-File: LICENSE
Keywords: backtesting,finance,optimization,portfolio,quant,risk
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Financial and Insurance Industry
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Office/Business :: Financial :: Investment
Classifier: Topic :: Scientific/Engineering :: Mathematics
Requires-Python: >=3.10
Requires-Dist: numpy>=1.24
Requires-Dist: pandas>=2.0
Requires-Dist: scipy>=1.10
Requires-Dist: statsmodels>=0.14
Provides-Extra: all
Requires-Dist: alpaca-py>=0.30; extra == 'all'
Requires-Dist: arch>=6.3; extra == 'all'
Requires-Dist: hmmlearn>=0.3.2; extra == 'all'
Requires-Dist: kaleido>=0.2.1; extra == 'all'
Requires-Dist: matplotlib>=3.7; extra == 'all'
Requires-Dist: plotly>=5.18; extra == 'all'
Requires-Dist: python-dotenv>=1.0; extra == 'all'
Requires-Dist: scikit-learn>=1.3; extra == 'all'
Requires-Dist: seaborn>=0.13; extra == 'all'
Requires-Dist: yfinance>=0.2.40; extra == 'all'
Provides-Extra: data
Requires-Dist: alpaca-py>=0.30; extra == 'data'
Requires-Dist: python-dotenv>=1.0; extra == 'data'
Requires-Dist: yfinance>=0.2.40; extra == 'data'
Provides-Extra: dev
Requires-Dist: alpaca-py>=0.30; extra == 'dev'
Requires-Dist: arch>=6.3; extra == 'dev'
Requires-Dist: build>=1.0; extra == 'dev'
Requires-Dist: empyrical-reloaded>=0.5.7; extra == 'dev'
Requires-Dist: hmmlearn>=0.3.2; extra == 'dev'
Requires-Dist: jupyter>=1.0; extra == 'dev'
Requires-Dist: kaleido>=0.2.1; extra == 'dev'
Requires-Dist: matplotlib>=3.7; extra == 'dev'
Requires-Dist: mkdocs-material>=9.5; extra == 'dev'
Requires-Dist: mkdocs>=1.5; extra == 'dev'
Requires-Dist: mkdocstrings[python]>=0.24; extra == 'dev'
Requires-Dist: mypy>=1.8; extra == 'dev'
Requires-Dist: nbformat>=5.9; extra == 'dev'
Requires-Dist: plotly>=5.18; extra == 'dev'
Requires-Dist: pytest-cov>=4.1; extra == 'dev'
Requires-Dist: pytest>=7.4; extra == 'dev'
Requires-Dist: python-dotenv>=1.0; extra == 'dev'
Requires-Dist: quantstats>=0.0.62; extra == 'dev'
Requires-Dist: ruff>=0.4; extra == 'dev'
Requires-Dist: scikit-learn>=1.3; extra == 'dev'
Requires-Dist: seaborn>=0.13; extra == 'dev'
Requires-Dist: yfinance>=0.2.40; extra == 'dev'
Provides-Extra: models
Requires-Dist: arch>=6.3; extra == 'models'
Requires-Dist: hmmlearn>=0.3.2; extra == 'models'
Requires-Dist: scikit-learn>=1.3; extra == 'models'
Provides-Extra: viz
Requires-Dist: kaleido>=0.2.1; extra == 'viz'
Requires-Dist: matplotlib>=3.7; extra == 'viz'
Requires-Dist: plotly>=5.18; extra == 'viz'
Requires-Dist: seaborn>=0.13; extra == 'viz'
Description-Content-Type: text/markdown

# PortPy

**Portfolio analysis that explains itself.**

PortPy is a Python library for portfolio performance measurement and risk analysis, built around one object — `Portfolio` — and one idea: every number it gives you can explain, in plain language, what it is, how to read it, and whether it's good or bad.

[![CI](https://github.com/Arthur-Faugeron/PortPy/actions/workflows/ci.yml/badge.svg)](https://github.com/Arthur-Faugeron/PortPy/actions/workflows/ci.yml)
[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
[![Python 3.10+](https://img.shields.io/badge/python-3.10%2B-blue.svg)](pyproject.toml)

```python
import pandas as pd
from portpy import Portfolio

prices = pd.read_csv("prices.csv", index_col=0, parse_dates=True)  # columns = tickers

portfolio = Portfolio(
    prices,
    weights={"AAPL": 0.4, "MSFT": 0.35, "GOOGL": 0.25},
    name="Tech Portfolio",
    risk_free_rate=0.04,
)

portfolio.metrics.sharpe_ratio(as_result=True).explain()
```

```text
sharpe_ratio (metric)
=====================

What it is:
  Measures excess return earned per unit of total volatility taken, using the risk-free rate as the return hurdle.

Formula:
  mean(r - rf) / std(r - rf, ddof=1) * sqrt(periods_per_year)

How to read it:
  A Sharpe of 1.0 means the strategy generated approximately one unit of excess return for each unit of volatility. Higher values indicate better risk-adjusted performance.

Good vs. bad:
  Higher is generally better. Values above 1 are commonly considered strong, but interpretation depends on the asset class, time period, and strategy complexity.

Caveats:
  Sharpe treats all volatility as bad, including upside volatility. It can also overstate strategies with asymmetric downside risk, illiquidity, or short backtests. The sqrt(periods_per_year) annualization assumes i.i.d., serially uncorrelated returns - positive autocorrelation (illiquid/infrequently-priced assets) means the annualized figure is overstated (Lo, 2002).

This result:
  very good
```

## Why PortPy

- **One object, one namespace.** `portfolio.metrics.<name>()` auto-fills returns, weights,
  risk-free rate, and annualization frequency from the portfolio itself — no re-threading
  the same five arguments through every call.
- **A real portfolio, not just a return stream.** Weights (negative/short included), asset-class
  tags, and explicit calendar-alignment / currency-conversion helpers for combining assets that
  don't trade on the same schedule (crypto, equities, bonds) or in the same currency.
- **Explains itself.** `.explain()` on any result — a plain-language card covering what it is,
  how to read it, good vs. bad, and known caveats.
- **Numerically validated.** Cross-checked against [`empyrical`](https://github.com/stefan-jansen/empyrical-reloaded)
  and [`quantstats`](https://github.com/ranaroussi/quantstats) on real market data — see
  `tests/validation/`.

## Install

```bash
pip install portpy-quant               # core: numpy, pandas, scipy, statsmodels
pip install "portpy-quant[viz]"        # + plotly, matplotlib, seaborn
pip install "portpy-quant[data]"       # + yfinance, alpaca-py (for the examples)
pip install "portpy-quant[all]"        # everything
```

## Documentation

- [Getting Started](./docs/getting-started.md)
- [User Guide](./docs/index.md) — the `Portfolio` object, weights & shorts, calendar/currency
  alignment, the explainability layer
- [API Reference](./docs/api/index.md) — every function, by module
- [Roadmap](./docs/roadmap.md) — what's implemented today vs. planned (`models`, `strategies`,
  `visualization` are not yet built)
- [`examples/`](./examples/) — runnable scripts and a full tutorial notebook exercising every
  metric against live Alpaca + Fed (FRED) data

## Status

PortPy is pre-1.0 (`Development Status :: 4 - Beta`). **Metrics and core** (calendar/currency
alignment, weights, the explainability layer) are implemented and tested. **Visualization,
models/optimization, and strategies/backtesting** are designed but not yet built — see the
[Roadmap](./docs/roadmap.md).

## License

[MIT](LICENSE) © Arthur Faugeron