使用 Tushare 获取实时财务数据,结合百度搜索和全局大模型进行深度分析。
bash
python3 scripts/analyze_stock.py --stock 601117
python3 scripts/analyze_stock.py --stock 601117 --style balanced
python
ctx.claw.skills.run("stock-analysis", {
"stock_code": "601117",
"style": "balanced" # conservative/balanced/aggressive
})
参数类型必填说明stock_codestr✅股票代码(6 位数字)stylestr❌投资风格(conservative/balanced/aggressive)
json
{
"stock": "601117",
"name": "中国化学",
"report": "完整分析报告",
"analysis": "大模型分析的利好与风险因素",
"model": "阿里云 Coding Plan(全局自动调用)"
}
复制 .env.example 为 .env 并填入你的 API key:
bash
cd ~/.openclaw/workspace/skills/stock-analysis
cp .env.example .env
# 编辑 .env 文件,填入真实的 API key
在 ~/.openclaw/openclaw.json 中配置:
json
{
"skills": {
"entries": {
"stock-analysis": {
"env": {
"TUSHARE_TOKEN": "your_tushare_token",
"BAIDU_API_KEY": "your_baidu_api_key",
"TAVILY_API_KEY": "your_tavily_api_key"
}
}
}
}
}
API用途获取方式必需TUSHARE_TOKEN获取财务数据https://tushare.pro (免费注册)✅BAIDU_API_KEY百度搜索新闻百度智能云控制台❌ 可选TAVILY_API_KEY深度分析https://tavily.com❌ 可选
json
{
"stock_code": "601117",
"style": "balanced"
}
json
{
"stock": "601117",
"name": "中国化学",
"report": "# 📈 中国化学 (601117) 分析报告\n\n...",
"analysis": "利好因素:\n1. 行业地位领先...\n风险因素:\n1. 行业竞争加剧...",
"model": "阿里云 Coding Plan(全局自动调用)"
}