← 返回 Skills 市场
ugpoor

Current Akshare List

作者 superStupidBear · GitHub ↗ · v1.0.1 · MIT-0
cross-platform ⚠ suspicious
83
总下载
0
收藏
0
当前安装
2
版本数
在 OpenClaw 中安装
/install current-akshare-list
功能描述
通过akshare下载所有A股、创业板、B股股票简况并用实时行情列表校对,获得当前正在交易的所有AB和创业板股票清单,以及不在交易的股票清单(代码、简称、上市时间),保存为csv。触发词:"A股股票列表"、"更新股票列表"、"股票列表下载"、"akshare股票"、"获取全部A股"、"沪深京A股"、"不在交易股票...
使用说明 (SKILL.md)

current-akshare-list

获取A股全量股票基础信息列表,并用实时行情接口交叉验证,输出「在交易」和「不在交易」两份清单。

环境要求

  • Python 3.11+
  • akshare SDK:pip install akshare
  • 若接口封禁,需开启VPN或建立定时任务等待

工作流程

第一步:下载股票基础信息(可选,若已有可跳过)

从六个市场来源获取股票列表,合并去重:

import akshare as ak
import pandas as pd

sources = [
    ("沪A", lambda: ak.stock_info_sh_name_code(symbol="主板A股")),
    ("沪B", lambda: ak.stock_info_sh_name_code(symbol="主板B股")),
    ("沪创", lambda: ak.stock_zh_index_cons_ci(symbol="000688")),
    ("深A", lambda: ak.stock_info_sz_name_code(symbol="A股列表")),
    ("深B", lambda: ak.stock_info_sz_name_code(symbol="B股列表")),
    ("京A", lambda: ak.stock_info_bj_a_code_name()),
]

results = []
for name, fn in sources:
    try:
        df = fn()
        df["source"] = name
        results.append(df)
    except Exception as e:
        print(f"{name} 获取失败: {e}")

stocklist = pd.concat(results).drop_duplicates(subset=["code"])
stocklist.columns = ["Symbol", "ShortName", "ListedDate", "Source"]
stocklist.to_csv("stocklist.csv", index=False)

第二步:实时行情接口验证(核心)

依次尝试三个接口,遇到封堵则处理:

import akshare as ak
import json

def fetch_spot_data():
    """获取三接口实时行情数据"""
    data = {}
    
    # 1. A股实时行情
    try:
        df = ak.stock_zh_a_spot_em()
        codes = df[['代码','名称']].to_dict('records')
        with open('/tmp/akshare_a_codes.json', 'w') as f:
            json.dump(codes, f, ensure_ascii=False)
        data['a'] = len(codes)
        print(f"✅ A股成功: {len(codes)} 条")
    except Exception as e:
        print(f"❌ A股失败: {type(e).__name__}: {e}")
        raise ConnectionError(f"A股接口封禁: {e}")
    
    # 2. B股实时行情
    try:
        df = ak.stock_zh_b_spot_em()
        codes = df[['代码','名称']].to_dict('records')
        with open('/tmp/akshare_b_codes.json', 'w') as f:
            json.dump(codes, f, ensure_ascii=False)
        data['b'] = len(codes)
        print(f"✅ B股成功: {len(codes)} 条")
    except Exception as e:
        print(f"❌ B股失败: {e}")
    
    # 3. 科创板实时行情
    try:
        df = ak.stock_zh_kcb_spot()
        codes = df[['代码','名称']].to_dict('records')
        with open('/tmp/akshare_kcb_codes.json', 'w') as f:
            json.dump(codes, f, ensure_ascii=False)
        data['kcb'] = len(codes)
        print(f"✅ 科创板成功: {len(codes)} 条")
    except Exception as e:
        print(f"❌ 科创板失败: {e}")
    
    return data

# 执行获取
try:
    data = fetch_spot_data()
    print(f"完成: {data}")
except ConnectionError as e:
    print(f"接口封禁,需要处理...")
    raise

第三步:对比分析

import json, csv

# 读取三个接口数据
with open('/tmp/akshare_a_codes.json', 'r') as f:
    a_codes = set(item['代码'] for item in json.load(f))
with open('/tmp/akshare_b_codes.json', 'r') as f:
    b_codes = set(item['代码'] for item in json.load(f))
with open('/tmp/akshare_kcb_codes.json', 'r') as f:
    kcb_codes = set(item['代码'] for item in json.load(f))

# 读取 stocklist
stocklist_codes = set()
stocklist_info = {}
with open('stocklist.csv', 'r', encoding='utf-8-sig') as f:
    reader = csv.DictReader(f)
    for row in reader:
        code = row['Symbol'].strip()
        stocklist_codes.add(code)
        stocklist_info[code] = {'name': row.get('ShortName', ''), 'date': row.get('ListedDate', '')}

# 三接口合并(去重)
all_spot_codes = a_codes | b_codes | kcb_codes

# 对比分析
in_spot_not_stocklist = all_spot_codes - stocklist_codes  # 需补充
in_stocklist_not_spot = stocklist_codes - all_spot_codes  # notspot

print(f"需补充: {len(in_spot_not_stocklist)}")
print(f"notspot: {len(in_stocklist_not_spot)}")

第四步:接口封禁处理

当东财接口被封(ConnectionError、RemoteDisconnected)时:

方案A:用户手动处理

告知用户:"东方财富接口被封,请开启VPN后重新执行,或选择建立定时任务自动重试"

方案B:自动建立定时任务

