Astock cache
📈 Claude Agent Skills for A股分析 | 29个即插即用 Skills 覆盖数据采集/大盘分析/资金流向/涨停追踪/技术面/基本面/估值/财报/多因子/回测/风控/智能报告 | 含自选股监控 | akshare+tushare+东财 | Claude Code 首选搭档
npx -y skills add ZICXR/A-Stock-Skills --skill astock-cacheAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 15 stars15 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its author says it does
Copied from the file, not written here
磁盘缓存 + K线 parquet。当用户跑全市场筛选每次都要等 30 分钟时,Claude 应使用此 Skill。K线缓存到 ~/.astock_skills/cache/kline/ 目录,5 秒 vs 30 分钟,差 360 倍。
SKILL.md
1.7 KB, as published. Nobody here has run it
astock-cache
何时使用
- 全市场筛选太慢 (每次 30 分钟)
- 反复拉同一只股票 K 线
- 跑 screener 跑 2 遍
- 想要"盘后更新一次,白天用一天"
🚀 快速上手
# 看缓存多少了
python main.py kline-stats
# 跑一次全市场 K 线更新 (15-30 分钟, 但之后都是 5 秒)
python daily_update.py
# 单独看某只股票
python main.py kline-stats
# {"count": 5028, "size_mb": 18.4}
提供能力
通用 Key-Value 缓存
cache_set/get/delete/clearcached(key, ttl)装饰器- 存储:
~/.astock_skills/cache/*.pkl
K 线 parquet 缓存 (新,推荐)
kline_save(code, df, days)存 parquetkline_load(code, days, max_age_hours)读kline_get_or_fetch(code, fetch_fn, days)智能模式- 存储:
~/.astock_skills/cache/kline/{code}_{days}d.parquet
screener 集成示例
from skills.01-infra.astock-cache.main import kline_get_or_fetch
from skills.01-infra.astock-data-source.main import get_kline
def smart_kline(code, days=60):
"""优先读缓存, 缓存没有才拉网络"""
return kline_get_or_fetch(code, get_kline, days=days)
# 第一次慢 (拉网络), 之后 5 秒
df = smart_kline("601991", 60)
性能
| 场景 | 无缓存 | 有缓存 | 加速比 |
|---|---|---|---|
| 单股 60 日 K 线 | 1.2s | 0.05s | 24x |
| 全市场 5028 只 60 日 | 30min | 5s | 360x |
依赖
pandas>=1.5.0
pyarrow>=10.0.0 # parquet 引擎