# teddyarvin86-coder/rmt-portfolio architecture

> Architecture diagram of the GitHub repository teddyarvin86-coder/rmt-portfolio, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/teddyarvin86-coder/rmt-portfolio
- Repository: https://github.com/teddyarvin86-coder/rmt-portfolio

## Overview

RMT Portfolio is a quantitative research package for denoising return covariance estimates, constructing portfolios, and evaluating them out of sample. A researcher selects a universe and experiment; price data is loaded and cleaned, covariance spectra are analyzed and denoised, and allocators produce weights for rolling backtests. Separate research workflows assess spectral structure, forecast risk, and robustness, with results and figures as outputs. The README documents these product capabilities; sampled source excerpts are partial, so links between unsampled experiment code and internals reflect documented workflow rather than inspected call sites.

Main entry points: [`experiments/run_main_backtest.py`](https://github.com/teddyarvin86-coder/rmt-portfolio/blob/main/experiments/run_main_backtest.py) (Rolling backtest), [`experiments/run_risk_forecast.py`](https://github.com/teddyarvin86-coder/rmt-portfolio/blob/main/experiments/run_risk_forecast.py) (Risk forecast), [`experiments/run_robustness.py`](https://github.com/teddyarvin86-coder/rmt-portfolio/blob/main/experiments/run_robustness.py) (Robustness scans), [`src/rmt_portfolio/data/loader.py`](https://github.com/teddyarvin86-coder/rmt-portfolio/blob/main/src/rmt_portfolio/data/loader.py) (Price loader)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Market data"]
  node_universe["Asset universes<br/>[universes.py]"]
  node_loader["Price loader<br/>[loader.py]"]
  node_config["Experiment config<br/>[config.py]"]
end

subgraph group_risk["Covariance research"]
  node_mp["MP law<br/>[mp_law.py]"]
  node_denoise["Covariance estimators<br/>[denoise.py]"]
end

subgraph group_portfolio["Portfolio construction"]
  node_optimizer["Weight allocators<br/>[optimizers.py]"]
  node_cluster["HRP clustering<br/>[clustering.py]"]
end

subgraph group_evaluation["Evaluation"]
  node_mainrun["Rolling backtest"]
  node_engine["Walk-forward engine<br/>[engine.py]"]
  node_metrics["Performance metrics<br/>[metrics.py]"]
end

subgraph group_research["Research outputs"]
  node_spectrumrun["Spectrum analysis"]
  node_riskrun["Risk forecast"]
  node_robustrun["Robustness scans<br/>[run_robustness.py]"]
  node_figurerun["Figure generation<br/>[run_figures.py]"]
  node_results["Research results"]
  node_figures["Research figures"]
end

node_researcher(("Researcher"))
node_marketdata["Market data providers"]

node_researcher -->|"runs"| node_mainrun
node_researcher -->|"runs"| node_spectrumrun
node_researcher -->|"runs"| node_riskrun
node_researcher -->|"runs"| node_robustrun
node_researcher -->|"runs"| node_figurerun
node_mainrun -->|"loads settings"| node_config
node_spectrumrun -->|"loads settings"| node_config
node_riskrun -->|"loads settings"| node_config
node_robustrun -->|"loads settings"| node_config
node_loader -->|"selects assets"| node_universe
node_loader -->|"downloads prices"| node_marketdata
node_mainrun -->|"loads returns"| node_loader
node_spectrumrun -->|"loads returns"| node_loader
node_riskrun -->|"loads returns"| node_loader
node_robustrun -->|"loads returns"| node_loader
node_spectrumrun -->|"analyzes spectrum"| node_mp
node_mainrun -->|"estimates covariance"| node_denoise
node_riskrun -->|"evaluates estimators"| node_denoise
node_robustrun -->|"varies estimator settings"| node_denoise
node_denoise -->|"fits MP noise model"| node_mp
node_mainrun -->|"allocates weights"| node_optimizer
node_robustrun -->|"varies allocation settings"| node_optimizer
node_optimizer -->|"uses HRP clustering"| node_cluster
node_mainrun -->|"runs strategies"| node_engine
node_engine -->|"evaluates returns"| node_metrics
node_riskrun -->|"scores risk forecasts"| node_metrics
node_mainrun -->|"writes backtest tables"| node_results
node_spectrumrun -->|"writes spectrum tables"| node_results
node_riskrun -->|"writes forecast tables"| node_results
node_robustrun -->|"writes scan tables"| node_results
node_figurerun -->|"reads result data"| node_results
node_figurerun -->|"writes figures"| node_figures

click node_universe "https://github.com/teddyarvin86-coder/rmt-portfolio/blob/main/src/rmt_portfolio/data/universes.py"
click node_loader "https://github.com/teddyarvin86-coder/rmt-portfolio/blob/main/src/rmt_portfolio/data/loader.py"
click node_config "https://github.com/teddyarvin86-coder/rmt-portfolio/blob/main/src/rmt_portfolio/config.py"
click node_mainrun "https://github.com/teddyarvin86-coder/rmt-portfolio/blob/main/experiments/run_main_backtest.py"
click node_spectrumrun "https://github.com/teddyarvin86-coder/rmt-portfolio/blob/main/experiments/run_spectrum_analysis.py"
click node_riskrun "https://github.com/teddyarvin86-coder/rmt-portfolio/blob/main/experiments/run_risk_forecast.py"
click node_robustrun "https://github.com/teddyarvin86-coder/rmt-portfolio/blob/main/experiments/run_robustness.py"
click node_figurerun "https://github.com/teddyarvin86-coder/rmt-portfolio/blob/main/experiments/run_figures.py"
click node_mp "https://github.com/teddyarvin86-coder/rmt-portfolio/blob/main/src/rmt_portfolio/rmt/mp_law.py"
click node_denoise "https://github.com/teddyarvin86-coder/rmt-portfolio/blob/main/src/rmt_portfolio/rmt/denoise.py"
click node_optimizer "https://github.com/teddyarvin86-coder/rmt-portfolio/blob/main/src/rmt_portfolio/portfolio/optimizers.py"
click node_cluster "https://github.com/teddyarvin86-coder/rmt-portfolio/blob/main/src/rmt_portfolio/portfolio/clustering.py"
click node_engine "https://github.com/teddyarvin86-coder/rmt-portfolio/blob/main/src/rmt_portfolio/backtest/engine.py"
click node_metrics "https://github.com/teddyarvin86-coder/rmt-portfolio/blob/main/src/rmt_portfolio/backtest/metrics.py"
click node_results "https://github.com/teddyarvin86-coder/rmt-portfolio/tree/main/results"
click node_figures "https://github.com/teddyarvin86-coder/rmt-portfolio/tree/main/figures"

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_universe,node_loader,node_config toneBlue
class node_mp,node_denoise toneAmber
class node_optimizer,node_cluster toneMint
class node_mainrun,node_engine,node_metrics toneRose
class node_spectrumrun,node_riskrun,node_robustrun,node_figurerun,node_results,node_figures,node_researcher,node_marketdata toneIndigo
```

## Components

### Market data

- [Asset universes](https://github.com/teddyarvin86-coder/rmt-portfolio/blob/main/src/rmt_portfolio/data/universes.py): `src/rmt_portfolio/data/universes.py`
- [Price loader](https://github.com/teddyarvin86-coder/rmt-portfolio/blob/main/src/rmt_portfolio/data/loader.py): `src/rmt_portfolio/data/loader.py`
- [Experiment config](https://github.com/teddyarvin86-coder/rmt-portfolio/blob/main/src/rmt_portfolio/config.py): `src/rmt_portfolio/config.py`

### Covariance research

- [MP law](https://github.com/teddyarvin86-coder/rmt-portfolio/blob/main/src/rmt_portfolio/rmt/mp_law.py): `src/rmt_portfolio/rmt/mp_law.py`
- [Covariance estimators](https://github.com/teddyarvin86-coder/rmt-portfolio/blob/main/src/rmt_portfolio/rmt/denoise.py): `src/rmt_portfolio/rmt/denoise.py`

### Portfolio construction

- [Weight allocators](https://github.com/teddyarvin86-coder/rmt-portfolio/blob/main/src/rmt_portfolio/portfolio/optimizers.py): `src/rmt_portfolio/portfolio/optimizers.py`
- [HRP clustering](https://github.com/teddyarvin86-coder/rmt-portfolio/blob/main/src/rmt_portfolio/portfolio/clustering.py): `src/rmt_portfolio/portfolio/clustering.py`

### Evaluation

- [Rolling backtest](https://github.com/teddyarvin86-coder/rmt-portfolio/blob/main/experiments/run_main_backtest.py): `experiments/run_main_backtest.py`
- [Walk-forward engine](https://github.com/teddyarvin86-coder/rmt-portfolio/blob/main/src/rmt_portfolio/backtest/engine.py): `src/rmt_portfolio/backtest/engine.py`
- [Performance metrics](https://github.com/teddyarvin86-coder/rmt-portfolio/blob/main/src/rmt_portfolio/backtest/metrics.py): `src/rmt_portfolio/backtest/metrics.py`

### Research outputs

- [Spectrum analysis](https://github.com/teddyarvin86-coder/rmt-portfolio/blob/main/experiments/run_spectrum_analysis.py): `experiments/run_spectrum_analysis.py`
- [Risk forecast](https://github.com/teddyarvin86-coder/rmt-portfolio/blob/main/experiments/run_risk_forecast.py): `experiments/run_risk_forecast.py`
- [Robustness scans](https://github.com/teddyarvin86-coder/rmt-portfolio/blob/main/experiments/run_robustness.py): `experiments/run_robustness.py`
- [Figure generation](https://github.com/teddyarvin86-coder/rmt-portfolio/blob/main/experiments/run_figures.py): `experiments/run_figures.py`
- [Research results](https://github.com/teddyarvin86-coder/rmt-portfolio/tree/main/results): `results`
- [Research figures](https://github.com/teddyarvin86-coder/rmt-portfolio/tree/main/figures): `figures`

### Other components

- **Researcher**
- **Market data providers**

## Connections

- Researcher → Rolling backtest: runs
- Researcher → Spectrum analysis: runs
- Researcher → Risk forecast: runs
- Researcher → Robustness scans: runs
- Researcher → Figure generation: runs
- Rolling backtest → Experiment config: loads settings
- Spectrum analysis → Experiment config: loads settings
- Risk forecast → Experiment config: loads settings
- Robustness scans → Experiment config: loads settings
- Price loader → Asset universes: selects assets
- Price loader → Market data providers: downloads prices
- Rolling backtest → Price loader: loads returns
- Spectrum analysis → Price loader: loads returns
- Risk forecast → Price loader: loads returns
- Robustness scans → Price loader: loads returns
- Spectrum analysis → MP law: analyzes spectrum
- Rolling backtest → Covariance estimators: estimates covariance
- Risk forecast → Covariance estimators: evaluates estimators
- Robustness scans → Covariance estimators: varies estimator settings
- Covariance estimators → MP law: fits MP noise model
- Rolling backtest → Weight allocators: allocates weights
- Robustness scans → Weight allocators: varies allocation settings
- Weight allocators → HRP clustering: uses HRP clustering
- Rolling backtest → Walk-forward engine: runs strategies
- Walk-forward engine → Performance metrics: evaluates returns
- Risk forecast → Performance metrics: scores risk forecasts
- Rolling backtest → Research results: writes backtest tables
- Spectrum analysis → Research results: writes spectrum tables
- Risk forecast → Research results: writes forecast tables
- Robustness scans → Research results: writes scan tables
- Figure generation → Research results: reads result data
- Figure generation → Research figures: writes figures
