AI-powered stock analysis system for A-shares / Hong Kong / US stocks
Analyze your watchlist daily → generate a decision dashboard → push to multiple channels (Telegram/Discord/Slack/Email/WeChat Work/Feishu)
Zero-cost deployment · Runs on GitHub Actions · No server required
Quick Start · Key Features · Sample Output · Full Guide · FAQ · Contributing · All Docs
| Module | Feature | Description |
|---|---|---|
| AI | Decision Dashboard | One-sentence conclusion + precise entry/exit levels + action checklist |
| Analysis | Multi-dimensional Analysis | Technicals + chip distribution + sentiment + real-time quotes |
| Market | Global Markets | A-shares, Hong Kong stocks, US stocks |
| Search | Smart Autocomplete (MVP) | [Beta] Home search supports code/name/pinyin/aliases; the local index now covers A-shares, Hong Kong, and US stocks and can be refreshed from Tushare or AkShare data |
| Review | Market Review | Daily overview, sectors, northbound capital flow |
| Intel | Announcement + Capital Flow Intelligence | IntelAgent now also pulls listed-company announcements (SSE/SZSE/CNINFO) and A-share main-force capital flow, and exposes capital_flow_signal (inflow/outflow/neutral/not_available) for flow direction context |
| Backtest | AI Backtest Validation | Auto-evaluate historical analysis accuracy, with a 1-day next-session validation view for AI prediction vs actual move and accuracy |
| Agent Q&A | Strategy Chat | Multi-turn strategy chat with 11 built-in trading strategies (internally loaded as skills) (Web/Bot/API) |
| Notifications | Multi-channel Push | Telegram, Discord, Slack, Email, WeChat Work, Feishu, etc. |
| Automation | Scheduled Runs | GitHub Actions scheduled execution, no server required |
The Backtest page now includes a 1-day next-session validation view. You can filter by stock code and analysis date range to compare the original AI prediction with the next trading day close and inspect the filtered accuracy rate. This is based on historical analysis plus
eval_window_days=1backtest data, not real trade execution logs.
| Type | Supported |
|---|---|
| LLMs | Gemini (free), OpenAI-compatible, DeepSeek, Qwen, Claude, Ollama |
| Market Data | AkShare, Tushare, Pytdx, Baostock, YFinance, Longbridge (primary for US/HK when configured) |
| News Search | Tavily, Anspire、SerpAPI, Bocha, Brave, MiniMax |
Longbridge-first (US/HK only): With
LONGBRIDGE_APP_KEY/LONGBRIDGE_APP_SECRET/LONGBRIDGE_ACCESS_TOKENset, daily bars and realtime quotes for US & HK stocks are fetched from Longbridge first; YFinance / AkShare are used for fallback or field merge when Longbridge fails or returns incomplete fields. If Longbridge is not configured, it is not called — US/HK still use YFinance / AkShare as before. US market indices (e.g. SPX) always prefer YFinance (indices are not supported on Longbridge). A-share routing is unchanged. See.env.exampleand the full guide.
| Rule | Description |
|---|---|
| No chasing highs | Auto warn when deviation > 5% |
| Trend trading | Bull alignment: MA5 > MA10 > MA20 |
| Precise levels | Entry, stop loss, target |
| Checklist | Each condition marked as Pass / Watch / Fail |
No server needed, runs automatically every day!
Click the Fork button in the upper right corner
Go to your forked repo → Settings → Secrets and variables → Actions → New repository secret
AI Model Configuration (Choose one)
For detailed configuration, see LLM Config Guide. The default path is: pick a provider, add the API key, then optionally pin a primary model. Use channels only when you need multi-provider routing or fallbacks; advanced YAML routing is optional for expert setups.
| Secret Name | Description | Required |
|---|---|---|
GEMINI_API_KEY |
Get free API key from Google AI Studio | ✅* |
OPENAI_API_KEY |
OpenAI-compatible API Key (supports DeepSeek, Qwen, etc.) | Optional |
OPENAI_BASE_URL |
OpenAI-compatible API endpoint (e.g., https://api.deepseek.com/v1) |
Optional |
OPENAI_MODEL |
Model name (e.g., deepseek-chat) |
Optional |
OLLAMA_API_BASE |
Ollama local service address (e.g. http://localhost:11434), for local/Docker deployment; do not use OPENAI_BASE_URL for Ollama, see LLM Config Guide - Ollama |
Optional |
*Note: Configure at least one of
GEMINI_API_KEY,OPENAI_API_KEY, orOLLAMA_API_BASE(local). Ollama requiresOLLAMA_API_BASE; usingOPENAI_BASE_URLcauses 404.
Notification channels (expand, choose at least one)
| Secret Name | Description | Required |
|---|---|---|
TELEGRAM_BOT_TOKEN |
Telegram Bot Token (Get from @BotFather) | Optional |
TELEGRAM_CHAT_ID |
Telegram Chat ID | Optional |
TELEGRAM_MESSAGE_THREAD_ID |
Telegram Topic ID (For sending to topics) | Optional |
DISCORD_WEBHOOK_URL |
Discord Webhook URL | Optional |
DISCORD_BOT_TOKEN |
Discord Bot Token (choose one with Webhook) | Optional |
DISCORD_MAIN_CHANNEL_ID |
Discord Channel ID (required when using Bot) | Optional |
DISCORD_INTERACTIONS_PUBLIC_KEY |
Discord Public Key (required only for inbound Interaction/Webhook signature verification) | Optional |
SLACK_BOT_TOKEN |
Slack Bot Token (recommended, supports image upload; takes priority over Webhook when both set) | Optional |
SLACK_CHANNEL_ID |
Slack Channel ID (required when using Bot) | Optional |
SLACK_WEBHOOK_URL |
Slack Incoming Webhook URL (text only, no image support) | Optional |
EMAIL_SENDER |
Sender email (e.g., xxx@qq.com) |
Optional |
EMAIL_PASSWORD |
Email authorization code (not login password) | Optional |
EMAIL_RECEIVERS |
Receiver emails (comma-separated, leave empty to send to yourself) | Optional |
WECHAT_WEBHOOK_URL |
WeChat Work Webhook URL | Optional |
FEISHU_WEBHOOK_URL |
Feishu Webhook URL | Optional |
PUSHPLUS_TOKEN |
PushPlus Token (Get it here, Chinese push service) | Optional |
SERVERCHAN3_SENDKEY |
ServerChan v3 SendKey ((Get it here, Mobile app push notification service) ) | Optional |
CUSTOM_WEBHOOK_URLS |
Custom Webhook URLs (supports DingTalk, etc., comma-separated) | Optional |
CUSTOM_WEBHOOK_BEARER_TOKEN |
Bearer token for custom webhooks (if required) | Optional |
SINGLE_STOCK_NOTIFY |
Send notification immediately after each stock | Optional |
REPORT_TYPE |
simple, full, or brief (Docker recommended: full) |
Optional |
REPORT_LANGUAGE |
Report output language: zh (default Chinese) / en (English); affects prompt instructions, Markdown templates, notification fallbacks, and fixed labels in the Web report view. The bundled daily_analysis.yml already maps this variable, so setting it in Actions Secrets/Variables works out of the box |
Optional |
ANALYSIS_DELAY |
Delay between stocks and market review (seconds) | Optional |
Note: Configure at least one channel; multiple channels will all receive notifications.
Stock List Configuration
| Secret Name | Description | Required |
|---|---|---|
STOCK_LIST |
Watchlist codes, e.g., 600519,AAPL,hk00700 |
✅ |
TAVILY_API_KEYS |
Tavily Search API (for news) | Recommended |
ANSPIRE_API_KEYS |
Anspire AI Search Specially optimized for Chinese content (effectively enhances A-share analysis) | Optional |
MINIMAX_API_KEYS |
MiniMax Coding Plan Web Search (structured search results) | Optional |
BRAVE_API_KEYS |
Brave Search API (privacy-focused, US stocks optimized) | Optional |
SERPAPI_API_KEYS |
SerpAPI Backup search | Optional |
BOCHA_API_KEYS |
Bocha Search Web Search API (Chinese search optimized, supports AI summaries, multiple keys comma-separated) | Optional |
SEARXNG_BASE_URLS |
SearXNG self-hosted instances (quota-free fallback, enable format: json in settings.yml); when empty the app auto-discovers public instances | Optional |
SEARXNG_PUBLIC_INSTANCES_ENABLED |
Auto-discover public SearXNG instances from searx.space when SEARXNG_BASE_URLS is empty (default true) |
Optional |
TUSHARE_TOKEN |
Tushare Pro Token | Optional |
TICKFLOW_API_KEY |
TickFlow API key (CN market review index enhancement; breadth also uses TickFlow when the plan supports universe queries) | Optional |
LONGBRIDGE_APP_KEY |
Longbridge OpenAPI App Key (becomes primary US/HK data source when configured) | Optional |
LONGBRIDGE_APP_SECRET |
Longbridge App Secret | Optional |
LONGBRIDGE_ACCESS_TOKEN |
Longbridge Access Token | Optional |
LONGBRIDGE_STATIC_INFO_TTL_SECONDS |
In-process static_info cache TTL in seconds (default 86400; 0 = no cache) |
Optional |
LONGBRIDGE_HTTP_URL |
HTTP API base URL (default https://openapi.longbridge.com) |
Optional |
LONGBRIDGE_QUOTE_WS_URL |
Quote WebSocket URL (default wss://openapi-quote.longbridge.com/v2) |
Optional |
LONGBRIDGE_TRADE_WS_URL |
Trade WebSocket URL (default wss://openapi-trade.longbridge.com/v2) |
Optional |
LONGBRIDGE_REGION |
Override region endpoint; the SDK auto-selects by network (default hk); set if wrong (e.g. cn, hk) |
Optional |
LONGBRIDGE_ENABLE_OVERNIGHT |
Overnight session quotes: true / false (default false) |
Optional |
LONGBRIDGE_PUSH_CANDLESTICK_MODE |
Candlestick push mode: realtime or confirmed (default realtime) |
Optional |
LONGBRIDGE_PRINT_QUOTE_PACKAGES |
Whether to print quote packages on connect (default false when unset; set 1/true/yes to enable) |
Optional |
WECHAT_MSG_TYPE |
WeChat Work message type, default markdown, set to text for plain markdown text |
Optional |
AGENT_MODE |
Enable Agent strategy chat mode (internally normalized as skill, true/false, default false) |
Optional |
AGENT_LITELLM_MODEL |
Optional Agent-only primary model; when empty it inherits the primary model, and bare names are normalized to openai/<model> |
Optional |
AGENT_MAX_STEPS |
Max reasoning-step limit for Agent mode (default 10); at the default each sub-agent keeps its own preset, when raised above the default all sub-agents adopt this value, and when lowered below a sub-agent's preset that sub-agent is capped at this value |
Optional |
AGENT_SKILLS |
Comma-separated active strategy-skill ids. Leave empty to use the primary default strategy skill declared in metadata (built-in default: bull_trend); use all to activate every loaded strategy skill. |
Optional |
AGENT_SKILL_DIR |
Custom strategy-skill directory (default built-in strategies/ compatibility path) |
Optional |
Stock Code Format
| Market | Format | Examples |
|---|---|---|
| A-shares | 6-digit number | 600519, 000001, 300750 |
| BSE (Beijing) | 8/4/92 prefix, 6-digit | 920748, 838163, 430047 |
| HK Stocks | hk + 5-digit number | hk00700, hk09988 |
| US Stocks | 1-5 uppercase letters | AAPL, TSLA, GOOGL |
Go to Actions tab → Click I understand my workflows, go ahead and enable them
Actions → Daily Stock Analysis → Run workflow → Select mode → Run workflow
The system will:
- Run automatically at scheduled time (default: 18:00 Beijing Time)
- Send analysis reports to all configured channels
- Save reports locally
Resume fetch and
--dry-rundata-existence checks now resolve the "latest reusable trading day" from each market's local timezone and trading calendar. Weekends and holidays reuse the most recent trading day, intraday runs reuse the last completed trading day, and after market close the run skips only if the current trading day's data is already stored. See Full Guide for the exact rules.
git clone https://github.com/ZhuLinsen/daily_stock_analysis.git
cd daily_stock_analysis# Create virtual environment (recommended)
python3 -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt# Copy configuration template
cp .env.example .env
# Edit .env file
nano .env # or use any editorConfigure the following:
# AI Model (Choose one)
GEMINI_API_KEY=your_gemini_api_key_here
# Stock Watchlist (Mixed markets supported)
STOCK_LIST=600519,AAPL,hk00700
# Notification Channel (Choose at least one)
TELEGRAM_BOT_TOKEN=your_bot_token
TELEGRAM_CHAT_ID=your_chat_id
# News Search (Optional)
TAVILY_API_KEYS=your_tavily_key# One-time analysis
python main.py
# Scheduled mode (runs daily at 18:00)
python main.py --schedule
# Analyze specific stocks
python main.py --stocks AAPL,TSLA,GOOGL
# Market review only
python main.py --market-review| Endpoint | Method | Description |
|---|---|---|
/ |
GET | Configuration page |
/health |
GET | Health check |
/analysis?code=xxx |
GET | Trigger async analysis for a single stock |
/analysis/history |
GET | Query analysis history records |
/tasks |
GET | Query all task statuses |
/task?id=xxx |
GET | Query a single task status |
- Talk to @BotFather →
/newbot→ get Bot Token - Get Chat ID: send a message to @userinfobot
- Configure:
TELEGRAM_BOT_TOKEN=123456789:ABCdefGHIjklMNOpqrsTUVwxyz
TELEGRAM_CHAT_ID=123456789Webhook:
DISCORD_WEBHOOK_URL=https://discord.com/api/webhooks/xxx/yyyBot:
DISCORD_BOT_TOKEN=your_bot_token
DISCORD_MAIN_CHANNEL_ID=your_channel_idBot (recommended, supports image upload; takes priority when both set):
SLACK_BOT_TOKEN=xoxb-...
SLACK_CHANNEL_ID=C01234567Webhook (text only):
SLACK_WEBHOOK_URL=https://hooks.slack.com/services/T.../B.../xxxEMAIL_SENDER=your_email@gmail.com
EMAIL_PASSWORD=your_app_password
EMAIL_RECEIVERS=receiver@example.com # OptionalWeChat Work:
WECHAT_WEBHOOK_URL=https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=xxxFeishu:
FEISHU_WEBHOOK_URL=https://open.feishu.cn/open-apis/bot/v2/hook/xxxPUSHPLUS_TOKEN=your_token_here# 🎯 2026-01-24 Decision Dashboard
> Total **3** stocks analyzed | 🟢Buy:1 🟡Hold:1 🔴Sell:1
## 📊 Analysis Summary
🟢 **AAPL(Apple Inc.)**: Buy | Score 85 | Strong Bullish
🟡 **600519(Kweichow Moutai)**: Hold | Score 65 | Bullish
🔴 **TSLA(Tesla)**: Sell | Score 35 | Bearish
---
## 🟢 AAPL (Apple Inc.)
### 📰 Key Information
**💭 Sentiment**: Positive news on iPhone 16 sales
**📊 Earnings**: Q1 2024 earnings beat expectations
### 📌 Core Conclusion
**🟢 Buy** | Strong Bullish
> **One-sentence Decision**: Strong technical setup with positive catalyst, ideal entry point
⏰ **Time Sensitivity**: Within this week
| Position | Action |
|----------|--------|
| 🆕 **No Position** | Buy at pullback |
| 💼 **With Position** | Continue holding |
### 📊 Data Perspective
**MA Alignment**: MA5>MA10>MA20 | Bull Trend: ✅ Yes | Trend Strength: 85/100
| Price Metrics | Value |
|--------------|-------|
| Current | $185.50 |
| MA5 | $183.20 |
| MA10 | $180.50 |
| MA20 | $177.80 |
| Bias (MA5) | +1.26% ✅ Safe |
| Support | $183.20 |
| Resistance | $190.00 |
**Volume**: Ratio 1.8 (Moderate increase) | Turnover 2.3%
💡 *Volume confirms bullish momentum*
### 🎯 Action Plan
**📍 Sniper Points**
| Level Type | Price |
|-----------|-------|
| 🎯 Ideal Entry | $183-184 |
| 🔵 Secondary Entry | $180-181 |
| 🛑 Stop Loss | $177 |
| 🎊 Target | $195 |
**💰 Position Sizing**: 20-30% of portfolio
- Entry Plan: Enter in 2-3 batches
- Risk Control: Strict stop loss at $177
**✅ Checklist**
- ✅ Bull trend confirmed
- ✅ Price near MA5 support
- ✅ Volume confirms trend
- ⚠️ Monitor market volatility
---# === Analysis Behavior ===
ANALYSIS_DELAY=10 # Delay between analysis (seconds) to avoid API rate limit
REPORT_TYPE=full # Report type: simple/full
SINGLE_STOCK_NOTIFY=true # Push immediately after each stock analysis
# === Schedule ===
SCHEDULE_ENABLED=true # Enable scheduled task
SCHEDULE_TIME=18:00 # Daily run time (HH:MM, 24-hour format)
MARKET_REVIEW_ENABLED=true # Enable market review
# === Data Source ===
TUSHARE_TOKEN=your_token # Tushare Pro (priority data source if configured)
# === System ===
MAX_WORKERS=3 # Concurrent threads (3 recommended to avoid blocking)
DEBUG=false # Enable debug loggingEnable the FastAPI service for configuration management and triggering analysis when running locally.
| Command | Description |
|---|---|
python main.py --serve |
Start API service + run full analysis once |
python main.py --serve-only |
Start API service only, manually trigger analysis |
- URL:
http://127.0.0.1:8000 - API docs:
http://127.0.0.1:8000/docs
- 📝 Configuration Management - View/modify watchlist
- 🚀 Quick Analysis - Trigger analysis via API
- 📊 Real-time Progress - Analysis task status updates in real-time, supports parallel tasks
- 🤖 Agent Strategy Chat - Use
/ask,/chat,/history,/strategies, and/researchfor multi-turn Q&A, history, strategy listing, and deep research (enable withAGENT_MODE=true) - 🧩 Intel compatibility -
capital_flow_signalis an additive Intel output field; clients that do not consume it can ignore it safely, while existing fields such asrisk_alertsandpositive_catalystsremain unchanged. - 📈 Backtest Validation - Evaluate historical analysis accuracy, query direction win rate and simulated returns
| Endpoint | Method | Description |
|---|---|---|
/api/v1/analysis/analyze |
POST | Trigger stock analysis |
/api/v1/analysis/tasks |
GET | Query task list |
/api/v1/analysis/status/{task_id} |
GET | Query task status |
/api/v1/history |
GET | Query analysis history |
/api/v1/backtest/run |
POST | Trigger backtest |
/api/v1/backtest/results |
GET | Query backtest results (paginated) |
/api/v1/backtest/performance |
GET | Get overall backtest performance |
/api/v1/backtest/performance/{code} |
GET | Get per-stock backtest performance |
/api/v1/agent/skills |
GET | Get available built-in/custom strategy skills |
/api/v1/agent/chat/stream |
POST (SSE) | Stream multi-turn Agent strategy chat |
/api/health |
GET | Health check |
Note:
POST /api/v1/analysis/analyzesupports only one stock whenasync_mode=false; batchstock_codesrequiresasync_mode=true. The async202response returns a singletask_idfor one stock, or anaccepted/duplicatessummary for batch requests.
For detailed instructions, see Full Guide - API Service
The home analysis input now behaves more like a search box, reducing the need to memorize exact symbols.
- Multi-signal matching: supports stock code, company name, pinyin abbreviation, and aliases (for example
gzmt-> 贵州茅台,tencent-> 腾讯控股,aapl-> Apple Inc.). - Multi-market coverage: the local index now covers A-shares, Hong Kong stocks, and US stocks. It can be regenerated from either Tushare or AkShare source data when needed.
- Graceful fallback:
- If the index is outdated, missing a newly listed symbol, or fails to load, the UI falls back to plain manual input without blocking analysis.
- If no suggestion matches, pressing Enter still submits the original input directly.
Tip: to refresh the index, run
python3 scripts/fetch_tushare_stock_list.pyto update the stock-list CSV files, then runpython3 scripts/generate_index_from_csv.pyto rebuild the static index.
- Complete Configuration Guide
- FAQ
- Deployment Guide
- Bot Command Reference
- Feishu Bot Setup
- DingTalk Bot Setup
| Alipay | WeChat Pay | Xiaohongshu |
|---|---|---|
![]() |
![]() |
![]() |
Contributions are welcome! Please:
- Fork this repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
See CONTRIBUTING.md for details.
This project is licensed under the MIT License - see the LICENSE file for details.
Made with ❤️ by AI enthusiasts | Star ⭐ this repo if you find it useful!
This tool is for informational and educational purposes only. The analysis results are generated by AI and should not be considered as investment advice. Stock market investments carry risk, and you should:
- Do your own research before making investment decisions
- Understand that past performance does not guarantee future results
- Only invest money you can afford to lose
- Consult with a licensed financial advisor for personalized advice
The developers of this tool are not liable for any financial losses resulting from the use of this software.
- AkShare - Stock data source
- Google Gemini - AI analysis engine
- Tavily - News search API
- All contributors who helped improve this project
- GitHub Issues: Report bugs or request features
- Discussions: Join discussions
- Email: zhuls345@gmail.com


