A-share K-line analysis tool - provides real-time quotes, technical indicator calculation, K-line pattern recognition, and technical analysis reports.
Features
- Real-time quotes: Sina Finance API to obtain real-time prices
- K-line data: Baostock to obtain historical K-line data
- Technical indicators: MA, MACD, RSI, Bollinger Bands
- Pattern recognition: Hammer line, Doji, Engulfing pattern
- Analysis report: Automatically generate technical analysis reports
- Visualization: Generate K-line charts (optional)
Data sources
| Data type | Source | Stability |
|---|---|---|
| Real-time price | Sina Finance | ✅ Stable |
| K-line history | Baostock | ✅ Stable |
Usage
# 基础分析
python3 scripts/kline_analyzer.py --code 600409 --days 30 --realtime --report
# 生成图表
python3 scripts/kline_analyzer.py --code 600409 --days 60 --plot --output chart.png
# JSON输出
python3 scripts/kline_analyzer.py --code 600409 --json
Parameter description
| Parameter | Description | Example |
|---|---|---|
--code |
Stock code | 600409 |
--days |
Number of days to retrieve | 30 |
--period |
Period | daily/weekly/monthly |
--realtime |
Retrieve real-time price | - |
--report |
Generate analysis report | - |
--plot |
Generate chart | - |
--output |
Chart save path | chart.png |
--json |
JSON format output | - |
Dependencies
- Python 3.8+
- pandas
- matplotlib
- baostock
Installation
pip3 install baostock pandas matplotlib --break-system-packages
Example output
📊 600409 三友化工 技术分析报告
==================================================
【实时行情】
最新价: 8.42 元
涨跌幅: -3.11%
【技术指标】
MA5: 8.62 (股价在下方📉)
RSI(14): 67.60 (中性➖)
MACD: 0.413 (金叉📈)
【综合建议】
• MACD金叉,短期动能偏多
Disclaimer
This tool is for learning and research purposes only and does not constitute investment advice. The stock market carries risks, and investment should be made with caution.
Version
v1.0.0 - 2026-03-09
License
MIT License