# shubhv123/silver_ml_model architecture

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

- Interactive diagram: https://gitdiagram.com/shubhv123/silver_ml_model
- Repository: https://github.com/shubhv123/silver_ml_model

## Overview

This repository is a silver-price prediction system. Its documented main workflow collects market and macro data, builds features, trains forecasting models, evaluates them through backtests, and presents results in a live dashboard. Separate capabilities cover news sentiment, Bayesian inference, risk management, and Qlib-based backtesting. The README establishes the main workflow and feature set; most of these subsystem implementations were not sampled, so finer runtime connections are not asserted.

Main entry points: [`src/backtest/full_model_comparison.py`](https://github.com/shubhv123/silver_ml_model/blob/main/src/backtest/full_model_comparison.py) (Model comparison), [`src/models/train_xgboost.py`](https://github.com/shubhv123/silver_ml_model/blob/main/src/models/train_xgboost.py) (Tree models), [`src/dashboard/live_dashboard.py`](https://github.com/shubhv123/silver_ml_model/blob/main/src/dashboard/live_dashboard.py) (Live dashboard), [`src/nlp/news_collector.py`](https://github.com/shubhv123/silver_ml_model/blob/main/src/nlp/news_collector.py) (News collection)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Data collection"]
  node_data_pipeline["Data pipeline"]
  node_price_data["Price collection"]
  node_macro_data["Macro collection"]
  node_cot_data["COT collection"]
  node_etf_data["ETF collection"]
  node_news_collection["News collection<br/>[news_collector.py]"]
end

subgraph group_features["Feature engineering"]
  node_sentiment["News sentiment"]
  node_finbert["FinBERT sentiment"]
  node_feature_build["Feature building<br/>[build_features.py]"]
  node_sentiment_features["Sentiment features"]
end

subgraph group_models["Prediction models"]
  node_tree_models["Tree models<br/>[train_xgboost.py]"]
  node_ensemble["Ensemble explainability<br/>[ensemble_shap.py]"]
  node_deep_models["Deep learning"]
  node_bayesian["Bayesian regression"]
end

subgraph group_evaluation["Evaluation and analysis"]
  node_comparison["Model comparison"]
  node_performance["Performance dashboard"]
  node_walk_forward["Walk-forward backtest"]
  node_sentiment_analysis["Sentiment-price analysis"]
  node_qlib["Qlib backtest"]
end

subgraph group_product["Risk and presentation"]
  node_risk["Position sizing<br/>[position_sizing.py]"]
  node_dashboard["Live dashboard<br/>[live_dashboard.py]"]
end

node_operator(("Operator"))
node_market_sources(("Market sources"))
node_fred(("FRED"))
node_newsapi(("NewsAPI"))

node_operator -->|"runs collection"| node_data_pipeline
node_market_sources -.->|"provides prices"| node_price_data
node_market_sources -.->|"provides ETF data"| node_etf_data
node_fred -->|"provides indicators"| node_macro_data
node_newsapi -.->|"provides news"| node_news_collection
node_operator -->|"runs engineering"| node_feature_build
node_operator -->|"trains models"| node_tree_models
node_operator -->|"runs backtest"| node_comparison
node_operator -->|"launches app"| node_dashboard
node_news_collection -.->|"analyzes news"| node_sentiment
node_sentiment -.->|"creates features"| node_sentiment_features
node_finbert -.->|"creates features"| node_sentiment_features
node_feature_build -.->|"supplies features"| node_tree_models
node_tree_models -.->|"compared in"| node_comparison
node_ensemble -.->|"compared in"| node_comparison
node_deep_models -.->|"compared in"| node_comparison
node_bayesian -.->|"shown in"| node_dashboard
node_risk -.->|"supports trading"| node_dashboard
node_comparison -->|"reports metrics"| node_performance
node_operator -.->|"runs evaluation"| node_walk_forward
node_operator -.->|"runs analysis"| node_sentiment_analysis
node_operator -.->|"runs backtest"| node_qlib

click node_data_pipeline "https://github.com/shubhv123/silver_ml_model/blob/main/src/data/run_data_pipeline.py"
click node_price_data "https://github.com/shubhv123/silver_ml_model/blob/main/src/data/collect_price_data.py"
click node_macro_data "https://github.com/shubhv123/silver_ml_model/blob/main/src/data/collect_macro_data.py"
click node_cot_data "https://github.com/shubhv123/silver_ml_model/blob/main/src/data/collect_cot_data.py"
click node_etf_data "https://github.com/shubhv123/silver_ml_model/blob/main/src/data/collect_etf_data.py"
click node_news_collection "https://github.com/shubhv123/silver_ml_model/blob/main/src/nlp/news_collector.py"
click node_sentiment "https://github.com/shubhv123/silver_ml_model/blob/main/src/nlp/sentiment_analysis.py"
click node_finbert "https://github.com/shubhv123/silver_ml_model/blob/main/src/nlp/finbert_sentiment.py"
click node_feature_build "https://github.com/shubhv123/silver_ml_model/blob/main/src/features/build_features.py"
click node_sentiment_features "https://github.com/shubhv123/silver_ml_model/blob/main/src/features/sentiment_features.py"
click node_tree_models "https://github.com/shubhv123/silver_ml_model/blob/main/src/models/train_xgboost.py"
click node_ensemble "https://github.com/shubhv123/silver_ml_model/blob/main/src/models/ensemble_shap.py"
click node_deep_models "https://github.com/shubhv123/silver_ml_model/blob/main/src/models/deep_learning/lstm_with_attention.py"
click node_bayesian "https://github.com/shubhv123/silver_ml_model/blob/main/src/bayesian/bayesian_regression.py"
click node_risk "https://github.com/shubhv123/silver_ml_model/blob/main/src/risk/position_sizing.py"
click node_dashboard "https://github.com/shubhv123/silver_ml_model/blob/main/src/dashboard/live_dashboard.py"
click node_comparison "https://github.com/shubhv123/silver_ml_model/blob/main/src/backtest/full_model_comparison.py"
click node_performance "https://github.com/shubhv123/silver_ml_model/blob/main/src/backtest/performance_dashboard.py"
click node_walk_forward "https://github.com/shubhv123/silver_ml_model/blob/main/src/backtest/walk_forward_backtest.py"
click node_sentiment_analysis "https://github.com/shubhv123/silver_ml_model/blob/main/src/analysis/sentiment_price_correlation.py"
click node_qlib "https://github.com/shubhv123/silver_ml_model/blob/main/src/qlib_integration/run_combined_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_data_pipeline,node_price_data,node_macro_data,node_cot_data,node_etf_data,node_news_collection toneBlue
class node_sentiment,node_finbert,node_feature_build,node_sentiment_features toneAmber
class node_tree_models,node_ensemble,node_deep_models,node_bayesian,node_newsapi toneMint
class node_comparison,node_performance,node_walk_forward,node_sentiment_analysis,node_qlib toneRose
class node_risk,node_dashboard,node_operator,node_market_sources,node_fred toneIndigo
```

## Components

### Data collection

- [Data pipeline](https://github.com/shubhv123/silver_ml_model/blob/main/src/data/run_data_pipeline.py): `src/data/run_data_pipeline.py`
- [Price collection](https://github.com/shubhv123/silver_ml_model/blob/main/src/data/collect_price_data.py): `src/data/collect_price_data.py`
- [Macro collection](https://github.com/shubhv123/silver_ml_model/blob/main/src/data/collect_macro_data.py): `src/data/collect_macro_data.py`
- [COT collection](https://github.com/shubhv123/silver_ml_model/blob/main/src/data/collect_cot_data.py): `src/data/collect_cot_data.py`
- [ETF collection](https://github.com/shubhv123/silver_ml_model/blob/main/src/data/collect_etf_data.py): `src/data/collect_etf_data.py`
- [News collection](https://github.com/shubhv123/silver_ml_model/blob/main/src/nlp/news_collector.py): `src/nlp/news_collector.py`

### Feature engineering

- [News sentiment](https://github.com/shubhv123/silver_ml_model/blob/main/src/nlp/sentiment_analysis.py): `src/nlp/sentiment_analysis.py`
- [FinBERT sentiment](https://github.com/shubhv123/silver_ml_model/blob/main/src/nlp/finbert_sentiment.py): `src/nlp/finbert_sentiment.py`
- [Feature building](https://github.com/shubhv123/silver_ml_model/blob/main/src/features/build_features.py): `src/features/build_features.py`
- [Sentiment features](https://github.com/shubhv123/silver_ml_model/blob/main/src/features/sentiment_features.py): `src/features/sentiment_features.py`

### Prediction models

- [Tree models](https://github.com/shubhv123/silver_ml_model/blob/main/src/models/train_xgboost.py): `src/models/train_xgboost.py`
- [Ensemble explainability](https://github.com/shubhv123/silver_ml_model/blob/main/src/models/ensemble_shap.py): `src/models/ensemble_shap.py`
- [Deep learning](https://github.com/shubhv123/silver_ml_model/blob/main/src/models/deep_learning/lstm_with_attention.py): `src/models/deep_learning/lstm_with_attention.py`
- [Bayesian regression](https://github.com/shubhv123/silver_ml_model/blob/main/src/bayesian/bayesian_regression.py): `src/bayesian/bayesian_regression.py`

### Evaluation and analysis

- [Model comparison](https://github.com/shubhv123/silver_ml_model/blob/main/src/backtest/full_model_comparison.py): `src/backtest/full_model_comparison.py`
- [Performance dashboard](https://github.com/shubhv123/silver_ml_model/blob/main/src/backtest/performance_dashboard.py): `src/backtest/performance_dashboard.py`
- [Walk-forward backtest](https://github.com/shubhv123/silver_ml_model/blob/main/src/backtest/walk_forward_backtest.py): `src/backtest/walk_forward_backtest.py`
- [Sentiment-price analysis](https://github.com/shubhv123/silver_ml_model/blob/main/src/analysis/sentiment_price_correlation.py): `src/analysis/sentiment_price_correlation.py`
- [Qlib backtest](https://github.com/shubhv123/silver_ml_model/blob/main/src/qlib_integration/run_combined_backtest.py): `src/qlib_integration/run_combined_backtest.py`

### Risk and presentation

- [Position sizing](https://github.com/shubhv123/silver_ml_model/blob/main/src/risk/position_sizing.py): `src/risk/position_sizing.py`
- [Live dashboard](https://github.com/shubhv123/silver_ml_model/blob/main/src/dashboard/live_dashboard.py): `src/dashboard/live_dashboard.py`

### Other components

- **Operator**
- **Market sources**
- **FRED**
- **NewsAPI**

## Connections

- Operator → Data pipeline: runs collection
- Market sources → Price collection: provides prices
- Market sources → ETF collection: provides ETF data
- FRED → Macro collection: provides indicators
- NewsAPI → News collection: provides news
- Operator → Feature building: runs engineering
- Operator → Tree models: trains models
- Operator → Model comparison: runs backtest
- Operator → Live dashboard: launches app
- News collection → News sentiment: analyzes news
- News sentiment → Sentiment features: creates features
- FinBERT sentiment → Sentiment features: creates features
- Feature building → Tree models: supplies features
- Tree models → Model comparison: compared in
- Ensemble explainability → Model comparison: compared in
- Deep learning → Model comparison: compared in
- Bayesian regression → Live dashboard: shown in
- Position sizing → Live dashboard: supports trading
- Model comparison → Performance dashboard: reports metrics (evidence: `src/backtest/performance_dashboard.py`)
- Operator → Walk-forward backtest: runs evaluation
- Operator → Sentiment-price analysis: runs analysis
- Operator → Qlib backtest: runs backtest
