# lithikajmalothu-16/battery-arbitrage-optimizer architecture

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

- Interactive diagram: https://gitdiagram.com/lithikajmalothu-16/battery-arbitrage-optimizer
- Repository: https://github.com/lithikajmalothu-16/battery-arbitrage-optimizer

## Overview

Battery Storage Arbitrage Optimizer forecasts hourly electricity prices, converts forecasts into battery schedules, and compares realized returns with a perfect-foresight ceiling. Its main workflow is the pipeline runner: load a selected data source, build day-ahead features, train a forecaster, optimize daily schedules, and score them against actual prices. Separate entry points provide a reusable forecast/backtest workflow, a full-year ceiling analysis, and plots. The README documents these capabilities; source excerpts show key calls, but the pipeline’s model training and scoring are implemented inline rather than delegated to the separate forecast and backtest modules.

Main entry points: [`src/optimizer.py`](https://github.com/lithikajmalothu-16/battery-arbitrage-optimizer/blob/main/src/optimizer.py) (Battery LP Optimizer), [`src/load_data.py`](https://github.com/lithikajmalothu-16/battery-arbitrage-optimizer/blob/main/src/load_data.py) (Source Router), [`src/features_dayahead.py`](https://github.com/lithikajmalothu-16/battery-arbitrage-optimizer/blob/main/src/features_dayahead.py) (Day-Ahead Features), [`src/run_pipeline.py`](https://github.com/lithikajmalothu-16/battery-arbitrage-optimizer/blob/main/src/run_pipeline.py) (Pipeline Runner)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Price Data"]
  node_synthetic["Synthetic Prices<br/>[data.py]"]
  node_eia["EIA Data Loader<br/>[eia_loader.py]"]
  node_source_router["Source Router<br/>[load_data.py]"]
end

subgraph group_forecast["Forecasting"]
  node_features["Day-Ahead Features"]
  node_forecast_model["Day-Ahead Forecaster"]
end

subgraph group_decisions["Optimization"]
  node_optimizer["Battery LP Optimizer<br/>[optimizer.py]"]
end

subgraph group_analysis["Evaluation"]
  node_pipeline["Pipeline Runner<br/>[run_pipeline.py]"]
  node_backtest["Forecast Backtest<br/>[backtest.py]"]
  node_ceiling["Ceiling Analysis<br/>[run_ceiling.py]"]
  node_plots["Backtest Plots<br/>[plot_backtest.py]"]
end

node_eia_api(("EIA API"))

node_source_router -->|"loads synthetic"| node_synthetic
node_source_router -->|"loads EIA"| node_eia
node_eia -->|"fetches demand"| node_eia_api
node_features -->|"loads data"| node_source_router
node_forecast_model -->|"builds features"| node_features
node_pipeline -->|"builds features"| node_features
node_pipeline -->|"optimizes schedules"| node_optimizer
node_backtest -->|"optimizes schedules"| node_optimizer
node_ceiling -->|"generates prices"| node_synthetic
node_ceiling -->|"optimizes prices"| node_optimizer
node_plots -->|"plans example day"| node_optimizer

click node_synthetic "https://github.com/lithikajmalothu-16/battery-arbitrage-optimizer/blob/main/src/data.py"
click node_eia "https://github.com/lithikajmalothu-16/battery-arbitrage-optimizer/blob/main/src/eia_loader.py"
click node_source_router "https://github.com/lithikajmalothu-16/battery-arbitrage-optimizer/blob/main/src/load_data.py"
click node_features "https://github.com/lithikajmalothu-16/battery-arbitrage-optimizer/blob/main/src/features_dayahead.py"
click node_forecast_model "https://github.com/lithikajmalothu-16/battery-arbitrage-optimizer/blob/main/src/forecast_dayahead.py"
click node_pipeline "https://github.com/lithikajmalothu-16/battery-arbitrage-optimizer/blob/main/src/run_pipeline.py"
click node_optimizer "https://github.com/lithikajmalothu-16/battery-arbitrage-optimizer/blob/main/src/optimizer.py"
click node_backtest "https://github.com/lithikajmalothu-16/battery-arbitrage-optimizer/blob/main/src/backtest.py"
click node_ceiling "https://github.com/lithikajmalothu-16/battery-arbitrage-optimizer/blob/main/src/run_ceiling.py"
click node_plots "https://github.com/lithikajmalothu-16/battery-arbitrage-optimizer/blob/main/src/plot_backtest.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_synthetic,node_eia,node_source_router toneBlue
class node_features,node_forecast_model toneAmber
class node_optimizer,node_eia_api toneMint
class node_pipeline,node_backtest,node_ceiling,node_plots toneRose
```

## Components

### Price Data

- [Synthetic Prices](https://github.com/lithikajmalothu-16/battery-arbitrage-optimizer/blob/main/src/data.py): `src/data.py`
- [EIA Data Loader](https://github.com/lithikajmalothu-16/battery-arbitrage-optimizer/blob/main/src/eia_loader.py): `src/eia_loader.py`
- [Source Router](https://github.com/lithikajmalothu-16/battery-arbitrage-optimizer/blob/main/src/load_data.py): `src/load_data.py`

### Forecasting

- [Day-Ahead Features](https://github.com/lithikajmalothu-16/battery-arbitrage-optimizer/blob/main/src/features_dayahead.py): `src/features_dayahead.py`
- [Day-Ahead Forecaster](https://github.com/lithikajmalothu-16/battery-arbitrage-optimizer/blob/main/src/forecast_dayahead.py): `src/forecast_dayahead.py`

### Optimization

- [Battery LP Optimizer](https://github.com/lithikajmalothu-16/battery-arbitrage-optimizer/blob/main/src/optimizer.py): `src/optimizer.py`

### Evaluation

- [Pipeline Runner](https://github.com/lithikajmalothu-16/battery-arbitrage-optimizer/blob/main/src/run_pipeline.py): `src/run_pipeline.py`
- [Forecast Backtest](https://github.com/lithikajmalothu-16/battery-arbitrage-optimizer/blob/main/src/backtest.py): `src/backtest.py`
- [Ceiling Analysis](https://github.com/lithikajmalothu-16/battery-arbitrage-optimizer/blob/main/src/run_ceiling.py): `src/run_ceiling.py`
- [Backtest Plots](https://github.com/lithikajmalothu-16/battery-arbitrage-optimizer/blob/main/src/plot_backtest.py): `src/plot_backtest.py`

### Other components

- **EIA API**

## Connections

- Source Router → Synthetic Prices: loads synthetic (evidence: `src/load_data.py`)
- Source Router → EIA Data Loader: loads EIA (evidence: `src/load_data.py`)
- EIA Data Loader → EIA API: fetches demand (evidence: `src/eia_loader.py`)
- Day-Ahead Features → Source Router: loads data (evidence: `src/features_dayahead.py`)
- Day-Ahead Forecaster → Day-Ahead Features: builds features (evidence: `src/forecast_dayahead.py`)
- Pipeline Runner → Day-Ahead Features: builds features (evidence: `src/run_pipeline.py`)
- Pipeline Runner → Battery LP Optimizer: optimizes schedules (evidence: `src/run_pipeline.py`)
- Forecast Backtest → Battery LP Optimizer: optimizes schedules (evidence: `src/backtest.py`)
- Ceiling Analysis → Synthetic Prices: generates prices (evidence: `src/run_ceiling.py`)
- Ceiling Analysis → Battery LP Optimizer: optimizes prices (evidence: `src/run_ceiling.py`)
- Backtest Plots → Battery LP Optimizer: plans example day (evidence: `src/plot_backtest.py`)
