# stefan-jansen/empyrical-reloaded architecture

> Architecture diagram of the GitHub repository stefan-jansen/empyrical-reloaded, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/stefan-jansen/empyrical-reloaded
- Repository: https://github.com/stefan-jansen/empyrical-reloaded

## Overview

Empyrical is a Python library for calculating financial performance and risk metrics from returns, benchmarks, and related portfolio data. A caller uses its public package API to access single-period or rolling statistics, or performance attribution; the calculations are implemented in separate modules and use shared period conventions and utilities. The README also documents optional market-data retrieval. The SOURCE INDEX confirms stats.py references periods.py and utils.py, and the public exports are visible in __init__.py; other internal call relationships are omitted where excerpts do not establish them.

Main entry points: [`src/empyrical/utils.py`](https://github.com/stefan-jansen/empyrical-reloaded/blob/main/src/empyrical/utils.py) (Rolling and Data Utilities), [`src/empyrical/__init__.py`](https://github.com/stefan-jansen/empyrical-reloaded/blob/main/src/empyrical/__init__.py) (Empyrical API), [`src/empyrical/stats.py`](https://github.com/stefan-jansen/empyrical-reloaded/blob/main/src/empyrical/stats.py) (Return Statistics), [`src/empyrical/periods.py`](https://github.com/stefan-jansen/empyrical-reloaded/blob/main/src/empyrical/periods.py) (Period Conventions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Public API"]
  node_public_api["Empyrical API<br/>[__init__.py]"]
end

subgraph group_calculation["Financial Calculations"]
  node_stats["Return Statistics<br/>[stats.py]"]
  node_attribution["Performance Attribution<br/>[perf_attrib.py]"]
end

subgraph group_support["Shared Support"]
  node_periods["Period Conventions<br/>[periods.py]"]
  node_utils["Rolling and Data Utilities<br/>[utils.py]"]
  node_deprecation["Deprecation Warnings<br/>[deprecate.py]"]
end

node_caller(("Python Caller"))
node_yahoo["Yahoo Finance"]
node_factor_data["Fama-French Data"]
node_fred["FRED Yields"]

node_caller -->|"calls"| node_public_api
node_public_api -->|"exports metrics"| node_stats
node_public_api -->|"exports attribution"| node_attribution
node_public_api -->|"exports periods"| node_periods
node_stats -->|"uses conventions"| node_periods
node_stats -->|"uses utilities"| node_utils
node_caller -->|"requests data"| node_utils
node_utils -.->|"downloads prices"| node_yahoo
node_utils -.->|"downloads factors"| node_factor_data
node_utils -.->|"retrieves yields"| node_fred

click node_public_api "https://github.com/stefan-jansen/empyrical-reloaded/blob/main/src/empyrical/__init__.py"
click node_stats "https://github.com/stefan-jansen/empyrical-reloaded/blob/main/src/empyrical/stats.py"
click node_attribution "https://github.com/stefan-jansen/empyrical-reloaded/blob/main/src/empyrical/perf_attrib.py"
click node_periods "https://github.com/stefan-jansen/empyrical-reloaded/blob/main/src/empyrical/periods.py"
click node_utils "https://github.com/stefan-jansen/empyrical-reloaded/blob/main/src/empyrical/utils.py"
click node_deprecation "https://github.com/stefan-jansen/empyrical-reloaded/blob/main/src/empyrical/deprecate.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_public_api toneBlue
class node_stats,node_attribution toneAmber
class node_periods,node_utils,node_deprecation toneMint
class node_caller,node_yahoo,node_factor_data,node_fred toneIndigo
```

## Components

### Public API

- [Empyrical API](https://github.com/stefan-jansen/empyrical-reloaded/blob/main/src/empyrical/__init__.py): `src/empyrical/__init__.py`

### Financial Calculations

- [Return Statistics](https://github.com/stefan-jansen/empyrical-reloaded/blob/main/src/empyrical/stats.py): `src/empyrical/stats.py`
- [Performance Attribution](https://github.com/stefan-jansen/empyrical-reloaded/blob/main/src/empyrical/perf_attrib.py): `src/empyrical/perf_attrib.py`

### Shared Support

- [Period Conventions](https://github.com/stefan-jansen/empyrical-reloaded/blob/main/src/empyrical/periods.py): `src/empyrical/periods.py`
- [Rolling and Data Utilities](https://github.com/stefan-jansen/empyrical-reloaded/blob/main/src/empyrical/utils.py): `src/empyrical/utils.py`
- [Deprecation Warnings](https://github.com/stefan-jansen/empyrical-reloaded/blob/main/src/empyrical/deprecate.py): `src/empyrical/deprecate.py`

### Other components

- **Python Caller**
- **Yahoo Finance**
- **Fama-French Data**
- **FRED Yields**

## Connections

- Python Caller → Empyrical API: calls (evidence: `README.md`)
- Empyrical API → Return Statistics: exports metrics (evidence: `src/empyrical/__init__.py`)
- Empyrical API → Performance Attribution: exports attribution (evidence: `src/empyrical/__init__.py`)
- Empyrical API → Period Conventions: exports periods (evidence: `src/empyrical/__init__.py`)
- Return Statistics → Period Conventions: uses conventions (evidence: `src/empyrical/stats.py`)
- Return Statistics → Rolling and Data Utilities: uses utilities (evidence: `src/empyrical/stats.py`)
- Python Caller → Rolling and Data Utilities: requests data (evidence: `README.md`)
- Rolling and Data Utilities → Yahoo Finance: downloads prices (evidence: `README.md`)
- Rolling and Data Utilities → Fama-French Data: downloads factors (evidence: `README.md`)
- Rolling and Data Utilities → FRED Yields: retrieves yields (evidence: `README.md`)
