# freenowill/stock-fish architecture

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

- Interactive diagram: https://gitdiagram.com/freenowill/stock-fish
- Repository: https://github.com/freenowill/stock-fish

## Overview

StockFish is an A-share analysis and price-forecasting application. Its main workflow accepts a stock request, gathers market/news data, analyzes it, produces predictions or a multi-agent CIO decision, and can optionally run a MiroFish simulation and generate a report. The graph also includes documented batch analysis, Qlib, Feishu, and memory capabilities. Some integrations are represented at their documented subsystem path because their implementation was not sampled; dashed links mark relationships not verified in source excerpts.

Main entry points: [`analysis/agent.py`](https://github.com/freenowill/stock-fish/blob/master/analysis/agent.py) (Stock analysis), [`app.py`](https://github.com/freenowill/stock-fish/blob/master/app.py) (HTTP API), [`analysis/nodes/prediction_node.py`](https://github.com/freenowill/stock-fish/blob/master/analysis/nodes/prediction_node.py) (Prediction debate), [`market_data/a_stock_provider.py`](https://github.com/freenowill/stock-fish/blob/master/market_data/a_stock_provider.py) (Stock data provider)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Application"]
  node_app["HTTP API<br/>[app.py]"]
  node_batch["Batch analysis<br/>[batch_analyzer.py]"]
end

subgraph group_data["Market data"]
  node_provider["Stock data provider"]
  node_fetchers["Fetcher manager<br/>[base.py]"]
  node_adapter["Provider adapter"]
  node_search["News search<br/>[search_service.py]"]
  node_stockindex["Index lookup"]
  node_stockmap["Stock mapping<br/>[stock_mapping.py]"]
  node_marketlib["Fetcher implementations<br/>[akshare_fetcher.py]"]
end

subgraph group_analysis["Analysis engine"]
  node_analysisagent["Stock analysis<br/>[agent.py]"]
  node_state["Analysis state<br/>[state.py]"]
  node_scoring["Factor scoring<br/>[scoring.py]"]
  node_prediction["Prediction debate<br/>[prediction_node.py]"]
  node_employees["Analysis agents<br/>[base.py]"]
  node_cio["CIO decision<br/>[cio.py]"]
  node_report["Prediction report"]
end

subgraph group_memory["Memory"]
  node_cache[("Data cache<br/>[cache_manager.py]")]
  node_stocks[("Stock archive<br/>[stock_library.py]")]
  node_mastertrack[("Master tracking<br/>[master_track.py]")]
end

subgraph group_integrations["Integrations"]
  node_mirofish["MiroFish simulation<br/>[simulation.py]"]
  node_bridge["Simulation bridge<br/>[orchestrator.py]"]
  node_qlib["Qlib inference<br/>[infer_runner.py]"]
  node_lark["Feishu bot<br/>[lark_bot.py]"]
end

node_user(("User"))
node_externaldata{{"Market and news sources"}}
node_llm{{"LLM service"}}

node_user -->|"requests analysis"| node_app
node_app -->|"runs analysis"| node_analysisagent
node_app -->|"starts batch"| node_batch
node_analysisagent -->|"collects data"| node_provider
node_analysisagent -->|"searches news"| node_search
node_provider -->|"uses adapter"| node_adapter
node_adapter -->|"dispatches fetches"| node_fetchers
node_fetchers -->|"loads fetchers"| node_marketlib
node_provider -.->|"fetches market data"| node_externaldata
node_search -.->|"searches sources"| node_externaldata
node_analysisagent -.->|"updates state"| node_state
node_analysisagent -.->|"calculates scores"| node_scoring
node_analysisagent -->|"requests prediction"| node_prediction
node_prediction -->|"runs agents"| node_employees
node_prediction -->|"requests decision"| node_cio
node_prediction -->|"loads track context"| node_mastertrack
node_prediction -.->|"generates analysis"| node_llm
node_analysisagent -->|"caches market data"| node_cache
node_analysisagent -->|"archives snapshots"| node_stocks
node_app -->|"starts simulation"| node_bridge
node_bridge -.->|"submits simulation"| node_mirofish
node_app -->|"generates report"| node_report
node_app -.->|"starts inference"| node_qlib
node_user -->|"sends commands"| node_lark
node_lark -.->|"calls analysis API"| node_app
node_stockindex -->|"uses mappings"| node_stockmap
node_analysisagent -.->|"resolves stock names"| node_stockindex

click node_app "https://github.com/freenowill/stock-fish/blob/master/app.py"
click node_batch "https://github.com/freenowill/stock-fish/blob/master/analysis/batch_analyzer.py"
click node_provider "https://github.com/freenowill/stock-fish/blob/master/market_data/a_stock_provider.py"
click node_fetchers "https://github.com/freenowill/stock-fish/blob/master/market_data/data_fetchers/base.py"
click node_adapter "https://github.com/freenowill/stock-fish/blob/master/market_data/provider_adapter.py"
click node_search "https://github.com/freenowill/stock-fish/blob/master/market_data/search/search_service.py"
click node_stockindex "https://github.com/freenowill/stock-fish/blob/master/market_data/stock_index/stock_index_loader.py"
click node_stockmap "https://github.com/freenowill/stock-fish/blob/master/market_data/stock_index/stock_mapping.py"
click node_marketlib "https://github.com/freenowill/stock-fish/blob/master/market_data/data_fetchers/akshare_fetcher.py"
click node_analysisagent "https://github.com/freenowill/stock-fish/blob/master/analysis/agent.py"
click node_state "https://github.com/freenowill/stock-fish/blob/master/analysis/state/state.py"
click node_scoring "https://github.com/freenowill/stock-fish/blob/master/analysis/scoring.py"
click node_prediction "https://github.com/freenowill/stock-fish/blob/master/analysis/nodes/prediction_node.py"
click node_employees "https://github.com/freenowill/stock-fish/blob/master/analysis/agents/base.py"
click node_cio "https://github.com/freenowill/stock-fish/blob/master/analysis/agents/cio.py"
click node_report "https://github.com/freenowill/stock-fish/blob/master/prediction_report/report_generator.py"
click node_cache "https://github.com/freenowill/stock-fish/blob/master/memory/cache/cache_manager.py"
click node_stocks "https://github.com/freenowill/stock-fish/blob/master/memory/stocks/stock_library.py"
click node_mastertrack "https://github.com/freenowill/stock-fish/blob/master/memory/masters/master_track.py"
click node_mirofish "https://github.com/freenowill/stock-fish/blob/master/MiroFish/backend/app/api/simulation.py"
click node_bridge "https://github.com/freenowill/stock-fish/blob/master/simulation_bridge/orchestrator.py"
click node_qlib "https://github.com/freenowill/stock-fish/blob/master/qlib-zh/infer_runner.py"
click node_lark "https://github.com/freenowill/stock-fish/blob/master/integration/lark_bot.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_app,node_batch,node_user toneBlue
class node_provider,node_fetchers,node_adapter,node_search,node_stockindex,node_stockmap,node_marketlib toneAmber
class node_analysisagent,node_state,node_scoring,node_prediction,node_employees,node_cio,node_report toneMint
class node_cache,node_stocks,node_mastertrack toneRose
class node_mirofish,node_bridge,node_qlib,node_lark,node_externaldata,node_llm toneIndigo
```

## Components

### Application

- [HTTP API](https://github.com/freenowill/stock-fish/blob/master/app.py): `app.py`
- [Batch analysis](https://github.com/freenowill/stock-fish/blob/master/analysis/batch_analyzer.py): `analysis/batch_analyzer.py`

### Market data

- [Stock data provider](https://github.com/freenowill/stock-fish/blob/master/market_data/a_stock_provider.py): `market_data/a_stock_provider.py`
- [Fetcher manager](https://github.com/freenowill/stock-fish/blob/master/market_data/data_fetchers/base.py): `market_data/data_fetchers/base.py`
- [Provider adapter](https://github.com/freenowill/stock-fish/blob/master/market_data/provider_adapter.py): `market_data/provider_adapter.py`
- [News search](https://github.com/freenowill/stock-fish/blob/master/market_data/search/search_service.py): `market_data/search/search_service.py`
- [Index lookup](https://github.com/freenowill/stock-fish/blob/master/market_data/stock_index/stock_index_loader.py): `market_data/stock_index/stock_index_loader.py`
- [Stock mapping](https://github.com/freenowill/stock-fish/blob/master/market_data/stock_index/stock_mapping.py): `market_data/stock_index/stock_mapping.py`
- [Fetcher implementations](https://github.com/freenowill/stock-fish/blob/master/market_data/data_fetchers/akshare_fetcher.py): `market_data/data_fetchers/akshare_fetcher.py`

### Analysis engine

- [Stock analysis](https://github.com/freenowill/stock-fish/blob/master/analysis/agent.py): `analysis/agent.py`
- [Analysis state](https://github.com/freenowill/stock-fish/blob/master/analysis/state/state.py): `analysis/state/state.py`
- [Factor scoring](https://github.com/freenowill/stock-fish/blob/master/analysis/scoring.py): `analysis/scoring.py`
- [Prediction debate](https://github.com/freenowill/stock-fish/blob/master/analysis/nodes/prediction_node.py): `analysis/nodes/prediction_node.py`
- [Analysis agents](https://github.com/freenowill/stock-fish/blob/master/analysis/agents/base.py): `analysis/agents/base.py`
- [CIO decision](https://github.com/freenowill/stock-fish/blob/master/analysis/agents/cio.py): `analysis/agents/cio.py`
- [Prediction report](https://github.com/freenowill/stock-fish/blob/master/prediction_report/report_generator.py): `prediction_report/report_generator.py`

### Memory

- [Data cache](https://github.com/freenowill/stock-fish/blob/master/memory/cache/cache_manager.py): `memory/cache/cache_manager.py`
- [Stock archive](https://github.com/freenowill/stock-fish/blob/master/memory/stocks/stock_library.py): `memory/stocks/stock_library.py`
- [Master tracking](https://github.com/freenowill/stock-fish/blob/master/memory/masters/master_track.py): `memory/masters/master_track.py`

### Integrations

- [MiroFish simulation](https://github.com/freenowill/stock-fish/blob/master/MiroFish/backend/app/api/simulation.py): `MiroFish/backend/app/api/simulation.py`
- [Simulation bridge](https://github.com/freenowill/stock-fish/blob/master/simulation_bridge/orchestrator.py): `simulation_bridge/orchestrator.py`
- [Qlib inference](https://github.com/freenowill/stock-fish/blob/master/qlib-zh/infer_runner.py): `qlib-zh/infer_runner.py`
- [Feishu bot](https://github.com/freenowill/stock-fish/blob/master/integration/lark_bot.py): `integration/lark_bot.py`

### Other components

- **User**
- **Market and news sources**
- **LLM service**

## Connections

- User → HTTP API: requests analysis
- HTTP API → Stock analysis: runs analysis (evidence: `app.py`)
- HTTP API → Batch analysis: starts batch (evidence: `app.py`)
- Stock analysis → Stock data provider: collects data (evidence: `analysis/agent.py`)
- Stock analysis → News search: searches news (evidence: `analysis/agent.py`)
- Stock data provider → Provider adapter: uses adapter (evidence: `market_data/a_stock_provider.py`)
- Provider adapter → Fetcher manager: dispatches fetches (evidence: `market_data/provider_adapter.py`)
- Fetcher manager → Fetcher implementations: loads fetchers (evidence: `market_data/data_fetchers/base.py`)
- Stock data provider → Market and news sources: fetches market data
- News search → Market and news sources: searches sources
- Stock analysis → Analysis state: updates state (evidence: `analysis/agent.py`)
- Stock analysis → Factor scoring: calculates scores (evidence: `analysis/agent.py`)
- Stock analysis → Prediction debate: requests prediction (evidence: `analysis/agent.py`)
- Prediction debate → Analysis agents: runs agents (evidence: `analysis/nodes/prediction_node.py`)
- Prediction debate → CIO decision: requests decision (evidence: `analysis/nodes/prediction_node.py`)
- Prediction debate → Master tracking: loads track context (evidence: `analysis/nodes/prediction_node.py`)
- Prediction debate → LLM service: generates analysis
- Stock analysis → Data cache: caches market data (evidence: `analysis/agent.py`)
- Stock analysis → Stock archive: archives snapshots (evidence: `analysis/agent.py`)
- HTTP API → Simulation bridge: starts simulation (evidence: `app.py`)
- Simulation bridge → MiroFish simulation: submits simulation
- HTTP API → Prediction report: generates report (evidence: `app.py`)
- HTTP API → Qlib inference: starts inference
- User → Feishu bot: sends commands
- Feishu bot → HTTP API: calls analysis API (evidence: `app.py`)
- Index lookup → Stock mapping: uses mappings (evidence: `market_data/stock_index/stock_index_loader.py`)
- Stock analysis → Index lookup: resolves stock names (evidence: `analysis/agent.py`)