1. 创建 cron 任务,每30分钟重试东财接口
2. 若成功:执行全量对比 → 输出结果 → 删除自身任务
3. 若失败:输出"仍被封,等待下次尝试" → 保留任务继续重试
4. 最大重试次数:24次(12小时),超时后通知用户
# 定时任务 payload 示例
{
    "kind": "agentTurn",
    "message": "重试东财接口,若成功则完成全量对比并输出结果到指定路径",
    "sessionTarget": "isolated"
}

第五步:输出结果文件

文件 说明 字段
stocklist.csv 全量股票基础信息 代码、简称、上市日期、来源
stocklist_intrading.csv 当前在交易股票 代码、简称、上市日期
notspot.csv 不在交易股票清单 代码、简称、上市日期

VPN 环境说明

东方财富接口(stock_zh_a_spot_em)在大陆IP下经常被封:

  • 开启VPN后:通常可稳定获取数据
  • 无VPN:接口返回 ConnectionError 或 RemoteDisconnected

若遇封禁,建议:

  1. 开启VPN后重试
  2. 建立定时任务自动重试(适合夜间执行)

已知限制

  • B股不在部分实时行情覆盖范围内,预期出现在 notspot 中
  • 科创板全量通过指数成分股接口获取(非直接全量列表)
安全使用建议
This skill appears to do what it says: it uses akshare to download and cross-check stock lists and writes CSV outputs. Before installing, consider: 1) akshare must be installed (pip) and may request network access; test the provided script manually to verify results. 2) The script writes intermediate files to /tmp and final CSVs to the current directory—verify those paths are acceptable and that no sensitive files will be overwritten. 3) SKILL.md suggests creating cron/agent scheduled retries if the realtime API is blocked; scheduling gives the skill persistence (it can run unattended). Only enable that automation if you trust the environment and have reviewed how scheduled tasks are created and removed. 4) No credentials are requested by the skill, which is good; still review network access and rate limits, and consider running first in an isolated environment. 5) If you are uncomfortable with automated retries or agent-scheduled tasks, run the script manually and handle retries yourself.
功能分析
Type: OpenClaw Skill Name: current-akshare-list Version: 1.0.1 The skill bundle contains instructions in SKILL.md that direct the AI agent to establish system persistence by creating cron jobs to automatically retry failed network requests. It also explicitly instructs the agent to prompt the user to use a VPN to bypass IP-based blocking from financial data providers. While these behaviors are framed as reliability features for the akshare library, the use of automated persistence and instructions to circumvent network security controls are high-risk patterns that could be repurposed for malicious activity.
能力评估
Purpose & Capability
The name/description match the included code and SKILL.md: it uses akshare to fetch market lists and realtime spot data, merges results, and writes CSVs. There are no unexpected env vars, binaries, or third-party credentials requested.
Instruction Scope
Runtime instructions focus on fetching lists, validating via realtime endpoints, and writing CSVs. They also describe handling API blocking by advising VPN use or creating a repeating task to retry. The suggested 'agentTurn' payload and cron retry behavior expand scope from a one-shot data fetch to automated scheduled retries — reasonable for reliability but worth confirming you want that automation and that the agent/platform will only perform the intended actions.
Install Mechanism
No install spec is included; this is instruction + a small Python script. The SKILL.md correctly recommends installing akshare via pip. There are no remote downloads or archive extraction performed by the skill itself.
Credentials
The skill requests no environment variables, credentials, or special config paths. The script writes output to the current directory (stocklist.csv) and to /tmp for intermediate JSON files — these file operations are proportional to the task.
Persistence & Privilege
While the skill itself is not 'always' enabled, the SKILL.md explicitly describes creating cron jobs and an 'agentTurn' scheduled payload to retry blocked APIs and to delete the job on success. That behavior would create persistence on the host or via the agent scheduler. Confirm whether you want automated scheduled retries and ensure the agent/host environment and permissions are controlled before enabling automation.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install current-akshare-list
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /current-akshare-list 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.1
- 新增 scripts/fetch_spot.py 脚本示例,用于抓取实时行情数据并分市场保存为 JSON。 - SKILL.md 优化实时行情校验流程说明,细化“接口封禁”后的两种处理方案(用户手动或自动定时重试)。 - 明确建议用户遇东财接口被封时优先开启 VPN,提高获取数据的可靠性。 - 输出和对比步骤增加代码示例,说明如何合并/校验在交易和不在交易股票。 - SKILL.md 文档优化,更突出实际操作流程与注意事项。
v1.0.0
- 首个版本发布:自动获取A股、创业板、B股股票简况,基于实时行情筛选当前在交易与不在交易股票,输出两份清单。 - 支持多市场合并,避免重复;自动判别沪深京主板、B股、科创板。 - 加入行情接口交叉验证,显式处理接口封禁,自动定时重试并通知。 - 输出代码、简称、上市时间到csv文件,分为全量、在交易、未交易三类。 - 明确环境及依赖要求,保障流程可用性。
元数据
Slug current-akshare-list
版本 1.0.1
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 2
常见问题

Current Akshare List 是什么?

通过akshare下载所有A股、创业板、B股股票简况并用实时行情列表校对,获得当前正在交易的所有AB和创业板股票清单,以及不在交易的股票清单(代码、简称、上市时间),保存为csv。触发词:"A股股票列表"、"更新股票列表"、"股票列表下载"、"akshare股票"、"获取全部A股"、"沪深京A股"、"不在交易股票... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 83 次。

如何安装 Current Akshare List?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install current-akshare-list」即可一键安装,无需额外配置。

Current Akshare List 是免费的吗?

是的,Current Akshare List 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

Current Akshare List 支持哪些平台?

Current Akshare List 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 Current Akshare List?

由 superStupidBear(@ugpoor)开发并维护,当前版本 v1.0.1。

💬 留言讨论