# kholmetskii/realized-vol architecture

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

- Interactive diagram: https://gitdiagram.com/kholmetskii/realized-vol
- Repository: https://github.com/kholmetskii/realized-vol

## Overview

This Python package downloads Dukascopy tick data, turns quotes into FX-session realized variance, and compares next-session forecasts through a walk-forward evaluation. The principal workflow runs from tick acquisition through daily RV, forecast-table preparation, model refitting, smearing correction, and statistical scoring. README statements and sampled source support the main stages; several secondary evaluation capabilities are documented but their precise runtime wiring is not fully sampled.

Main entry points: [`src/rvol/experiment.py`](https://github.com/kholmetskii/realized-vol/blob/main/src/rvol/experiment.py) (Experiment workflow), [`src/rvol/data/volatility/dataset.py`](https://github.com/kholmetskii/realized-vol/blob/main/src/rvol/data/volatility/dataset.py) (Daily RV dataset), [`src/rvol/data/sources/dukascopy/download.py`](https://github.com/kholmetskii/realized-vol/blob/main/src/rvol/data/sources/dukascopy/download.py) (Range downloader), [`src/rvol/data/sources/dukascopy/dukascopy_client.py`](https://github.com/kholmetskii/realized-vol/blob/main/src/rvol/data/sources/dukascopy/dukascopy_client.py) (HTTP client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_acquisition["Tick acquisition"]
  node_downloader["Range downloader<br/>[download.py]"]
  node_client["HTTP client"]
  node_decoder["Tick decoder<br/>[decoding.py]"]
  node_cache[("Hourly cache<br/>[raw_hour_cache.py]")]
end

subgraph group_marketdata["Market data"]
  node_ticks["Tick files"]
  node_sessions["FX sessions<br/>[sessions.py]"]
  node_estimators["RV estimators<br/>[variance.py]"]
  node_daily["Daily RV dataset<br/>[dataset.py]"]
end

subgraph group_forecasting["Forecasting"]
  node_features["Trailing features"]
  node_targets["Forecast targets<br/>[targets.py]"]
  node_table["Forecast table<br/>[forecast_data.py]"]
  node_experiment["Experiment workflow<br/>[experiment.py]"]
  node_model["Model wrapper<br/>[forecast_model.py]"]
  node_rules["Forecast rules"]
  node_walkforward["Walk-forward<br/>[walk_forward.py]"]
end

subgraph group_evaluation["Evaluation"]
  node_smearing["Smearing correction<br/>[smearing.py]"]
  node_scoring["QLIKE scoring<br/>[qlike.py]"]
  node_dm["DM comparison<br/>[diebold_mariano.py]"]
  node_robustness["Robustness checks<br/>[robustness.py]"]
  node_results["Comparison results<br/>[experiment.py]"]
end

node_user(("Researcher"))
node_feed["Dukascopy feed"]

node_user -->|"requests range"| node_downloader
node_downloader -->|"fetches hours"| node_client
node_client -->|"requests data"| node_feed
node_downloader -->|"reads/writes hours"| node_cache
node_downloader -->|"decodes hours"| node_decoder
node_user -->|"builds dataset"| node_daily
node_ticks -->|"reads tick chunks"| node_daily
node_daily -->|"assigns sessions"| node_sessions
node_daily -->|"estimates variance"| node_estimators
node_user -->|"runs comparison"| node_experiment
node_experiment -->|"builds features"| node_features
node_experiment -->|"builds targets"| node_targets
node_experiment -->|"prepares table"| node_table
node_daily -->|"supplies daily RV"| node_experiment
node_experiment -->|"runs forecasts"| node_walkforward
node_walkforward -->|"fits model"| node_model
node_model -->|"delegates fitting"| node_rules
node_experiment -->|"corrects forecasts"| node_smearing
node_experiment -->|"scores QLIKE"| node_scoring
node_scoring -->|"compares losses"| node_dm
node_experiment -->|"summarizes results"| node_results
node_user -.->|"may inspect robustness"| node_robustness

click node_downloader "https://github.com/kholmetskii/realized-vol/blob/main/src/rvol/data/sources/dukascopy/download.py"
click node_client "https://github.com/kholmetskii/realized-vol/blob/main/src/rvol/data/sources/dukascopy/dukascopy_client.py"
click node_decoder "https://github.com/kholmetskii/realized-vol/blob/main/src/rvol/data/sources/dukascopy/decoding.py"
click node_cache "https://github.com/kholmetskii/realized-vol/blob/main/src/rvol/data/sources/dukascopy/raw_hour_cache.py"
click node_sessions "https://github.com/kholmetskii/realized-vol/blob/main/src/rvol/data/market/sessions.py"
click node_estimators "https://github.com/kholmetskii/realized-vol/blob/main/src/rvol/estimators/variance.py"
click node_daily "https://github.com/kholmetskii/realized-vol/blob/main/src/rvol/data/volatility/dataset.py"
click node_features "https://github.com/kholmetskii/realized-vol/blob/main/src/rvol/data/preparation/trailing_mean_features.py"
click node_targets "https://github.com/kholmetskii/realized-vol/blob/main/src/rvol/data/preparation/targets.py"
click node_table "https://github.com/kholmetskii/realized-vol/blob/main/src/rvol/data/preparation/forecast_data.py"
click node_experiment "https://github.com/kholmetskii/realized-vol/blob/main/src/rvol/experiment.py"
click node_model "https://github.com/kholmetskii/realized-vol/blob/main/src/rvol/models/forecast_model.py"
click node_rules "https://github.com/kholmetskii/realized-vol/blob/main/src/rvol/models/linear_regression.py"
click node_walkforward "https://github.com/kholmetskii/realized-vol/blob/main/src/rvol/walkforward/walk_forward.py"
click node_smearing "https://github.com/kholmetskii/realized-vol/blob/main/src/rvol/walkforward/smearing.py"
click node_scoring "https://github.com/kholmetskii/realized-vol/blob/main/src/rvol/evaluation/qlike.py"
click node_dm "https://github.com/kholmetskii/realized-vol/blob/main/src/rvol/evaluation/diebold_mariano.py"
click node_robustness "https://github.com/kholmetskii/realized-vol/blob/main/src/rvol/evaluation/robustness.py"
click node_results "https://github.com/kholmetskii/realized-vol/blob/main/src/rvol/experiment.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_downloader,node_client,node_decoder,node_cache toneBlue
class node_ticks,node_sessions,node_estimators,node_daily toneAmber
class node_features,node_targets,node_table,node_experiment,node_model,node_rules,node_walkforward toneMint
class node_smearing,node_scoring,node_dm,node_robustness,node_results toneRose
class node_user,node_feed toneIndigo
```

## Components

### Tick acquisition

- [Range downloader](https://github.com/kholmetskii/realized-vol/blob/main/src/rvol/data/sources/dukascopy/download.py): `src/rvol/data/sources/dukascopy/download.py`
- [HTTP client](https://github.com/kholmetskii/realized-vol/blob/main/src/rvol/data/sources/dukascopy/dukascopy_client.py): `src/rvol/data/sources/dukascopy/dukascopy_client.py`
- [Tick decoder](https://github.com/kholmetskii/realized-vol/blob/main/src/rvol/data/sources/dukascopy/decoding.py): `src/rvol/data/sources/dukascopy/decoding.py`
- [Hourly cache](https://github.com/kholmetskii/realized-vol/blob/main/src/rvol/data/sources/dukascopy/raw_hour_cache.py): `src/rvol/data/sources/dukascopy/raw_hour_cache.py`

### Market data

- **Tick files**
- [FX sessions](https://github.com/kholmetskii/realized-vol/blob/main/src/rvol/data/market/sessions.py): `src/rvol/data/market/sessions.py`
- [RV estimators](https://github.com/kholmetskii/realized-vol/blob/main/src/rvol/estimators/variance.py): `src/rvol/estimators/variance.py`
- [Daily RV dataset](https://github.com/kholmetskii/realized-vol/blob/main/src/rvol/data/volatility/dataset.py): `src/rvol/data/volatility/dataset.py`

### Forecasting

- [Trailing features](https://github.com/kholmetskii/realized-vol/blob/main/src/rvol/data/preparation/trailing_mean_features.py): `src/rvol/data/preparation/trailing_mean_features.py`
- [Forecast targets](https://github.com/kholmetskii/realized-vol/blob/main/src/rvol/data/preparation/targets.py): `src/rvol/data/preparation/targets.py`
- [Forecast table](https://github.com/kholmetskii/realized-vol/blob/main/src/rvol/data/preparation/forecast_data.py): `src/rvol/data/preparation/forecast_data.py`
- [Experiment workflow](https://github.com/kholmetskii/realized-vol/blob/main/src/rvol/experiment.py): `src/rvol/experiment.py`
- [Model wrapper](https://github.com/kholmetskii/realized-vol/blob/main/src/rvol/models/forecast_model.py): `src/rvol/models/forecast_model.py`
- [Forecast rules](https://github.com/kholmetskii/realized-vol/blob/main/src/rvol/models/linear_regression.py): `src/rvol/models/linear_regression.py`
- [Walk-forward](https://github.com/kholmetskii/realized-vol/blob/main/src/rvol/walkforward/walk_forward.py): `src/rvol/walkforward/walk_forward.py`

### Evaluation

- [Smearing correction](https://github.com/kholmetskii/realized-vol/blob/main/src/rvol/walkforward/smearing.py): `src/rvol/walkforward/smearing.py`
- [QLIKE scoring](https://github.com/kholmetskii/realized-vol/blob/main/src/rvol/evaluation/qlike.py): `src/rvol/evaluation/qlike.py`
- [DM comparison](https://github.com/kholmetskii/realized-vol/blob/main/src/rvol/evaluation/diebold_mariano.py): `src/rvol/evaluation/diebold_mariano.py`
- [Robustness checks](https://github.com/kholmetskii/realized-vol/blob/main/src/rvol/evaluation/robustness.py): `src/rvol/evaluation/robustness.py`
- [Comparison results](https://github.com/kholmetskii/realized-vol/blob/main/src/rvol/experiment.py): `src/rvol/experiment.py`

### Other components

- **Researcher**
- **Dukascopy feed**

## Connections

- Researcher → Range downloader: requests range (evidence: `README.md`)
- Range downloader → HTTP client: fetches hours (evidence: `src/rvol/data/sources/dukascopy/download.py`)
- HTTP client → Dukascopy feed: requests data (evidence: `src/rvol/data/sources/dukascopy/dukascopy_client.py`)
- Range downloader → Hourly cache: reads/writes hours (evidence: `src/rvol/data/sources/dukascopy/download.py`)
- Range downloader → Tick decoder: decodes hours (evidence: `src/rvol/data/sources/dukascopy/download.py`)
- Researcher → Daily RV dataset: builds dataset (evidence: `README.md`)
- Tick files → Daily RV dataset: reads tick chunks (evidence: `src/rvol/data/volatility/dataset.py`)
- Daily RV dataset → FX sessions: assigns sessions (evidence: `src/rvol/data/volatility/dataset.py`)
- Daily RV dataset → RV estimators: estimates variance (evidence: `src/rvol/data/volatility/dataset.py`)
- Researcher → Experiment workflow: runs comparison (evidence: `README.md`)
- Experiment workflow → Trailing features: builds features (evidence: `src/rvol/experiment.py`)
- Experiment workflow → Forecast targets: builds targets (evidence: `src/rvol/experiment.py`)
- Experiment workflow → Forecast table: prepares table (evidence: `src/rvol/experiment.py`)
- Daily RV dataset → Experiment workflow: supplies daily RV (evidence: `README.md`)
- Experiment workflow → Walk-forward: runs forecasts (evidence: `src/rvol/experiment.py`)
- Walk-forward → Model wrapper: fits model (evidence: `src/rvol/walkforward/walk_forward.py`)
- Model wrapper → Forecast rules: delegates fitting (evidence: `src/rvol/models/forecast_model.py`)
- Experiment workflow → Smearing correction: corrects forecasts (evidence: `src/rvol/experiment.py`)
- Experiment workflow → QLIKE scoring: scores QLIKE (evidence: `src/rvol/experiment.py`)
- QLIKE scoring → DM comparison: compares losses
- Experiment workflow → Comparison results: summarizes results (evidence: `src/rvol/experiment.py`)
- Researcher → Robustness checks: may inspect robustness (evidence: `README.md`)
