# touhoufan2024/qlibassistant architecture

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

- Interactive diagram: https://gitdiagram.com/touhoufan2024/qlibassistant
- Repository: https://github.com/touhoufan2024/qlibassistant

## Overview

QlibAssistant automates CSI 300 market-data updates, rolling model training, ensemble prediction, and historical backtesting, then publishes prediction and review pages. The main user entry point is the `roll` CLI: it loads configuration and dispatches data, training, or model commands. Separate branches cover model archives, optional DoltHub CSV synchronization, and static-page generation. Edges are limited to relationships shown in excerpts or stated in the README; unsampled implementation details are not inferred.

Main entry points: [`roll/modelcli.py`](https://github.com/touhoufan2024/qlibassistant/blob/main/roll/modelcli.py) (Model selection and inference), [`roll/roll.py`](https://github.com/touhoufan2024/qlibassistant/blob/main/roll/roll.py) (Command dispatcher), [`roll/model_review.py`](https://github.com/touhoufan2024/qlibassistant/blob/main/roll/model_review.py) (Backtest review), [`roll/traincli.py`](https://github.com/touhoufan2024/qlibassistant/blob/main/roll/traincli.py) (Rolling training)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI and configuration"]
  node_entry["Command dispatcher<br/>[roll.py]"]
  node_config["Model configuration<br/>[myconfig.py]"]
end

subgraph group_models["Data and modeling"]
  node_data["Market data updates<br/>[datacli.py]"]
  node_market_store[("Local Qlib data")]
  node_trainer["Rolling training<br/>[traincli.py]"]
  node_experiments[("Model experiments")]
  node_selection["Model selection and inference<br/>[modelcli.py]"]
  node_model_archive["Model archive management<br/>[model_backup.py]"]
end

subgraph group_review["Review and results"]
  node_review["Backtest review<br/>[model_review.py]"]
  node_score_csv["Prediction CSVs"]
  node_review_csv["Review statistics"]
  node_backtest_csv["Backtest results"]
end

subgraph group_publishing["Publishing and sync"]
  node_page_generator["Static page generation<br/>[gen_page.py]"]
  node_site["Results website"]
  node_dolt_sync["CSV synchronization<br/>[sync_dolt.py]"]
end

node_user(("CLI user"))
node_market_source["Investment data releases"]
node_dolt["DoltHub SQL API"]

node_user -->|"runs commands"| node_entry
node_entry -->|"dispatches data"| node_data
node_entry -->|"dispatches training"| node_trainer
node_entry -->|"dispatches model"| node_selection
node_data -->|"downloads data"| node_market_source
node_data -->|"updates data"| node_market_store
node_trainer -->|"builds tasks"| node_config
node_trainer -->|"trains on data"| node_market_store
node_trainer -->|"records runs"| node_experiments
node_selection -->|"filters models"| node_experiments
node_selection -->|"predicts from data"| node_market_store
node_selection -->|"writes scores"| node_score_csv
node_entry -->|"dispatches archive"| node_model_archive
node_selection -->|"delegates archive"| node_model_archive
node_entry -->|"dispatches review"| node_review
node_selection -->|"delegates review"| node_review
node_review -->|"requests labels"| node_selection
node_review -->|"reads predictions"| node_score_csv
node_review -->|"saves statistics"| node_review_csv
node_review -->|"saves backtests"| node_backtest_csv
node_page_generator -->|"copies results"| node_backtest_csv
node_page_generator -->|"generates pages"| node_site
node_dolt_sync -->|"syncs tables"| node_dolt

click node_entry "https://github.com/touhoufan2024/qlibassistant/blob/main/roll/roll.py"
click node_config "https://github.com/touhoufan2024/qlibassistant/blob/main/roll/myconfig.py"
click node_data "https://github.com/touhoufan2024/qlibassistant/blob/main/roll/datacli.py"
click node_trainer "https://github.com/touhoufan2024/qlibassistant/blob/main/roll/traincli.py"
click node_selection "https://github.com/touhoufan2024/qlibassistant/blob/main/roll/modelcli.py"
click node_model_archive "https://github.com/touhoufan2024/qlibassistant/blob/main/roll/model_backup.py"
click node_review "https://github.com/touhoufan2024/qlibassistant/blob/main/roll/model_review.py"
click node_score_csv "https://github.com/touhoufan2024/qlibassistant/tree/main/qlib_score_csv"
click node_review_csv "https://github.com/touhoufan2024/qlibassistant/tree/main/review_csv"
click node_backtest_csv "https://github.com/touhoufan2024/qlibassistant/tree/main/backtest_csv"
click node_page_generator "https://github.com/touhoufan2024/qlibassistant/blob/main/page/script/gen_page.py"
click node_site "https://github.com/touhoufan2024/qlibassistant/tree/main/page/docs"
click node_dolt_sync "https://github.com/touhoufan2024/qlibassistant/blob/main/script/sync_dolt.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_entry,node_config,node_user toneBlue
class node_data,node_market_store,node_trainer,node_experiments,node_selection,node_model_archive toneAmber
class node_review,node_score_csv,node_review_csv,node_backtest_csv,node_dolt toneMint
class node_page_generator,node_site,node_dolt_sync toneRose
class node_market_source toneIndigo
```

## Components

### CLI and configuration

- [Command dispatcher](https://github.com/touhoufan2024/qlibassistant/blob/main/roll/roll.py): `roll/roll.py`
- [Model configuration](https://github.com/touhoufan2024/qlibassistant/blob/main/roll/myconfig.py): `roll/myconfig.py`

### Data and modeling

- [Market data updates](https://github.com/touhoufan2024/qlibassistant/blob/main/roll/datacli.py): `roll/datacli.py`
- **Local Qlib data**
- [Rolling training](https://github.com/touhoufan2024/qlibassistant/blob/main/roll/traincli.py): `roll/traincli.py`
- **Model experiments**
- [Model selection and inference](https://github.com/touhoufan2024/qlibassistant/blob/main/roll/modelcli.py): `roll/modelcli.py`
- [Model archive management](https://github.com/touhoufan2024/qlibassistant/blob/main/roll/model_backup.py): `roll/model_backup.py`

### Review and results

- [Backtest review](https://github.com/touhoufan2024/qlibassistant/blob/main/roll/model_review.py): `roll/model_review.py`
- [Prediction CSVs](https://github.com/touhoufan2024/qlibassistant/tree/main/qlib_score_csv): `qlib_score_csv`
- [Review statistics](https://github.com/touhoufan2024/qlibassistant/tree/main/review_csv): `review_csv`
- [Backtest results](https://github.com/touhoufan2024/qlibassistant/tree/main/backtest_csv): `backtest_csv`

### Publishing and sync

- [Static page generation](https://github.com/touhoufan2024/qlibassistant/blob/main/page/script/gen_page.py): `page/script/gen_page.py`
- [Results website](https://github.com/touhoufan2024/qlibassistant/tree/main/page/docs): `page/docs`
- [CSV synchronization](https://github.com/touhoufan2024/qlibassistant/blob/main/script/sync_dolt.py): `script/sync_dolt.py`

### Other components

- **CLI user**
- **Investment data releases**
- **DoltHub SQL API**

## Connections

- CLI user → Command dispatcher: runs commands (evidence: `README.md`)
- Command dispatcher → Market data updates: dispatches data (evidence: `roll/roll.py`)
- Command dispatcher → Rolling training: dispatches training (evidence: `roll/roll.py`)
- Command dispatcher → Model selection and inference: dispatches model (evidence: `roll/roll.py`)
- Market data updates → Investment data releases: downloads data (evidence: `roll/datacli.py`)
- Market data updates → Local Qlib data: updates data (evidence: `README.md`)
- Rolling training → Model configuration: builds tasks (evidence: `roll/traincli.py`)
- Rolling training → Local Qlib data: trains on data (evidence: `README.md`)
- Rolling training → Model experiments: records runs (evidence: `roll/traincli.py`)
- Model selection and inference → Model experiments: filters models (evidence: `README.md`)
- Model selection and inference → Local Qlib data: predicts from data (evidence: `README.md`)
- Model selection and inference → Prediction CSVs: writes scores (evidence: `README.md`)
- Command dispatcher → Model archive management: dispatches archive
- Model selection and inference → Model archive management: delegates archive (evidence: `roll/modelcli.py`)
- Command dispatcher → Backtest review: dispatches review
- Model selection and inference → Backtest review: delegates review (evidence: `roll/modelcli.py`)
- Backtest review → Model selection and inference: requests labels (evidence: `roll/model_review.py`)
- Backtest review → Prediction CSVs: reads predictions (evidence: `roll/model_review.py`)
- Backtest review → Review statistics: saves statistics (evidence: `roll/model_review.py`)
- Backtest review → Backtest results: saves backtests (evidence: `roll/model_review.py`)
- Static page generation → Backtest results: copies results (evidence: `page/script/gen_page.py`)
- Static page generation → Results website: generates pages (evidence: `page/script/gen_page.py`)
- CSV synchronization → DoltHub SQL API: syncs tables (evidence: `script/sync_dolt.py`)
