astock-cache
Skill26 starsChanged 5 months agoMITView on GitHub
磁盘缓存 + K线 parquet。当用户跑全市场筛选每次都要等 30 分钟时,Claude 应使用此 Skill。K线缓存到 ~/.astock_skills/cache/kline/ 目录,5 秒 vs 30 分钟,差 360 倍。
In this repository10 other files it gives its agents.
- start-hereSkill
- astock-data-sourceSkill
- astock-utilsSkill
- trade-journalSkill
- watchlist-monitorSkill
- stock-technical-analysisSkill
- trade-reviewSkill
- screenerSkill
- reportSkill
- alerterSkill
The file
Files
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 引擎Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

