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_bar
# 初始化 Tushare (日线数据)
init_source("tushare")
# 获取日线数据 (symbol 格式: "代码.交易所")
df = get_bar("600000.SH", frequency="1day", start_date="20260401", end_date="20260402")
print(df.head())
输入参数格式说明
股票代码
symbol 参数统一使用 代码.交易所 格式:
| 交易所 | 代码 | 示例 |
|---|---|---|
| 上交所 | SH | 600000.SH |
| 深交所 | SZ | 000001.SZ |
测试
pytest tests/ -v
pytest tests/test_tushare.py::TestTushareIntegration::test_get_bar # 运行单个测试
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.2.tar.gz
(8.9 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.2.tar.gz.
File metadata
- Download URL: hqdata-0.1.2.tar.gz
- Upload date:
- Size: 8.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cca3134df4768c5df8d42cb3aa9fe17fbfa982812fba333b4af98b1a3e28d3f6
|
|
| MD5 |
52eb3636cdf4abf3314cba8325a3c078
|
|
| BLAKE2b-256 |
e3069f952c4c9556957f5a24171a9205296a1773b337240306d0c553994c3db9
|
File details
Details for the file hqdata-0.1.2-py3-none-any.whl.
File metadata
- Download URL: hqdata-0.1.2-py3-none-any.whl
- Upload date:
- Size: 8.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 |
56a0d07d94c5807438b3df37081fd64e30d10b57d7e5da42f1d0d443d502d342
|
|
| MD5 |
7ae3a8d500c8c70b93b78f3fcf409133
|
|
| BLAKE2b-256 |
1e78454d149b37f57a58c06a8cf25f9a6cc083997661fe66268027240f818533
|