
Akshare Stock
Run natural-language A-share and cross-market stock analysis in OpenClaw with compact outputs for QQ or Telegram.
Overview
AKShare Stock is an agent skill most often used in Grow (also Build integrations) that routes natural-language queries to akshare-backed A-share and cross-market analysis with compact chat output.
Install
npx skills add https://github.com/molezzz/openclaw-stock-skill --skill akshare-stockWhat is this skill?
- Router → Service → Analyzer → Formatter four-layer architecture for extensibility
- Covers quotes, K-line, fundamentals, sectors, futures, funds, and cross-market adapters via akshare
- Natural-language routing to intent, symbols, timeframe, metrics, and top_n
- Dedicated analyzers for K-line, capital flow, and sector rotation with 30–120s cache
- Output formatted for compact QQ/Telegram messaging
- 4-layer architecture: Router, Service, Analyzer, Formatter
- 30–120 second short cache window documented
Adoption & trust: 9.7k installs on skills.sh; 14 GitHub stars; 1/3 security scanners passed (skills.sh audits).
What problem does it solve?
You need fast, conversational A-share intelligence across quotes, fundamentals, and sectors without manually chaining akshare calls and formatting charts for mobile chat.
Who is it for?
Indie builders running OpenClaw on Mac who trade or research Chinese equities and want one skill for multi-domain market questions.
Skip if: Builders who need licensed institutional terminals, non-Python stacks, or markets with zero akshare coverage.
When should I use this skill?
User asks for A-share or related market analysis in natural language inside OpenClaw.
What do I get? / Deliverables
You get routed analysis text with computed indicators, flow reads, and sector context suitable for QQ or Telegram, backed by a modular Python skill tree you can extend.
- Structured market analysis text for chat channels
- Extensible router/service modules for new intents
Recommended Skills
Journey fit
Spans multiple journey phases - primary shelf plus alternate fits below.
Analytics is the canonical shelf because the skill’s value is interpreting market data, not scaffolding a generic app UI. Grow analytics fits ongoing monitoring, sector rotation, and flow reads rather than one-time prototype validation.
Where it fits
Morning scan of index moves, limit-up counts, and main-force inflow before adjusting watchlists.
Compare sector rotation strength across concepts to decide which theme still has persistence.
Wire main.py --query into an OpenClaw bot that answers QQ group finance questions.
Quick health read on data adapters when akshare endpoints change and caches look stale.
How it compares
Skill-packaged research workflow—not a hosted brokerage API or a simple single-ticker price checker.
Common Questions / FAQ
Who is akshare-stock for?
Solo operators using OpenClaw who analyze A-shares and related instruments and want NL-driven reports in chat apps.
When should I use akshare-stock?
During Grow analytics for daily market checks; during Build integrations when composing bots; before trades when you need sector rotation or flow context.
Is akshare-stock safe to install?
Review the Security Audits panel on this Prism page; the skill pulls third-party market data and runs Python with network access—never treat outputs as investment advice.
SKILL.md
READMESKILL.md - Akshare Stock
# A股分析全能 Skill(AKShare) 目标:在 OpenClaw 中通过自然语言触发 A 股和相关市场分析,输出适配 QQ/Telegram 的紧凑文本。 - 运行环境:Mac + Python 3.9 - akshare 路径:`/Users/molezz/Library/Python/3.9/lib/python3.9/site-packages` - Skill 入口建议:`python3 skills/akshare-stock/main.py --query "${USER_QUERY}"` --- ## 1) 整体架构设计 采用 `Router -> Service -> Analyzer -> Formatter` 四层结构,便于扩展和维护。 ### A. 目录组织(建议) ```text skills/akshare-stock/ SKILL.md main.py # OpenClaw 调用入口 router.py # 意图识别 + 参数解析 schemas.py # 数据结构定义(dataclass) formatter.py # QQ/Telegram 输出模板 services/ market_service.py # 大盘/个股行情、K线、分时、涨跌停、资金流 fundamental_service.py# 财务指标、财报、融资融券、龙虎榜 sector_service.py # 行业/概念板块、轮动、板块资金流 cross_service.py # 期货/期权、基金、可转债、港股/美股 analyzers/ kline_analyzer.py # 均线、振幅、涨跌幅、量比等 flow_analyzer.py # 主力净流入、连续性、强弱排序 rotation_analyzer.py # 板块轮动强度、持续性 adapters/ akshare_adapter.py # 封装 akshare 接口,隔离 API 变化 utils/ trading_calendar.py # 交易日判断 symbols.py # 指数/股票/板块别名映射 cache.py # 短缓存(30~120 秒) ``` ### B. 核心流程 1. `main.py` 接收自然语言 query。 2. `router.py` 输出结构化意图:`intent + symbols + timeframe + metric + top_n`。 3. `services/*` 拉取原始数据(只做数据获取和轻清洗)。 4. `analyzers/*` 做指标计算和结论生成。 5. `formatter.py` 按聊天平台压缩输出(短句、分段、emoji、重点数值)。 ### C. 关键设计点 - **意图优先级**:先识别“任务类型”,再解析标的和参数,避免误判。 - **适配层隔离**:akshare 接口若改名,只需改 `adapters/akshare_adapter.py`。 - **容错回退**:实时接口失败时回退到最近交易日数据,并标注“非实时”。 - **缓存策略**: - 大盘/资金流:30~60 秒 - 板块排行:60~120 秒 - 财报/财务:当天缓存 - **消息长度控制**:单条建议 <= 1000 字符;超长自动拆分 2~3 条。 --- ## 2) 触发词设计(自然语言路由) 建议采用“关键词 + 正则 + 别名词典”混合方式。 ### A. 意图分类(Intent) - `INDEX_REALTIME`:实时大盘 - `KLINE_ANALYSIS`:历史 K 线 - `INTRADAY_ANALYSIS`:分时分析 - `LIMIT_STATS`:涨跌停统计 - `MONEY_FLOW`:资金流向 - `FUNDAMENTAL`:财务指标 / 财报 - `MARGIN_LHB`:融资融券 / 龙虎榜 - `SECTOR_ANALYSIS`:行业/概念/轮动/板块资金 - `DERIVATIVES`:期货/期权 - `FUND_BOND`:基金净值 / 可转债 - `HK_US_MARKET`:港股 / 美股 ### B. 触发词样例 - 实时大盘:`A股大盘` `上证现在多少` `沪深300实时` - K线:`贵州茅台近60日K线` `宁德时代周线` `比亚迪月线复权` - 分时:`看下000001分时` `平安银行今天分时走势` - 涨跌停:`今日涨停统计` `跌停家数` `连板梯队` - 资金流:`主力资金流入前十` `北向资金` `行业资金净流入` - 基本面:`茅台财务指标` `宁德时代最新季报` `ROE和毛利率` - 融资融券/龙虎榜:`中兴通讯融资融券` `今日龙虎榜` - 板块:`行业板块涨幅榜` `概念轮动` `AI板块资金流` - 其他市场:`IF主力合约` `300ETF期权` `基金净值` `可转债行情` `腾讯港股` `英伟达美股` ### C. 参数抽取规则 - 股票代码:`\b\d{6}\b`(如 `600519`) - 日期:`YYYYMMDD` / `YYYY-MM-DD` / `今天/昨日/近N日` - 周期:`1m/5m/15m/30m/60m/day/week/month` - 排名:`前N`(默认 10) - 复权:`前复权/后复权/不复权` --- ## 3) 各功能实现思路 下面是“功能 -> 推荐数据 -> 分析输出”的落地框架(接口以 akshare 当前版本为准,实际以 adapter 层统一封装)。 ### 3.1 实时大盘行情(已有基础版,升级点) - 数据:上证、深成指、创业板、沪深300、上证50、科创50。 - 增强:加入成交额、振幅、领涨板块、北向资金当日净流入。 - 输出:`指数点位 + 涨跌幅 + 市场情绪一句话`。 ### 3.2 行情分析 - **历史K线**: - 数据:日/周/月 K 线(复权可选)。 - 指标:近 N 日涨跌幅、5/10/20 日均线、量能变化、波动率。 - 输出:趋势判断(多头/震荡/走弱)+ 关键位(支撑/压力)。 - **分时数据**: - 数据:分钟级行情。 - 指标:VWAP 偏离、盘中高低点、午后资金回流。 - **涨跌停统计**: - 数据:涨停池、跌停池、连板梯队。 - 指标:涨停家数、炸板率、最高连板、情绪评分。 - **资金流向**: - 数据:个股/行业/市场资金流。 - 指标:主力净流入 TopN、连续净流入天数、资金集中度。 ### 3.3 基本面分析 - **个股财务指标**:ROE、毛利率、净利率、资产负债率、经营现金流。 - **财报数据**:营收同比、净利润同比、扣非净利润同比、EPS。 - **融资融券**:融资余额、融券余额、日变动,识别杠杆偏好。 - **龙虎榜**:上榜原因、买卖前五席位净额、游资活跃度。 - 输出风格:`核心指标摘要 + 同比/环比 + 风险提示`。 ### 3.4 板块分析 - **行业板块涨跌**:行业涨跌幅榜、成交额、上涨家数。 - **概念板块轮动**:近 5 日强度、持续性、日内切换速度。 - **板块资金流向**:行业/概念净流入排行 + 领涨龙头。 - 输出:`强势板块Top3 + 轮动结论 + 次日观察点`。 ### 3.5 其他(跨市场) - 期货/期权:主力合约价格、涨跌、持仓变化;期权 PCR(若可得)。 - 基金净值:开放式基金净值、估值偏离、近一周收益。 - 可转债:价格、溢价率、正股联动、成交额。 - 港股/美股:实时行情、近5日表现、与A股联动提示。 --- ## 4) 代码示例框架(骨架) > 说明:以下为可直接落地的最小框架,不含完整业务细节。 ### `main.py` ```python #!/usr/bin/env python3 # -*- coding: utf-8 -*- import argparse from router import parse_query from services.market_service import MarketService from services.fundamental_service import FundamentalService from services.sector_service import SectorService from services.cross_service import CrossServ