# 1nchaos/adata architecture

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

- Interactive diagram: https://gitdiagram.com/1nchaos/adata
- Repository: https://github.com/1nchaos/adata

## Overview

AData is a Python SDK for retrieving A-share quant data, with additional fund, bond, and market-sentiment data. Its main workflow is that a Python caller invokes a domain API, such as stock-code lookup followed by stock-market history; the SDK fetches and normalizes public-source data into DataFrames. The graph preserves documented stock reference, market, and related data capabilities. Several modules are represented at their exact tree paths, but their internal calls were not sampled; edges are limited to README statements or visible source references and calls.

Main entry points: [`adata/common/base/base_ths.py`](https://github.com/1nchaos/adata/blob/main/adata/common/base/base_ths.py) (THS request base), [`adata/stock/info/stock_code.py`](https://github.com/1nchaos/adata/blob/main/adata/stock/info/stock_code.py) (Stock codes), [`adata/stock/market/stock_market/stock_market_template.py`](https://github.com/1nchaos/adata/blob/main/adata/stock/market/stock_market/stock_market_template.py) (Stock K-lines), [`adata/stock/market/concepth_market/concept_market_template.py`](https://github.com/1nchaos/adata/blob/main/adata/stock/market/concepth_market/concept_market_template.py) (Concept markets)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_stock_reference["Stock Reference"]
  node_stock_codes["Stock codes<br/>[stock_code.py]"]
  node_stock_info["Stock information<br/>[stock_info.py]"]
  node_stock_concepts["Stock concepts"]
  node_stock_index_info["Index information<br/>[stock_index.py]"]
  node_trade_calendar["Trade calendar<br/>[trade_calendar.py]"]
end

subgraph group_stock_markets["Stock Markets"]
  node_stock_history["Stock K-lines"]
  node_index_markets["Index markets"]
  node_concept_markets["Concept markets"]
  node_capital_flows["Stock capital flows"]
  node_concept_flows["Concept capital flows<br/>[concept_flow.py]"]
  node_dividends["Stock dividends<br/>[stock_dividend.py]"]
  node_finance_statements["Financial statements<br/>[core.py]"]
end

subgraph group_market_research["Market Research"]
  node_sentiment["Market sentiment<br/>[alist.py]"]
  node_north_flow["Northbound flows<br/>[north_flow.py]"]
  node_sentiment_topics["Sentiment topics<br/>[hot.py]"]
end

subgraph group_other_assets["Other Assets"]
  node_etf_markets["ETF markets<br/>[etf_market_ths.py]"]
  node_fund_info["Fund information<br/>[fund_info.py]"]
  node_bond_markets["Bond markets"]
  node_bond_codes["Bond codes<br/>[bond_code.py]"]
end

subgraph group_runtime["Shared Runtime"]
  node_request_client["HTTP request client<br/>[sunrequests.py]"]
  node_ths_base["THS request base<br/>[base_ths.py]"]
  node_null_handler["Null-result handler<br/>[handler.py]"]
end

node_python_caller(("Python caller"))
node_eastmoney(("Eastmoney"))
node_baidu(("Baidu Finance"))
node_sina(("Sina Finance"))
node_tencent(("Tencent Finance"))
node_ths(("Tonghuashun"))

node_python_caller -->|"requests codes"| node_stock_codes
node_python_caller -->|"requests K-lines"| node_stock_history
node_stock_codes -->|"fetches rankings"| node_baidu
node_stock_codes -->|"fetches listings"| node_eastmoney
node_stock_history -.->|"market source"| node_sina
node_stock_history -.->|"market source"| node_tencent
node_stock_history -.->|"market source"| node_baidu
node_stock_concepts -->|"fetches concepts"| node_ths
node_index_markets -->|"source adapter"| node_eastmoney
node_concept_markets -.->|"source adapter"| node_ths
node_north_flow -->|"fetches history"| node_eastmoney
node_north_flow -->|"fallback source"| node_ths
node_etf_markets -->|"fetches ETF data"| node_ths
node_bond_markets -->|"fetches quotes"| node_sina
node_bond_markets -->|"uses client"| node_request_client
node_ths_base -->|"sends requests"| node_request_client
node_ths_base -->|"retrieves THS data"| node_ths
node_fund_info -->|"uses base"| node_ths_base
node_etf_markets -->|"uses base"| node_ths_base
node_concept_markets -->|"uses base"| node_ths_base
node_stock_codes -->|"wraps fetch"| node_null_handler

click node_stock_codes "https://github.com/1nchaos/adata/blob/main/adata/stock/info/stock_code.py"
click node_stock_info "https://github.com/1nchaos/adata/blob/main/adata/stock/info/stock_info.py"
click node_stock_concepts "https://github.com/1nchaos/adata/blob/main/adata/stock/info/concept/stock_concept_ths.py"
click node_stock_index_info "https://github.com/1nchaos/adata/blob/main/adata/stock/info/stock_index.py"
click node_trade_calendar "https://github.com/1nchaos/adata/blob/main/adata/stock/info/trade_calendar.py"
click node_stock_history "https://github.com/1nchaos/adata/blob/main/adata/stock/market/stock_market/stock_market_template.py"
click node_index_markets "https://github.com/1nchaos/adata/blob/main/adata/stock/market/index_market/market_index_template.py"
click node_concept_markets "https://github.com/1nchaos/adata/blob/main/adata/stock/market/concepth_market/concept_market_template.py"
click node_capital_flows "https://github.com/1nchaos/adata/blob/main/adata/stock/market/capital_flow/stock_capital_flow.py"
click node_concept_flows "https://github.com/1nchaos/adata/blob/main/adata/stock/market/concept_capital_flow/concept_flow.py"
click node_dividends "https://github.com/1nchaos/adata/blob/main/adata/stock/market/stock_dividend.py"
click node_finance_statements "https://github.com/1nchaos/adata/blob/main/adata/stock/finance/core.py"
click node_sentiment "https://github.com/1nchaos/adata/blob/main/adata/sentiment/alist.py"
click node_north_flow "https://github.com/1nchaos/adata/blob/main/adata/sentiment/north_flow.py"
click node_sentiment_topics "https://github.com/1nchaos/adata/blob/main/adata/sentiment/hot.py"
click node_etf_markets "https://github.com/1nchaos/adata/blob/main/adata/fund/market/etf_market_ths.py"
click node_fund_info "https://github.com/1nchaos/adata/blob/main/adata/fund/info/fund_info.py"
click node_bond_markets "https://github.com/1nchaos/adata/blob/main/adata/bond/market/bond_market_sina.py"
click node_bond_codes "https://github.com/1nchaos/adata/blob/main/adata/bond/info/bond_code.py"
click node_request_client "https://github.com/1nchaos/adata/blob/main/adata/common/utils/sunrequests.py"
click node_ths_base "https://github.com/1nchaos/adata/blob/main/adata/common/base/base_ths.py"
click node_null_handler "https://github.com/1nchaos/adata/blob/main/adata/common/exception/handler.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_codes,node_stock_info,node_stock_concepts,node_stock_index_info,node_trade_calendar toneBlue
class node_stock_history,node_index_markets,node_concept_markets,node_capital_flows,node_concept_flows,node_dividends,node_finance_statements toneAmber
class node_sentiment,node_north_flow,node_sentiment_topics toneMint
class node_etf_markets,node_fund_info,node_bond_markets,node_bond_codes toneRose
class node_request_client,node_ths_base,node_null_handler,node_python_caller,node_eastmoney,node_baidu,node_sina,node_tencent,node_ths toneIndigo
```

## Components

### Stock Reference

- [Stock codes](https://github.com/1nchaos/adata/blob/main/adata/stock/info/stock_code.py): `adata/stock/info/stock_code.py`
- [Stock information](https://github.com/1nchaos/adata/blob/main/adata/stock/info/stock_info.py): `adata/stock/info/stock_info.py`
- [Stock concepts](https://github.com/1nchaos/adata/blob/main/adata/stock/info/concept/stock_concept_ths.py): `adata/stock/info/concept/stock_concept_ths.py`
- [Index information](https://github.com/1nchaos/adata/blob/main/adata/stock/info/stock_index.py): `adata/stock/info/stock_index.py`
- [Trade calendar](https://github.com/1nchaos/adata/blob/main/adata/stock/info/trade_calendar.py): `adata/stock/info/trade_calendar.py`

### Stock Markets

- [Stock K-lines](https://github.com/1nchaos/adata/blob/main/adata/stock/market/stock_market/stock_market_template.py): `adata/stock/market/stock_market/stock_market_template.py`
- [Index markets](https://github.com/1nchaos/adata/blob/main/adata/stock/market/index_market/market_index_template.py): `adata/stock/market/index_market/market_index_template.py`
- [Concept markets](https://github.com/1nchaos/adata/blob/main/adata/stock/market/concepth_market/concept_market_template.py): `adata/stock/market/concepth_market/concept_market_template.py`
- [Stock capital flows](https://github.com/1nchaos/adata/blob/main/adata/stock/market/capital_flow/stock_capital_flow.py): `adata/stock/market/capital_flow/stock_capital_flow.py`
- [Concept capital flows](https://github.com/1nchaos/adata/blob/main/adata/stock/market/concept_capital_flow/concept_flow.py): `adata/stock/market/concept_capital_flow/concept_flow.py`
- [Stock dividends](https://github.com/1nchaos/adata/blob/main/adata/stock/market/stock_dividend.py): `adata/stock/market/stock_dividend.py`
- [Financial statements](https://github.com/1nchaos/adata/blob/main/adata/stock/finance/core.py): `adata/stock/finance/core.py`

### Market Research

- [Market sentiment](https://github.com/1nchaos/adata/blob/main/adata/sentiment/alist.py): `adata/sentiment/alist.py`
- [Northbound flows](https://github.com/1nchaos/adata/blob/main/adata/sentiment/north_flow.py): `adata/sentiment/north_flow.py`
- [Sentiment topics](https://github.com/1nchaos/adata/blob/main/adata/sentiment/hot.py): `adata/sentiment/hot.py`

### Other Assets

- [ETF markets](https://github.com/1nchaos/adata/blob/main/adata/fund/market/etf_market_ths.py): `adata/fund/market/etf_market_ths.py`
- [Fund information](https://github.com/1nchaos/adata/blob/main/adata/fund/info/fund_info.py): `adata/fund/info/fund_info.py`
- [Bond markets](https://github.com/1nchaos/adata/blob/main/adata/bond/market/bond_market_sina.py): `adata/bond/market/bond_market_sina.py`
- [Bond codes](https://github.com/1nchaos/adata/blob/main/adata/bond/info/bond_code.py): `adata/bond/info/bond_code.py`

### Shared Runtime

- [HTTP request client](https://github.com/1nchaos/adata/blob/main/adata/common/utils/sunrequests.py): `adata/common/utils/sunrequests.py`
- [THS request base](https://github.com/1nchaos/adata/blob/main/adata/common/base/base_ths.py): `adata/common/base/base_ths.py`
- [Null-result handler](https://github.com/1nchaos/adata/blob/main/adata/common/exception/handler.py): `adata/common/exception/handler.py`

### Other components

- **Python caller**
- **Eastmoney**
- **Baidu Finance**
- **Sina Finance**
- **Tencent Finance**
- **Tonghuashun**

## Connections

- Python caller → Stock codes: requests codes (evidence: `README.md`)
- Python caller → Stock K-lines: requests K-lines (evidence: `README.md`)
- Stock codes → Baidu Finance: fetches rankings (evidence: `adata/stock/info/stock_code.py`)
- Stock codes → Eastmoney: fetches listings (evidence: `adata/stock/info/stock_code.py`)
- Stock K-lines → Sina Finance: market source (evidence: `README.md`)
- Stock K-lines → Tencent Finance: market source (evidence: `README.md`)
- Stock K-lines → Baidu Finance: market source (evidence: `README.md`)
- Stock concepts → Tonghuashun: fetches concepts (evidence: `adata/stock/info/concept/stock_concept_ths.py`)
- Index markets → Eastmoney: source adapter
- Concept markets → Tonghuashun: source adapter
- Northbound flows → Eastmoney: fetches history (evidence: `adata/sentiment/north_flow.py`)
- Northbound flows → Tonghuashun: fallback source (evidence: `adata/sentiment/north_flow.py`)
- ETF markets → Tonghuashun: fetches ETF data (evidence: `adata/fund/market/etf_market_ths.py`)
- Bond markets → Sina Finance: fetches quotes (evidence: `adata/bond/market/bond_market_sina.py`)
- Bond markets → HTTP request client: uses client (evidence: `adata/bond/market/bond_market_sina.py`)
- THS request base → HTTP request client: sends requests (evidence: `adata/common/base/base_ths.py`)
- THS request base → Tonghuashun: retrieves THS data (evidence: `adata/common/base/base_ths.py`)
- Fund information → THS request base: uses base (evidence: `adata/fund/info/fund_info.py`)
- ETF markets → THS request base: uses base (evidence: `adata/fund/market/etf_market_ths.py`)
- Concept markets → THS request base: uses base (evidence: `adata/stock/market/concepth_market/concept_market_ths.py`)
- Stock codes → Null-result handler: wraps fetch (evidence: `adata/stock/info/stock_code.py`)
