Ashareskill

v0.1.0

使用BaoStock获取股票K线数据及完整技术指标的专业工具。支持单只股票或股票池查询,支持自定义时间段和K线级别(日线/周线/月线),获取的数据包含均线、MACD、KDJ、RSI、BOLL、CCI等完整技术指标。适用于:1)获取股票历史K线数据用于策略回测;2)导出完整技术指标数据用于量化分析;3)批量获取多只...

0· 174·0 current·0 all-time

Install

OpenClaw Prompt Flow

Install with OpenClaw

Best for remote or guided setup. Copy the exact prompt, then paste it into OpenClaw for caoyachao/ashareskill.

Previewing Install & Setup.
Prompt PreviewInstall & Setup
Install the skill "Ashareskill" (caoyachao/ashareskill) from ClawHub.
Skill page: https://clawhub.ai/caoyachao/ashareskill
Keep the work scoped to this skill only.
After install, inspect the skill metadata and help me finish setup.
Use only the metadata you can verify from ClawHub; do not invent missing requirements.
Ask before making any broader environment changes.

Command Line

CLI Commands

Use the direct CLI path if you want to install manually and keep every step visible.

OpenClaw CLI

Bare skill slug

openclaw skills install ashareskill

ClawHub CLI

Package manager switcher

npx clawhub@latest install ashareskill
Security Scan
VirusTotalVirusTotal
Benign
View report →
OpenClawOpenClaw
Benign
medium confidence
Purpose & Capability
Name/description ask for A‑share K‑line & indicators via BaoStock; included Python code uses the baostock library and computes standard indicators with pandas/numpy — these requirements match the described purpose and are proportionate.
Instruction Scope
SKILL.md instructs running the included Python script or importing AShareSkill; instructions do not request unrelated files/credentials. Minor inconsistencies exist in example invocation paths (SKILL.md references 'kimi/ashareskill/...' while the repository layout provides 'scripts/ashareskill.py' and README uses 'scripts/ashareskill.py'), which may cause runtime/import errors but are not a security concern.
Install Mechanism
No install spec is provided (instruction-only skill with a requirements.txt). Dependencies are standard Python packages (baostock, pandas, numpy); there is no remote download or archive extraction of arbitrary code specified in the manifest.
Credentials
The skill declares no required environment variables, no credentials, and the code calls baostock.login() without external secret injection. Requested runtime behavior (network calls to BaoStock) is expected and proportionate to the purpose.
Persistence & Privilege
Skill does not request 'always: true' or any elevated/system‑wide persistence. It performs one-time runtime network queries and caches stock lists locally in memory; no modification of other skills or system config is observed.
Assessment
This package appears to be a straightforward BaoStock-based data fetcher. Before installing/running: 1) fix the path/import inconsistencies in SKILL.md vs repository (the examples reference 'kimi/...' but files live under 'scripts/'); 2) install dependencies in a virtualenv and test with a single small query to confirm behavior; 3) be aware the script will make network calls to BaoStock (it logs in and downloads stock lists), so run it in a controlled environment if you are concerned about network activity; 4) review the full scripts/ashareskill.py if you need absolute assurance (the provided fragment is consistent with the description but was truncated in the manifest); 5) this tool is for data retrieval/analysis only and is not investment advice.

Like a lobster shell, security has layers — review code before you run it.

latestvk9704s9bjra53ew6gw608ny88x836dmk
174downloads
0stars
1versions
Updated 1mo ago
v0.1.0
MIT-0

AShareSkill - A股数据获取工具

基于BaoStock数据源的股票数据分析工具,支持获取完整K线数据及各类技术指标。

功能特点

  • 支持多种查询方式:单只股票或股票池批量查询
  • 灵活的时间段:支持自定义起始和结束日期
  • 多级别K线:日线(d)、周线(w)、月线(m)
  • 完整技术指标
    • 均线系统:MA5, MA10, MA20, MA30, MA60, MA120, MA250
    • MACD指标:DIF, DEA, MACD柱状
    • KDJ指标:K值, D值, J值
    • RSI指标:RSI6, RSI12, RSI24
    • 布林带(BOLL):上轨, 中轨, 下轨
    • CCI指标
    • 成交量指标及涨跌幅数据
  • 单一文件输出:所有数据输出为一个CSV文件

