Skip to main content

agent-stock

CI PyPI version Python

面向 AI Agent 的股市数据命令行工具,提供市场概览、个股行情、板块涨跌、技术指标与资金流向等信息。

📦 安装

# uv tool
uv tool install agent-stock  # 安装
uv tool upgrade agent-stock  # 升级

# pip
python -m pip install agent-stock     # 安装
python -m pip install -U agent-stock  # 升级

🚀 快速开始

# 市场数据
stock index
stock search 腾讯
stock rank --count 20

# 个股数据
stock quote 000001

# 帮助与版本
stock --help
stock quote --help
stock -v

🔧 命令

可以通过 stock --help 或 stock <子命令> --help 查看帮助。

市场数据

stock index                               # 大盘主要指数总览(A股含申万一级行业数据)
stock search <keyword>                    # 股票搜索,仅限股票名称、股票代码、股票简称搜索
stock query <condition>                   # 条件选股
stock rank --sort <sort> --count <count>  # 市场股票排序,sort 默认值 turnover

# 参数说明:
# - sort: 排序类型,可选 成交额 turnover|量比 volumeRatio|换手率 exchange|涨跌幅 priceRatio|主力净流入 netMainIn
# - count: 排序数量,默认 20,取值范围 1 - 100
# - keyword: 关键词,示例:腾讯、tengxun等
# - condition: 自然语言的条件语句,示例:"MACD金叉;KDJ金叉;非ST;非涨停;市盈率大于0;市盈率小于100;市值大于50亿;"

个股数据

stock detail <symbol>               # 个股详情,包含股票实时行情、日K数据、技术指标、分时数据、资金流向、相关板块和概念、新闻等
stock quant <symbol>                # 个股数据实时量化分析结果

# 参数说明:
# - symbol: A 股股票代码,如 600519、000001

🤖 技能

Skill 安装

npx skills add https://github.com/AnoyiX/agent-stock/tree/main/skills/agent-stock

Skill 清单

【个股决策】

输入示例: 帮我决策中国平安、帮我决策000001、使用量化方式帮我决策中国平安

【AI 选股】

输入示例: 帮我选股

【持仓分析】

输入示例(建议单次分析不要超过 6 只股票持仓的记录):

帮我分析持仓:

资金余额: 1000000

代码,名称,现价,成本,股数,持仓收益率,持仓占比
000001,xxxxxx,20.45,20.33,400,+4.96%,1.51%
000002,xxxxxx,20.82,21.84,1600,-2.92%,6.00%
000003,xxxxxx,3.46,3.89,39900,-1.05%,24.41%
000004,xxxxxx,26.89,25.34,1500,+2.88%,6.92%

[!TIP] Stocks AI 投资账本 可以一键复制持仓信息!

🐛 开发

# 安装依赖
uv sync

# 运行测试
uv run pytest tests/ -v

# Lint
uv run ruff check .

# 调试
uv run python -m stock quote 000001

在 IDE 中启用该技能,以 Trae 为例:

mkdir -p $(pwd)/.trae/skills/

ln -s $(pwd)/skills $(pwd)/.trae/skills

Metadata

Release files for agent-stock 0.2.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for agent-stock 0.2.8
File Size Uploaded
agent_stock-0.2.8.tar.gz 96.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for agent-stock 0.2.8
File Interpreter ABI Platform
agent_stock-0.2.8-py3-none-any.whl Python 3 none any Details

Total release size: 132.3 kB

Release files / agent_stock-0.2.8.tar.gz

Download URL agent_stock-0.2.8.tar.gz
Size 96.1 kB
Tags Source
SHA-256 checksum
How to use checksums
fbc1cd0d4d07faec93616ee6dcfedd5f0738b281cb4473c232f42dd1c6e5f477
BLAKE2b-256 checksum
How to use checksums
ae286395a5db87f50c5be14bf1fb620376f1a781b2ff4afe7c80e32cae210340
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 25, 2026.

Transparency log

Release files / agent_stock-0.2.8-py3-none-any.whl

Download URL agent_stock-0.2.8-py3-none-any.whl
Size 36.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9fe5f361c042a3660f221622a6f16823cc68393b018282a79430a3b3fa1f3286
BLAKE2b-256 checksum
How to use checksums
4f2bd15560032e250fb6bad27ae0a612ab6d98b295e6112a4f9cd9ee7270546c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 25, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.2.8 This release

2 release files

0.2.7

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page