Skip to main content

A quantitative trading system development framework for A-share stock market

Project description

ClawQuant

Python Version License

中文 | English

注意: ClawQuant 是专门为 OpenClaw 定制的量化交易 Skill 框架,推荐通过 OpenClaw 自动安装使用。

ClawQuant 是一个基于 Python 的开源量化交易系统开发框架,专注于 A 股市场。它提供了从数据获取、因子计算、策略回测到交易执行的完整量化交易解决方案。

安装方式

方式一:通过 OpenClaw 自动安装(推荐)

在 OpenClaw 中添加 Skill 即可自动完成安装:

# OpenClaw 会自动完成以下操作:
# 1. pip install agent-quant
# 2. 安装依赖
# 3. 配置环境

方式二:手动 pip 安装

pip install agent-quant

方式三:从源码安装

git clone https://github.com/clawquant/agentquant.git
cd agentquant
pip install -e .

快速开始

1. 启动数据库服务

Windows:

# 前台运行
start_db_server.bat

# 后台运行
start_db_server.bat --bg

Linux/Mac:

# 添加执行权限
chmod +x start_db_server.sh

# 前台运行
./start_db_server.sh

# 后台运行
./start_db_server.sh --bg

2. 使用 CLI 工具

# 查看帮助
python -m agentquant.cli --help

# 更新数据
python -m agentquant.cli update --codes 000001.SZ --date 2024-06-01

# 查询数据
python -m agentquant.cli query --code 000001.SZ --start 2024-01-01 --end 2024-06-01

# 查看可用因子
python -m agentquant.cli factor list

# 策略回测
python -m agentquant.cli strategy backtest CROSS_STRATEGY --codes 000001.SZ --start 2024-01-01 --end 2024-06-01

3. 使用 Python API

from agentquant.database.api import StockAPI

# 创建 API 实例
api = StockAPI()

# 获取日线数据
df = api.get_daily('000001.SZ', '2024-01-01', '2024-06-01')
print(df)

# 获取股票列表
stocks = api.get_all_stocks()
print(stocks)

功能特性

📊 数据管理

  • 多数据源支持:通过 QMT (XtQuant) 获取实时行情数据
  • 本地数据存储:基于 DuckDB 的高性能本地数据存储
  • HTTP API 服务:提供标准化的数据访问接口
  • 自动数据更新:支持定时任务自动更新数据

🔬 因子分析

  • 内置因子库:包含技术指标、情绪指标、质量因子等 20+ 常用因子
  • 自定义因子:支持用户自定义因子计算
  • 因子回测:支持 IC 测试、分层收益测试等

📈 策略回测

  • 多引擎支持
    • Local:本地轻量级回测引擎
    • CSKhQuant:基于 CSKhQuant 框架的回测
    • JQData:聚宽数据回测引擎
    • VNPY:基于 VNPY 框架的回测
  • 统一接口:所有引擎使用统一的输入输出格式
  • 策略库:内置均线交叉、MACD 等经典策略

🖥️ 图形界面

  • 数据查看器:可视化查看股票数据和因子数据
  • 回测界面:图形化策略回测和结果展示
  • 批量下载:支持批量数据下载和管理

🤖 AI 支持

  • Skill 接口:提供标准化的 AI Agent 调用接口
  • CLI 工具:命令行工具支持自动化操作

项目结构

agentquant/
├── database/          # 数据管理模块
│   ├── api.py         # 数据访问接口
│   ├── storage/       # 数据存储(DuckDB)
│   ├── updater/       # 数据更新
│   └── source/        # 数据源(QMT)
├── backtest/          # 回测引擎
├── factor/            # 因子库
├── strategy/          # 策略库
├── gui/               # 图形界面
├── utils/             # 工具函数
├── scripts/           # 脚本工具
├── skills/            # AI Skill 接口
├── tests/             # 测试代码
├── cli.py             # 命令行工具
├── examples/          # 示例代码
└── docs/              # 文档

依赖说明

核心依赖

  • Python >= 3.8
  • DuckDB >= 0.9.0
  • Pandas >= 2.0.0
  • NumPy >= 1.24.0
  • PyQt5 >= 5.15.0

可选依赖

  • 数据接口:xtquant (QMT 数据接口)
  • 回测引擎
    • CSKhQuant:需要单独安装
    • JQData:需要聚宽账号
    • VNPY:需要安装 vnpy 包

关于 QMT

QMT (迅投) 是本项目的主要数据源,用于获取 A 股实时行情数据。由于 QMT 不在开源社区,需要用户自行安装:

  1. 下载并安装 QMT 客户端
  2. 安装 xtquant Python 包
  3. 配置 QMT 路径

详细配置请参考 QMT 配置文档

文档

贡献指南

我们欢迎所有形式的贡献,包括但不限于:

  • 提交 Bug 报告
  • 提交功能建议
  • 提交代码改进
  • 完善文档

请参考 CONTRIBUTING.md 了解详细贡献流程。

社区与支持

许可证

本项目采用 MIT 许可证 开源。

免责声明

本项目仅供学习和研究使用,不构成任何投资建议。使用本项目进行实盘交易的风险由用户自行承担。

致谢

感谢以下开源项目的贡献:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

agent_quant-0.2.44.tar.gz (226.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

agent_quant-0.2.44-py3-none-any.whl (282.0 kB view details)

Uploaded Python 3

File details

Details for the file agent_quant-0.2.44.tar.gz.

File metadata

  • Download URL: agent_quant-0.2.44.tar.gz
  • Upload date:
  • Size: 226.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for agent_quant-0.2.44.tar.gz
Algorithm Hash digest
SHA256 af6b65554e511e3df04b6022fe676ee635444c9bd2eefb42884f8c5017f0dbd4
MD5 cfafe705a6fff0dee86034390dcdb96a
BLAKE2b-256 4149459d2a3f7e78aaed9c7a3d781eb4f18c4c0f12ab168df012591543d80b61

See more details on using hashes here.

File details

Details for the file agent_quant-0.2.44-py3-none-any.whl.

File metadata

  • Download URL: agent_quant-0.2.44-py3-none-any.whl
  • Upload date:
  • Size: 282.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for agent_quant-0.2.44-py3-none-any.whl
Algorithm Hash digest
SHA256 1d7848472348f1596fa8066d6bd1111a89af6aa73dd451b1180f2a595ac83530
MD5 e5bfee386e583230c1c90f3fe1e7b54d
BLAKE2b-256 5bd169a12098f63524de000efbe60a0221212e287bf774fff81b73bc51804f5e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page