使用方法

1. 直接调用脚本

# 单只股票查询
python kimi/ashareskill/scripts/ashareskill.py --stock 贵州茅台 --start 2023-01-01 --end 2024-01-01 --freq d

# 股票池查询(逗号分隔)
python kimi/ashareskill/scripts/ashareskill.py --stock "贵州茅台,中国平安,宁德时代" --start 2023-01-01 --end 2024-01-01

# 使用周线数据
python kimi/ashareskill/scripts/ashareskill.py --stock 600519 --start 2022-01-01 --freq w --output mydata.csv

# 使用月线数据
python kimi/ashareskill/scripts/ashareskill.py --stock 000001 --start 2020-01-01 --freq m

# 获取指数成分股(如中证500)月线数据
python kimi/ashareskill/scripts/ashareskill.py --index 000905 --start 2024-01-01 --freq m -o zz500.csv

# 获取沪深300成分股日线数据
python kimi/ashareskill/scripts/ashareskill.py --index 000300 --start 2024-01-01 --freq d -o hs300.csv

2. 参数说明

参数简写说明默认值
--stock-s股票名称或代码(多只股票用逗号分隔)与--index二选一
--index-i指数代码,获取指数成分股(000905中证500,000300沪深300等)与--stock二选一
--start开始日期 (YYYY-MM-DD)一年前
--end结束日期 (YYYY-MM-DD)今天
--freq-fK线级别: d(日线), w(周线), m(月线)d
--output-o输出文件名自动生成
--adjust-a复权类型: 1(前复权), 2(后复权), 3(不复权)3

3. 作为Python模块使用

from kimi.ashareskill.scripts.ashareskill import AShareSkill

# 创建实例
skill = AShareSkill()

# 获取单只股票数据
df = skill.get_kline_data(
    stock_code="sh.600519",  # 或 "贵州茅台"
    start_date="2023-01-01",
    end_date="2024-01-01",
    frequency="d"
)

# 获取多只股票数据
df_pool = skill.get_stock_pool_data(
    stock_list=["贵州茅台", "中国平安", "宁德时代"],
    start_date="2023-01-01",
    end_date="2024-01-01",
    frequency="d"
)

# 保存到文件
skill.save_to_csv(df_pool, "output.csv")

输出数据字段说明

字段名说明
code股票代码
name股票名称
date交易日期
open开盘价
high最高价
low最低价
close收盘价
preclose前收盘价
volume成交量(股)
amount成交额(元)
turn换手率
pctChg涨跌幅(%)
peTTM滚动市盈率
pbMRQ市净率
psTTM滚动市销率
pcfNcfTTM滚动市现率
isST是否ST股
均线指标
ma5, ma10, ma20, ma30, ma60, ma120, ma250各周期移动平均线
MACD指标
macd_dif, macd_dea, macdDIF线, DEA线, MACD柱状
KDJ指标
kdj_k, kdj_d, kdj_jK值, D值, J值
RSI指标
rsi_6, rsi_12, rsi_246日/12日/24日RSI
布林带
boll_upper, boll_middle, boll_lower上轨, 中轨, 下轨
CCI指标
cciCCI指标值

依赖要求

需要安装以下Python包:

  • baostock
  • pandas
  • numpy

注意事项

  1. 首次使用时会自动登录BaoStock并加载股票列表
  2. K线级别说明:
    • d - 日线:每个交易日一条数据
    • w - 周线:每周一条数据(周五收盘)
    • m - 月线:每月一条数据(月末收盘)
  3. 复权类型说明:
    • 1 - 前复权:保持当前价格不变,调整历史价格
    • 2 - 后复权:保持历史价格不变,调整当前价格
    • 3 - 不复权:原始价格
  4. 技术指标说明:
    • 均线需要足够的历史数据才能计算
    • MA120/MA250等长期均线需要至少120/250个交易日数据
    • MACD、KDJ等指标基于默认参数计算
  5. 支持的指数成分股查询:
    • 000905 - 中证500指数
    • 000300 - 沪深300指数
    • 000016 - 上证50指数
  6. 批量获取大量股票数据时(如500只成分股),建议分批处理或增加超时时间
  7. 数据仅供参考,不构成投资建议

Comments

Loading comments...