A股历史与实时行情数据统一接入、清洗与存储
Project description
hqdata - A股历史与实时行情数据统一接入、清洗与存储
定位
hqdata 是 HonestQuant 量化系统的数据基础层,职责边界清晰:
- 对下:封装各数据源 SDK,屏蔽接口差异
- 对上:提供统一的查询接口
- 上层策略和引擎只调用
hqdata.api,不直接接触任何数据源
支持的数据源
| 数据源 | 状态 | 说明 |
|---|---|---|
| AKShare | 计划中 | 免费,实时数据 |
| Tushare | 已接入 | 需满足账户积分要求,支持股票&指数的历史日线 |
| 米筐 | 接入中 | 需license,支持Tick |
| 迅投 | 计划中 | 需迅投终端 |
| iTick | 计划中 | 需注册 |
安装
方式一:通过pip安装
# 基础安装(仅包含核心功能)
pip install hqdata
# 按需安装数据源依赖
pip install hqdata[tushare] # Tushare 支持
pip install hqdata[ricequant] # 米筐支持
pip install hqdata[tushare,ricequant] # 同时安装两者
# 复制模板并自行填入所需字段
cp .env.example .env # 放在你运行 Python 代码的当前目录(优先)/包安装目录
方式二:本地开发
# 创建虚拟环境
python -m venv .venv
source .venv/bin/activate
# 安装依赖 (editable 模式,改代码直接生效)
pip install -e .
# 复制模板并自行填入所需字段
cp .env.example .env # 放在你运行 Python 代码的当前目录(优先)/包安装目录
使用
以 Tushare 为例:
from hqdata import init_source, get_stock_list, get_stock_bar, get_index_list, get_index_bar
# 初始化
init_source("tushare")
# 查询股票列表
df = get_stock_list()
print(df.head())
# 查询日线数据 (symbol 格式: "代码.交易所")
df = get_stock_bar("000001.SZ", frequency="1day", start_date="20260101", end_date="20260401")
print(df.head())
# 查询指数列表
df = get_index_list(market="SSE")
print(df.head())
# 查询指数日线数据
df = get_index_bar("000300.SH", start_date="20260101", end_date="20260401")
print(df.head())
测试
pytest tests/ -v
pytest tests/test_tushare.py::TestTushareIntegration::test_get_stock_bar # 运行单个测试
输入参数格式说明
股票代码
symbol 参数统一使用 代码.交易所 格式:
| 交易所 | 代码 | 示例 |
|---|---|---|
| 上交所 | SH | 600000.SH |
| 深交所 | SZ | 000001.SZ |
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
hqdata-0.1.7.tar.gz
(10.6 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file hqdata-0.1.7.tar.gz.
File metadata
- Download URL: hqdata-0.1.7.tar.gz
- Upload date:
- Size: 10.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5bc609c4a6cb3295d064ce7a70cc594474b1aa952eef84dff63a73f323d4fe5e
|
|
| MD5 |
fd63abf7e8fc87eb0023b6f6261db483
|
|
| BLAKE2b-256 |
70e5b8b2dbdd5764240df0fbf623dff6358fa26af7faf9fafecf562c97d9eca8
|
File details
Details for the file hqdata-0.1.7-py3-none-any.whl.
File metadata
- Download URL: hqdata-0.1.7-py3-none-any.whl
- Upload date:
- Size: 9.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7adbb7f6eba3dd43857e83664c07c7985db21f968e997b98bdbdca925ba29944
|
|
| MD5 |
80f5aae482bfb84c93aa5c213a804826
|
|
| BLAKE2b-256 |
971facf7b7eeb5cc6ef8519d4ee67e1d7a2d43764508a1f58f09cbb8a46a18dd
|