An intelligent stock analysis system that combines multi-source data fusion, multi-dimensional scoring, and LLM-powered reasoning to provide actionable market insights. Designed as a multi-agent architecture where specialized agents handle data collection, analysis, screening, and reporting.
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ User Interface Layer โ
โ CLI โข WeChat Bot โข Web Dashboard โข API โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Agent Orchestrator โ
โ Task Scheduling โข Memory โข Context Management โ
โโโโโฌโโโโโโโโโโโฌโโโโโโโโโโโฌโโโโโโโโโโโฌโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโ
โ โ โ โ โ
โโโโโผโโโโ โโโโโผโโโโ โโโโโผโโโโ โโโโโผโโโโ โโโโโผโโโโ
โ Data โ โAnalysisโ โScreen โ โReport โ โMonitorโ
โ Agent โ โ Agent โ โ Agent โ โ Agent โ โ Agent โ
โ โ โ โ โ โ โ โ โ โ
โMulti- โ โTechnic.โ โFull โ โDaily โ โReal- โ
โSource โ โCapital โ โMarket โ โBrief โ โtime โ
โFusion โ โSentim. โ โScan โ โGener. โ โAlert โ
โ โ โFundam. โ โ17+ โ โLLM โ โ โ
โ5+ API โ โMarket โ โFactor โ โPoweredโ โCron โ
โโโโโฌโโโโ โโโโโฌโโโโ โโโโโฌโโโโ โโโโโฌโโโโ โโโโโฌโโโโ
โ โ โ โ โ
โโโโโผโโโโโโโโโโผโโโโโโโโโโผโโโโโโโโโโผโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโ
โ Data Source Layer โ
โ Tencent โข Sina โข EastMoney โข THS โข AkShare โข Tushare โข YFinanceโ
โ Fallback Chain โข Cache โข Rate Limiting โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Real-time quotes from 5+ providers (Tencent, Sina, EastMoney, THS, AkShare) with automatic failover. If one source is down, the system seamlessly switches to the next.
# Data sources with automatic fallback
sources = [TencentRealtimeSource(), SinaRealtimeSource(), EastMoneyRealtimeSource()]
chain = FallbackChain(sources)
quote = await chain.get_quote("002475") # Tries each source until one succeedsEvery stock gets scored across 5 dimensions:
| Dimension | Factors | Weight |
|---|---|---|
| Technical | MA trends, RSI, consecutive candles, price position | 25% |
| Capital Flow | Main force net flow, outer/inner ratio, volume ratio | 25% |
| Sentiment | News polarity, market heat, social media signals | 20% |
| Fundamental | PE, PB, revenue growth, ROE | 20% |
| Market | Sector strength, index correlation | 10% |
Scan 5000+ A-share stocks in seconds with configurable filters:
- Bowlong anti-chase rules (avoid overbought stocks)
- Fundamental risk gating (ST, delisting, insider selling)
- Event-driven scoring (news catalysts)
- Holdings overlap detection
Feed market data to LLM for natural language analysis:
- Daily morning/evening reports
- Stock-specific deep dives
- Portfolio risk assessment
- Market sentiment summary
- Scheduled market scans (pre-market, mid-day, post-market)
- Real-time price alerts via WeChat/Telegram
- Portfolio tracking with stop-loss monitoring
# Install
pip install -e .
# Single stock analysis
stock-agent analyze 002475
# Full market scan
stock-agent scan --top 20
# Market overview
stock-agent market
# Generate daily report
stock-agent report morningstock-agent/
โโโ src/stock_agent/
โ โโโ __init__.py
โ โโโ __main__.py # CLI entry point
โ โโโ tools/ # Agent tools (callable by LLM)
โ โ โโโ stock_analysis.py
โ โ โโโ market_scan.py
โ โ โโโ daily_report.py
โ โ โโโ price_alert.py
โ โโโ data/ # Multi-source data layer
โ โ โโโ sources/ # Data source adapters
โ โ โ โโโ base.py # Abstract base + FallbackChain
โ โ โ โโโ tencent.py
โ โ โ โโโ sina.py
โ โ โ โโโ eastmoney.py
โ โ โ โโโ ths.py
โ โ โโโ manager.py # Unified data manager
โ โ โโโ cache.py # TTL cache layer
โ โโโ analysis/ # Scoring & analysis engine
โ โ โโโ scoring.py # Multi-dimensional scoring
โ โ โโโ technical.py # Technical indicators
โ โ โโโ capital_flow.py # Capital flow analysis
โ โ โโโ sentiment.py # News sentiment (LLM-powered)
โ โ โโโ fundamental.py # PE/PB/ROE analysis
โ โโโ agent/ # LLM agent integration
โ โ โโโ tools.py # OpenAI function-calling schemas
โ โ โโโ prompts.py # System prompts
โ โ โโโ orchestrator.py # Multi-agent coordinator
โ โโโ reporting/ # Report generation
โ โโโ morning.py # Pre-market brief
โ โโโ evening.py # Post-market summary
โ โโโ templates.py # Report templates
โโโ tests/
โ โโโ test_scoring.py
โ โโโ test_data_sources.py
โ โโโ test_technical.py
โโโ pyproject.toml
โโโ README.md
โโโ LICENSE
Each tool is designed to be called by an LLM agent via function calling:
# tools/stock_analysis.py
TOOLS = [
{
"type": "function",
"function": {
"name": "stock_analysis",
"description": "Analyze a single stock with multi-dimensional scoring",
"parameters": {
"type": "object",
"properties": {
"code": {"type": "string", "description": "Stock code, e.g. '002475'"},
"include_sentiment": {"type": "boolean", "default": True},
},
"required": ["code"]
}
}
},
{
"type": "function",
"function": {
"name": "market_scan",
"description": "Scan the full A-share market and return top candidates",
"parameters": {
"type": "object",
"properties": {
"top_n": {"type": "integer", "default": 20},
"min_pe": {"type": "number"},
"max_pe": {"type": "number"},
"exclude_sectors": {"type": "array", "items": {"type": "string"}},
}
}
}
}
]{
"code": "002475",
"name": "็ซ่ฎฏ็ฒพๅฏ",
"price": 71.29,
"change_pct": 2.55,
"total_score": 55.0,
"signal": "WATCH",
"technical": {
"score": 55,
"signals": ["5่ฟ้ณ+5"],
"consecutive_up_candles": 5
},
"capital": {
"score": 60,
"signals": ["ไธปๅๅๅผบ +28.3ไธ", "ๅค็ๅๅผบ+8"]
},
"fundamental": {
"score": 58,
"pe": 30.17,
"pb": 5.88
}
}Built-in anti-chase and risk control rules:
- โ No buying stocks with PE > 50 (unless strong catalyst)
- โ No chasing stocks up > 5% in a single day
- โ No buying stocks that overlap with existing holdings
- โ Must have clear stop-loss level before entry
- โ Prefer stocks with PE < 30 and positive capital flow
- โ Require multi-day confirmation before entry
- OpenClaw โ Agent orchestration framework
- AkShare โ Financial data API
- Tushare โ A-share data provider
MIT