daily-stock-analysis
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseDaily Stock Analysis (股票智能分析系统)
每日股票分析(股票智能分析系统)
Skill by ara.so — Daily 2026 Skills collection.
LLM-powered stock analysis system for A-share, Hong Kong, and US markets. Automatically fetches quotes, news, and fundamentals, generates AI decision dashboards with buy/sell targets, and pushes results to WeChat/Feishu/Telegram/Discord/Email on a schedule via GitHub Actions — zero server cost.
由ara.so提供的Skill — 每日2026技能合集。
基于大语言模型(LLM)的A股、港股、美股分析系统,可自动获取行情、资讯及基本面数据,生成包含买卖目标价的AI决策仪表盘,并通过GitHub Actions定时推送结果至微信/飞书/Telegram/Discord/邮件等渠道 — 零服务器成本。
What It Does
功能特性
- AI Decision Dashboard: One-line conclusion + precise buy/sell/stop-loss prices + checklist per stock
- Multi-market: A-shares (CN), HK stocks, US stocks + indices (SPX, DJI, IXIC)
- Data sources: AkShare, Tushare, YFinance for quotes; Tavily/SerpAPI/Brave for news
- LLM backends: Gemini, OpenAI, Claude, DeepSeek, Qwen via LiteLLM (unified)
- Push channels: WeChat Work, Feishu, Telegram, Discord, DingTalk, Email, PushPlus
- Automation: GitHub Actions cron schedule, no server needed
- Web UI: Portfolio management, history, backtesting, Agent Q&A
- Agent: Multi-turn strategy Q&A with 11 built-in strategies (MA crossover, Elliott Wave, etc.)
- AI决策仪表盘:一句话核心结论 + 精准买卖/止损价格 + 单只股票检查清单
- 多市场支持:A股(中国)、港股、美股 + 指数(SPX、DJI、IXIC)
- 数据来源:行情数据来自AkShare、Tushare、YFinance;资讯数据来自Tavily/SerpAPI/Brave
- LLM后端:通过LiteLLM统一接入Gemini、OpenAI、Claude、DeepSeek、Qwen
- 推送渠道:企业微信、飞书、Telegram、Discord、钉钉、邮件、PushPlus
- 自动化运行:通过GitHub Actions定时任务执行,无需服务器
- Web界面:投资组合管理、历史记录、回测、Agent问答
- 智能Agent:支持11种内置策略的多轮策略问答(如均线金叉、艾略特波浪等)
Installation
安装部署
Method 1: GitHub Actions (Recommended, Zero Cost)
方法1:GitHub Actions(推荐,零成本)
Step 1: Fork the repository
https://github.com/ZhuLinsen/daily_stock_analysisStep 2: Configure Secrets ()
Settings → Secrets and variables → ActionsRequired — at least one LLM key:
GEMINI_API_KEY # Google AI Studio (free tier available)
OPENAI_API_KEY # OpenAI or compatible (DeepSeek, Qwen, etc.)
OPENAI_BASE_URL # e.g. https://api.deepseek.com/v1
OPENAI_MODEL # e.g. deepseek-chat, gpt-4o
AIHUBMIX_KEY # AIHubMix (recommended, covers Gemini+GPT+Claude+DeepSeek)
ANTHROPIC_API_KEY # ClaudeRequired — stock list:
STOCKS # e.g. 600519,300750,AAPL,TSLA,00700.HKRequired — at least one notification channel:
TELEGRAM_BOT_TOKEN
TELEGRAM_CHAT_ID
FEISHU_WEBHOOK_URL
WECHAT_WEBHOOK_URL
EMAIL_SENDER / EMAIL_PASSWORD / EMAIL_RECEIVERS
DISCORD_WEBHOOK_URLStep 3: Trigger manually or wait for cron
Go to
Actions → stock_analysis → Run workflow步骤1:复刻仓库
https://github.com/ZhuLinsen/daily_stock_analysis步骤2:配置密钥()
设置 → 密钥和变量 → Actions必填项 — 至少一个LLM密钥:
GEMINI_API_KEY # Google AI Studio(提供免费额度)
OPENAI_API_KEY # OpenAI或兼容平台(如DeepSeek、Qwen等)
OPENAI_BASE_URL # 示例:https://api.deepseek.com/v1
OPENAI_MODEL # 示例:deepseek-chat, gpt-4o
AIHUBMIX_KEY # AIHubMix(推荐,支持Gemini+GPT+Claude+DeepSeek)
ANTHROPIC_API_KEY # Claude必填项 — 股票列表:
STOCKS # 示例:600519,300750,AAPL,TSLA,00700.HK必填项 — 至少一个通知渠道:
TELEGRAM_BOT_TOKEN
TELEGRAM_CHAT_ID
FEISHU_WEBHOOK_URL
WECHAT_WEBHOOK_URL
EMAIL_SENDER / EMAIL_PASSWORD / EMAIL_RECEIVERS
DISCORD_WEBHOOK_URL步骤3:手动触发或等待定时任务
进入
Actions → stock_analysis → 运行工作流Method 2: Local / Docker
方法2:本地部署 / Docker
bash
git clone https://github.com/ZhuLinsen/daily_stock_analysis
cd daily_stock_analysis
cp .env.example .envbash
git clone https://github.com/ZhuLinsen/daily_stock_analysis
cd daily_stock_analysis
cp .env.example .envEdit .env with your keys
编辑.env文件,填入你的密钥
pip install -r requirements.txt
python main.py
**Docker:**
```bash
docker build -t stock-analysis .
docker run --env-file .env stock-analysisDocker Compose:
bash
docker-compose up -dpip install -r requirements.txt
python main.py
**Docker部署:**
```bash
docker build -t stock-analysis .
docker run --env-file .env stock-analysisDocker Compose部署:
bash
docker-compose up -dConfiguration
配置说明
.env
File (Local)
.env.env文件(本地部署)
env
undefinedenv
undefinedLLM - pick one or more
LLM - 选择一个或多个
GEMINI_API_KEY=your_gemini_key
OPENAI_API_KEY=your_openai_key
OPENAI_BASE_URL=https://api.deepseek.com/v1
OPENAI_MODEL=deepseek-chat
AIHUBMIX_KEY=your_aihubmix_key
GEMINI_API_KEY=your_gemini_key
OPENAI_API_KEY=your_openai_key
OPENAI_BASE_URL=https://api.deepseek.com/v1
OPENAI_MODEL=deepseek-chat
AIHUBMIX_KEY=your_aihubmix_key
Stock list (comma-separated)
股票列表(逗号分隔)
STOCKS=600519,300750,AAPL,TSLA,00700.HK
STOCKS=600519,300750,AAPL,TSLA,00700.HK
Notification
通知设置
TELEGRAM_BOT_TOKEN=your_bot_token
TELEGRAM_CHAT_ID=your_chat_id
TELEGRAM_BOT_TOKEN=your_bot_token
TELEGRAM_CHAT_ID=your_chat_id
Optional settings
可选设置
REPORT_TYPE=full # simple | full | brief
ANALYSIS_DELAY=10 # seconds between stocks (avoid rate limiting)
MAX_WORKERS=3 # concurrent analysis threads
SINGLE_STOCK_NOTIFY=false # push each stock immediately when done
NEWS_MAX_AGE_DAYS=3 # ignore news older than N days
undefinedREPORT_TYPE=full # simple | full | brief(简洁版 | 完整版 | 摘要版)
ANALYSIS_DELAY=10 # 单只股票分析间隔(秒,避免请求限制)
MAX_WORKERS=3 # 并发分析线程数
SINGLE_STOCK_NOTIFY=false # 单只股票分析完成后立即推送
NEWS_MAX_AGE_DAYS=3 # 忽略超过N天的旧资讯
undefinedMulti-Channel LLM (Advanced)
多渠道LLM配置(进阶)
env
LLM_CHANNELS=gemini,deepseek,claude
LLM_GEMINI_PROTOCOL=google
LLM_GEMINI_API_KEY=your_key
LLM_GEMINI_MODELS=gemini-2.0-flash,gemini-1.5-pro
LLM_GEMINI_ENABLED=true
LLM_DEEPSEEK_PROTOCOL=openai
LLM_DEEPSEEK_BASE_URL=https://api.deepseek.com/v1
LLM_DEEPSEEK_API_KEY=your_key
LLM_DEEPSEEK_MODELS=deepseek-chat
LLM_DEEPSEEK_ENABLED=trueenv
LLM_CHANNELS=gemini,deepseek,claude
LLM_GEMINI_PROTOCOL=google
LLM_GEMINI_API_KEY=your_key
LLM_GEMINI_MODELS=gemini-2.0-flash,gemini-1.5-pro
LLM_GEMINI_ENABLED=true
LLM_DEEPSEEK_PROTOCOL=openai
LLM_DEEPSEEK_BASE_URL=https://api.deepseek.com/v1
LLM_DEEPSEEK_API_KEY=your_key
LLM_DEEPSEEK_MODELS=deepseek-chat
LLM_DEEPSEEK_ENABLED=trueStock Grouping (Send Different Stocks to Different Emails)
股票分组推送(不同股票推送给不同邮箱)
env
STOCK_GROUP_1=600519,300750,000858
EMAIL_GROUP_1=investor1@example.com
STOCK_GROUP_2=AAPL,TSLA,NVDA
EMAIL_GROUP_2=investor2@example.comenv
STOCK_GROUP_1=600519,300750,000858
EMAIL_GROUP_1=investor1@example.com
STOCK_GROUP_2=AAPL,TSLA,NVDA
EMAIL_GROUP_2=investor2@example.comMarket Review Mode
市场复盘模式
env
MARKET_REVIEW=cn # cn | us | bothenv
MARKET_REVIEW=cn # cn | us | bothcn = A-share three-phase review strategy
cn = A股三阶段复盘策略
us = US Regime Strategy (risk-on/neutral/risk-off)
us = 美股Regime策略(风险偏好/中性/规避)
both = both markets
both = 同时复盘两个市场
undefinedundefinedKey Commands (CLI)
核心命令(CLI)
bash
undefinedbash
undefinedRun full analysis immediately
立即运行完整分析
python main.py
python main.py
Analyze specific stocks only
仅分析指定股票
STOCKS=600519,AAPL python main.py
STOCKS=600519,AAPL python main.py
Run web dashboard
启动Web仪表盘
python web_app.py
python web_app.py
Access at http://localhost:5000
Run with Docker (env file)
使用Docker运行(加载.env文件)
docker run --env-file .env stock-analysis python main.py
docker run --env-file .env stock-analysis python main.py
Run schedule mode (waits for cron, then runs)
启动定时模式(等待定时任务触发后运行)
SCHEDULE_RUN_IMMEDIATELY=true python main.py
undefinedSCHEDULE_RUN_IMMEDIATELY=true python main.py
undefinedGitHub Actions Workflow
GitHub Actions工作流
The workflow file runs on schedule:
.github/workflows/stock_analysis.ymlyaml
undefined工作流文件按计划运行:
.github/workflows/stock_analysis.ymlyaml
undefinedDefault schedule - customize in the workflow file
默认定时规则 - 在工作流文件中自定义
on:
schedule:
- cron: '30 1 * * 1-5' # 9:30 AM CST (UTC+8) weekdays
workflow_dispatch: # manual trigger
**To change schedule:** Edit `.github/workflows/stock_analysis.yml` cron expression.
**To add secrets via GitHub CLI:**
```bash
gh secret set GEMINI_API_KEY --body "$GEMINI_API_KEY"
gh secret set STOCKS --body "600519,300750,AAPL,TSLA"
gh secret set TELEGRAM_BOT_TOKEN --body "$TG_TOKEN"
gh secret set TELEGRAM_CHAT_ID --body "$TG_CHAT_ID"on:
schedule:
- cron: '30 1 * * 1-5' # 工作日上午9:30(UTC+8)
workflow_dispatch: # 手动触发
**修改定时规则:** 编辑`.github/workflows/stock_analysis.yml`中的cron表达式。
**通过GitHub CLI添加密钥:**
```bash
gh secret set GEMINI_API_KEY --body "$GEMINI_API_KEY"
gh secret set STOCKS --body "600519,300750,AAPL,TSLA"
gh secret set TELEGRAM_BOT_TOKEN --body "$TG_TOKEN"
gh secret set TELEGRAM_CHAT_ID --body "$TG_CHAT_ID"Code Examples
代码示例
Programmatic Analysis (Python)
程序化分析(Python)
python
undefinedpython
undefinedRun analysis for specific stocks programmatically
程序化分析指定股票
import asyncio
from analyzer import StockAnalyzer
async def analyze():
analyzer = StockAnalyzer()
# Analyze a single A-share stock
result = await analyzer.analyze_stock("600519") # Moutai
print(result['conclusion'])
print(result['buy_price'])
print(result['stop_loss'])
print(result['target_price'])asyncio.run(analyze())
undefinedimport asyncio
from analyzer import StockAnalyzer
async def analyze():
analyzer = StockAnalyzer()
# 分析单只A股股票
result = await analyzer.analyze_stock("600519") # 贵州茅台
print(result['conclusion'])
print(result['buy_price'])
print(result['stop_loss'])
print(result['target_price'])asyncio.run(analyze())
undefinedCustom Notification Integration
自定义通知集成
python
from notifier import NotificationManager
notifier = NotificationManager()python
from notifier import NotificationManager
notifier = NotificationManager()Send to Telegram
发送至Telegram
await notifier.send_telegram(
token=os.environ['TELEGRAM_BOT_TOKEN'],
chat_id=os.environ['TELEGRAM_CHAT_ID'],
message="📈 Analysis complete\n600519: BUY at 1680, SL: 1620, TP: 1800"
)
await notifier.send_telegram(
token=os.environ['TELEGRAM_BOT_TOKEN'],
chat_id=os.environ['TELEGRAM_CHAT_ID'],
message="📈 分析完成\n600519:建议在1680买入,止损1620,止盈1800"
)
Send to Feishu webhook
发送至飞书Webhook
await notifier.send_feishu(
webhook_url=os.environ['FEISHU_WEBHOOK_URL'],
content=analysis_report
)
undefinedawait notifier.send_feishu(
webhook_url=os.environ['FEISHU_WEBHOOK_URL'],
content=analysis_report
)
undefinedUsing the Agent API
使用Agent API
python
import requestspython
import requestsAsk the stock agent a strategy question
向股票Agent提问策略问题
response = requests.post('http://localhost:5000/api/agent/chat', json={
"message": "600519现在适合买入吗?用均线金叉策略分析",
"stock_code": "600519",
"strategy": "ma_crossover" # ma_crossover, elliott_wave, chan_theory, etc.
})
print(response.json()['reply'])
undefinedresponse = requests.post('http://localhost:5000/api/agent/chat', json={
"message": "600519现在适合买入吗?用均线金叉策略分析",
"stock_code": "600519",
"strategy": "ma_crossover" # ma_crossover, elliott_wave, chan_theory等
})
print(response.json()['reply'])
undefinedBacktest Analysis Accuracy
回测分析准确率
python
import requestspython
import requestsTrigger backtest for a stock
触发单只股票回测
response = requests.post('http://localhost:5000/api/backtest', json={
"stock_code": "600519",
"days": 30 # evaluate last 30 days of AI predictions
})
result = response.json()
print(f"Direction accuracy: {result['direction_accuracy']}%")
print(f"Take-profit hit rate: {result['tp_hit_rate']}%")
print(f"Stop-loss hit rate: {result['sl_hit_rate']}%")
undefinedresponse = requests.post('http://localhost:5000/api/backtest', json={
"stock_code": "600519",
"days": 30 # 评估过去30天的AI预测结果
})
result = response.json()
print(f"方向准确率:{result['direction_accuracy']}%")
print(f"止盈命中率:{result['tp_hit_rate']}%")
print(f"止损命中率:{result['sl_hit_rate']}%")
undefinedImport Stocks from Image (Vision LLM)
从图片导入股票(视觉LLM)
python
import requestspython
import requestsUpload screenshot of stock list for AI extraction
上传股票列表截图,由AI提取股票信息
with open('watchlist_screenshot.png', 'rb') as f:
response = requests.post(
'http://localhost:5000/api/stocks/import/image',
files={'image': f}
)
stocks = response.json()['extracted_stocks']
with open('watchlist_screenshot.png', 'rb') as f:
response = requests.post(
'http://localhost:5000/api/stocks/import/image',
files={'image': f}
)
stocks = response.json()['extracted_stocks']
Returns: [{"code": "600519", "name": "贵州茅台", "confidence": 0.98}, ...]
返回结果:[{"code": "600519", "name": "贵州茅台", "confidence": 0.98}, ...]
undefinedundefinedWeb Dashboard Features
Web仪表盘功能
Start the web app:
bash
python web_app.py| Route | Feature |
|---|---|
| Today's analysis dashboard |
| Holdings management, P&L tracking |
| Past analysis reports (bulk delete supported) |
| AI prediction accuracy backtest |
| Multi-turn strategy Q&A |
| LLM channels, notification config |
| Import stocks from image/CSV/clipboard |
启动Web应用:
bash
python web_app.py| 路由 | 功能 |
|---|---|
| 今日分析仪表盘 |
| 持仓管理、盈亏追踪 |
| 历史分析报告(支持批量删除) |
| AI预测准确率回测 |
| 多轮策略问答 |
| LLM渠道、通知配置 |
| 从图片/CSV/剪贴板导入股票 |
Supported Stock Formats
支持的股票格式
undefinedundefinedA-shares (6-digit code)
A股(6位代码)
600519 # 贵州茅台
300750 # 宁德时代
000858 # 五粮液
600519 # 贵州茅台
300750 # 宁德时代
000858 # 五粮液
HK stocks (5-digit + .HK)
港股(5位代码 + .HK)
00700.HK # 腾讯控股
09988.HK # 阿里巴巴
00700.HK # 腾讯控股
09988.HK # 阿里巴巴
US stocks (ticker)
美股(交易代码)
AAPL
TSLA
NVDA
AAPL
TSLA
NVDA
US indices
美股指数
SPX # S&P 500
DJI # Dow Jones
IXIC # NASDAQ
undefinedSPX # 标普500
DJI # 道琼斯
IXIC # 纳斯达克
undefinedBuilt-in Trading Rules
内置交易规则
| Rule | Config |
|---|---|
| No chasing highs | |
| Trend trading | MA5 > MA10 > MA20 bullish alignment required |
| Precise targets | Buy price, stop-loss, take-profit per stock |
| News freshness | |
| Checklist | Each condition marked: ✅ Satisfied / ⚠️ Caution / ❌ Not Met |
| 规则 | 配置项 |
|---|---|
| 不追高 | |
| 趋势交易 | 需满足MA5 > MA10 > MA20多头排列 |
| 精准目标 | 单只股票对应买入价、止损价、止盈价 |
| 资讯新鲜度 | |
| 检查清单 | 每个条件标记:✅ 满足 / ⚠️ 注意 / ❌ 不满足 |
Troubleshooting
常见问题排查
Analysis runs but no push received:
bash
undefined分析运行但未收到推送:
bash
undefinedCheck notification config
检查通知配置
python -c "from notifier import test_all_channels; test_all_channels()"
python -c "from notifier import test_all_channels; test_all_channels()"
Verify secrets are set (GitHub Actions)
验证GitHub Actions中的密钥是否设置
gh secret list
**LLM API errors / rate limiting:**
```env
ANALYSIS_DELAY=15 # increase delay between stocks
MAX_WORKERS=1 # reduce concurrency
LITELLM_FALLBACK_MODELS=gemini-1.5-flash,deepseek-chat # add fallbacksAkShare data fetch fails (A-shares):
bash
pip install akshare --upgradegh secret list
**LLM API错误 / 请求限制:**
```env
ANALYSIS_DELAY=15 # 增加单只股票分析间隔
MAX_WORKERS=1 # 减少并发数
LITELLM_FALLBACK_MODELS=gemini-1.5-flash,deepseek-chat # 添加备用模型AkShare行情数据获取失败(A股):
bash
pip install akshare --upgradeA-share data requires Chinese network or proxy
A股数据需要中国网络环境或代理
**YFinance US stock data issues:**
```bash
pip install yfinance --upgrade
**YFinance美股数据问题:**
```bash
pip install yfinance --upgradeUS stocks use YFinance exclusively for consistency
美股数据统一使用YFinance
**GitHub Actions not triggering:**
- Check Actions are enabled: `Settings → Actions → General → Allow all actions`
- Verify cron syntax at [crontab.guru](https://crontab.guru)
- Check workflow file exists: `.github/workflows/stock_analysis.yml`
**Web auth issues (admin password):**
```env
**GitHub Actions未触发:**
- 检查Actions是否启用:`设置 → Actions → 通用 → 允许所有Actions`
- 在[crontab.guru](https://crontab.guru)验证cron语法
- 确认工作流文件存在:`.github/workflows/stock_analysis.yml`
**Web界面权限问题(管理员密码):**
```envIf auth was disabled and re-enabled, current password required
如果曾关闭权限后重新启用,需输入当前密码
Reset via environment variable
通过环境变量重置密码
WEB_ADMIN_PASSWORD=new_password
**Multi-worker deployment auth state:**
```bashWEB_ADMIN_PASSWORD=new_password
**多Worker部署时权限状态不同步:**
```bashAuth toggle only applies to current process
权限切换仅对当前进程生效
Must restart all workers to sync state
需重启所有Worker以同步状态
docker-compose restart
undefineddocker-compose restart
undefinedReport Types
报告类型
env
REPORT_TYPE=simple # Concise: conclusion + key prices only
REPORT_TYPE=full # Complete: all technical + fundamental + news analysis
REPORT_TYPE=brief # 3-5 sentence summaryFull report includes:
- 一句话核心结论 (one-line core conclusion)
- 技术面分析 (technical: MA alignment, chip distribution)
- 基本面 (valuation, growth, earnings, institutional holdings)
- 舆情情报 (news sentiment, social media — US stocks)
- 精确买卖点位 (precise entry/exit levels)
- 操作检查清单 (action checklist)
- 板块涨跌榜 (sector performance boards)
env
REPORT_TYPE=simple # 简洁版:仅包含结论 + 核心价格
REPORT_TYPE=full # 完整版:包含技术面+基本面+资讯分析
REPORT_TYPE=brief # 摘要版:3-5句话总结完整版报告包含:
- 一句话核心结论
- 技术面分析(均线排列、筹码分布)
- 基本面(估值、成长性、盈利、机构持仓)
- 舆情情报(资讯情绪、社交媒体热度 — 美股)
- 精确买卖点位
- 操作检查清单
- 板块涨跌榜
LLM Priority Order
LLM优先级顺序
Gemini → Anthropic → OpenAI/AIHubMix/CompatibleAIHubMix is recommended for single-key access to all major models without VPN:
env
AIHUBMIX_KEY=$AIHUBMIX_KEY # covers Gemini, GPT, Claude, DeepSeekGemini → Anthropic → OpenAI/AIHubMix/兼容平台AIHubMix是推荐选项,无需VPN即可通过单个密钥访问所有主流模型:
env
AIHUBMIX_KEY=$AIHUBMIX_KEY # 支持Gemini、GPT、Claude、DeepSeekNo OPENAI_BASE_URL needed — auto-configured
无需设置OPENAI_BASE_URL — 自动配置
undefinedundefined