# aureusa/financial_forecasting architecture

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

- Interactive diagram: https://gitdiagram.com/aureusa/financial_forecasting
- Repository: https://github.com/aureusa/financial_forecasting

## Overview

This repository is a stock and cryptocurrency forecasting framework with an MLP–LSTM ensemble and a rolling trading simulator. Its main workflow retrieves market prices, derives SMA trends and residuals, trains separate models, and combines their predictions for evaluation; a second workflow repeatedly retrains models and simulates portfolio decisions. The graph reflects the README’s documented capabilities and the shown call/import evidence; some simulator internals are only partially excerpted, so uncertain links are omitted or marked unverified.

Main entry points: [`forecast/forecastFactoryEnsemble.py`](https://github.com/aureusa/financial_forecasting/blob/main/forecast/forecastFactoryEnsemble.py) (Forecast workflow), [`pipelines/training.py`](https://github.com/aureusa/financial_forecasting/blob/main/pipelines/training.py) (Train workflow), [`market/dynamic.py`](https://github.com/aureusa/financial_forecasting/blob/main/market/dynamic.py) (Trading environment), [`naive_model/network_constructor.py`](https://github.com/aureusa/financial_forecasting/blob/main/naive_model/network_constructor.py) (Network construction)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_market_data["Market data"]
  node_stock["Stock retrieval<br/>[stockGetter.py]"]
  node_datapipeline["Feature preparation<br/>[dataPipeline.py]"]
  node_marketdata["Market features<br/>[data.py]"]
end

subgraph group_learning["Model training"]
  node_training["Train workflow<br/>[training.py]"]
  node_constructor["Network construction"]
  node_mlp["MLP residual model<br/>[mlp.py]"]
  node_lstm["LSTM trend model<br/>[lstm.py]"]
  node_normalizer["Data normalization<br/>[normalizer.py]"]
  node_savedmodels["Saved models"]
end

subgraph group_forecast["Forecasting"]
  node_forecastfactory["Forecast workflow"]
  node_ensemble["Ensemble prediction<br/>[ensembleModel.py]"]
end

subgraph group_simulation["Market simulation"]
  node_marketworkflow["Simulation workflow<br/>[market_sim.py]"]
  node_environment["Trading environment<br/>[dynamic.py]"]
  node_datamaker["Simulation data<br/>[data.py]"]
  node_rolling["Rolling models<br/>[model.py]"]
  node_stateutils["State persistence<br/>[utils.py]"]
end

subgraph group_analysis["Evaluation"]
  node_testing["Forecast testing<br/>[testing.py]"]
  node_plotter["Prediction plots"]
end

node_user(("User"))
node_yahoo(("Yahoo Finance"))

node_user -->|"starts training"| node_training
node_training -->|"prepares data"| node_datapipeline
node_datapipeline -->|"retrieves prices"| node_stock
node_stock -->|"downloads prices"| node_yahoo
node_training -->|"trains networks"| node_constructor
node_constructor -->|"constructs model"| node_mlp
node_constructor -.->|"constructs model"| node_lstm
node_training -.->|"saves models"| node_savedmodels
node_user -->|"requests forecast"| node_forecastfactory
node_forecastfactory -->|"loads market data"| node_datapipeline
node_forecastfactory -->|"requests predictions"| node_ensemble
node_ensemble -->|"predicts residuals"| node_mlp
node_ensemble -->|"predicts trend"| node_lstm
node_testing -->|"evaluates forecasts"| node_forecastfactory
node_forecastfactory -->|"plots predictions"| node_plotter
node_user -->|"starts simulation"| node_marketworkflow
node_marketworkflow -->|"rolls market"| node_environment
node_environment -.->|"gets features"| node_datamaker
node_environment -.->|"retraining models"| node_rolling
node_rolling -->|"trains residual model"| node_mlp
node_rolling -->|"trains trend model"| node_lstm
node_environment -->|"saves state"| node_stateutils
node_datamaker -->|"retrieves prices"| node_stock

click node_stock "https://github.com/aureusa/financial_forecasting/blob/main/data_pipeline/stockGetter.py"
click node_datapipeline "https://github.com/aureusa/financial_forecasting/blob/main/data_pipeline/dataPipeline.py"
click node_marketdata "https://github.com/aureusa/financial_forecasting/blob/main/market/data.py"
click node_training "https://github.com/aureusa/financial_forecasting/blob/main/pipelines/training.py"
click node_constructor "https://github.com/aureusa/financial_forecasting/blob/main/naive_model/network_constructor.py"
click node_mlp "https://github.com/aureusa/financial_forecasting/blob/main/naive_model/mlp.py"
click node_lstm "https://github.com/aureusa/financial_forecasting/blob/main/naive_model/lstm.py"
click node_normalizer "https://github.com/aureusa/financial_forecasting/blob/main/naive_model/normalizer.py"
click node_savedmodels "https://github.com/aureusa/financial_forecasting/tree/main/saved_models"
click node_forecastfactory "https://github.com/aureusa/financial_forecasting/blob/main/forecast/forecastFactoryEnsemble.py"
click node_ensemble "https://github.com/aureusa/financial_forecasting/blob/main/forecast/ensembleModel.py"
click node_testing "https://github.com/aureusa/financial_forecasting/blob/main/pipelines/testing.py"
click node_plotter "https://github.com/aureusa/financial_forecasting/blob/main/visualisation/visualize_simple.py"
click node_marketworkflow "https://github.com/aureusa/financial_forecasting/blob/main/pipelines/market_sim.py"
click node_environment "https://github.com/aureusa/financial_forecasting/blob/main/market/dynamic.py"
click node_datamaker "https://github.com/aureusa/financial_forecasting/blob/main/market/data.py"
click node_rolling "https://github.com/aureusa/financial_forecasting/blob/main/market/model.py"
click node_stateutils "https://github.com/aureusa/financial_forecasting/blob/main/utils.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_stock,node_datapipeline,node_marketdata,node_user toneBlue
class node_training,node_constructor,node_mlp,node_lstm,node_normalizer,node_savedmodels toneAmber
class node_forecastfactory,node_ensemble toneMint
class node_marketworkflow,node_environment,node_datamaker,node_rolling,node_stateutils toneRose
class node_testing,node_plotter,node_yahoo toneIndigo
```

## Components

### Market data

- [Stock retrieval](https://github.com/aureusa/financial_forecasting/blob/main/data_pipeline/stockGetter.py): `data_pipeline/stockGetter.py`
- [Feature preparation](https://github.com/aureusa/financial_forecasting/blob/main/data_pipeline/dataPipeline.py): `data_pipeline/dataPipeline.py`
- [Market features](https://github.com/aureusa/financial_forecasting/blob/main/market/data.py): `market/data.py`

### Model training

- [Train workflow](https://github.com/aureusa/financial_forecasting/blob/main/pipelines/training.py): `pipelines/training.py`
- [Network construction](https://github.com/aureusa/financial_forecasting/blob/main/naive_model/network_constructor.py): `naive_model/network_constructor.py`
- [MLP residual model](https://github.com/aureusa/financial_forecasting/blob/main/naive_model/mlp.py): `naive_model/mlp.py`
- [LSTM trend model](https://github.com/aureusa/financial_forecasting/blob/main/naive_model/lstm.py): `naive_model/lstm.py`
- [Data normalization](https://github.com/aureusa/financial_forecasting/blob/main/naive_model/normalizer.py): `naive_model/normalizer.py`
- [Saved models](https://github.com/aureusa/financial_forecasting/tree/main/saved_models): `saved_models`

### Forecasting

- [Forecast workflow](https://github.com/aureusa/financial_forecasting/blob/main/forecast/forecastFactoryEnsemble.py): `forecast/forecastFactoryEnsemble.py`
- [Ensemble prediction](https://github.com/aureusa/financial_forecasting/blob/main/forecast/ensembleModel.py): `forecast/ensembleModel.py`

### Market simulation

- [Simulation workflow](https://github.com/aureusa/financial_forecasting/blob/main/pipelines/market_sim.py): `pipelines/market_sim.py`
- [Trading environment](https://github.com/aureusa/financial_forecasting/blob/main/market/dynamic.py): `market/dynamic.py`
- [Simulation data](https://github.com/aureusa/financial_forecasting/blob/main/market/data.py): `market/data.py`
- [Rolling models](https://github.com/aureusa/financial_forecasting/blob/main/market/model.py): `market/model.py`
- [State persistence](https://github.com/aureusa/financial_forecasting/blob/main/utils.py): `utils.py`

### Evaluation

- [Forecast testing](https://github.com/aureusa/financial_forecasting/blob/main/pipelines/testing.py): `pipelines/testing.py`
- [Prediction plots](https://github.com/aureusa/financial_forecasting/blob/main/visualisation/visualize_simple.py): `visualisation/visualize_simple.py`

### Other components

- **User**
- **Yahoo Finance**

## Connections

- User → Train workflow: starts training (evidence: `README.md`)
- Train workflow → Feature preparation: prepares data (evidence: `pipelines/training.py`)
- Feature preparation → Stock retrieval: retrieves prices (evidence: `data_pipeline/dataPipeline.py`)
- Stock retrieval → Yahoo Finance: downloads prices (evidence: `data_pipeline/stockGetter.py`)
- Train workflow → Network construction: trains networks (evidence: `pipelines/training.py`)
- Network construction → MLP residual model: constructs model (evidence: `naive_model/network_constructor.py`)
- Network construction → LSTM trend model: constructs model
- Train workflow → Saved models: saves models
- User → Forecast workflow: requests forecast (evidence: `README.md`)
- Forecast workflow → Feature preparation: loads market data (evidence: `forecast/forecastFactoryEnsemble.py`)
- Forecast workflow → Ensemble prediction: requests predictions (evidence: `forecast/forecastFactoryEnsemble.py`)
- Ensemble prediction → MLP residual model: predicts residuals (evidence: `forecast/ensembleModel.py`)
- Ensemble prediction → LSTM trend model: predicts trend (evidence: `forecast/ensembleModel.py`)
- Forecast testing → Forecast workflow: evaluates forecasts (evidence: `pipelines/testing.py`)
- Forecast workflow → Prediction plots: plots predictions (evidence: `forecast/forecastFactoryEnsemble.py`)
- User → Simulation workflow: starts simulation (evidence: `README.md`)
- Simulation workflow → Trading environment: rolls market (evidence: `pipelines/market_sim.py`)
- Trading environment → Simulation data: gets features (evidence: `market/dynamic.py`)
- Trading environment → Rolling models: retraining models (evidence: `market/dynamic.py`)
- Rolling models → MLP residual model: trains residual model (evidence: `market/model.py`)
- Rolling models → LSTM trend model: trains trend model (evidence: `market/model.py`)
- Trading environment → State persistence: saves state (evidence: `market/dynamic.py`)
- Simulation data → Stock retrieval: retrieves prices (evidence: `market/data.py`)
