Use the AKShare library to obtain and analyze China A-share market data. AKShare isfree and open-sourcefinancial data interface, requiring no registration or Token.
Quick Start
Environment Preparation
pip install akshare pandas numpy pyyaml
Using Scripts
cd e:\AIproJect\A_Share\.agent\skills\akshare-stock\scripts
# 智能投资分析(推荐)
python analyze_investment.py 002475
Real-Time Quotes
python get_realtime_quote.py 002475
Historical K-Linespython get_history_kline.py 002475 --days 60
Technical Indicatorspython calc_technical.py 002475
Comprehensive Analysis Reportpython stock_analyzer.py 002475 -o report.md
## 脚本列表
### 数据获取脚本
| 脚本 | 功能 | 示例 |
|------|------|------|
| `get_realtime_quote.py` | 实时行情 | `python get_realtime_quote.py 002475` |
| `get_history_kline.py` | 历史K线 | `python get_history_kline.py 002475 --days 60` |
| `get_valuation.py` | 估值指标 | `python get_valuation.py 002475` |
| `get_fund_flow.py` | 资金流向 | `python get_fund_flow.py 002475 --days 10` |
| `get_financial.py` | 财务数据 | `python get_financial.py 002475` |
| `get_shareholders.py` | 股东信息 | `python get_shareholders.py 002475` |
| `get_dividend.py` | 分红数据 | `python get_dividend.py 002475` |
### 分析脚本
| 脚本 | 功能 | 说明 |
|------|------|------|
| `analyze_investment.py` | 智能投资分析 | 多维度评分 + 投资建议 |
| `calc_technical.py` | 技术指标计算 | MA/MACD/RSI/KDJ/BOLL |
| `stock_analyzer.py` | 综合分析报告 | 合并所有数据的完整报告 |
### 工具脚本
| 脚本 | 功能 | 说明 |
|------|------|------|
| `cache_manager.py` | 数据缓存 | SQLite 本地缓存 |
| `scheduler.py` | 定时任务 | 自动获取数据和生成报告 |
## 核心功能
### 1. 智能投资分析
```bash
python analyze_investment.py 002475
Automated analysis:
- 📊 Valuation analysis (PE/PB/dividend yield)
- 📈 Growth analysis (revenue/profit growth rate)
- 💵 Capital flow analysis (main capital flow)
- 📉 Technical analysis (moving averages/MACD/RSI)
- Comprehensive score + investment recommendation
2. Technical Indicators
python calc_technical.py 002475
Supported indicators:
- MA: 5/10/20/60-day moving averages
- MACD: DIF, DEA, MACD histogram
- RSI: 6/12/24-day
- KDJ: K, D, J
- BOLL: upper band/middle band/lower band
3. Data Caching
Automatic caching to avoid repeated requests:
- Real-time quotes: 1 minute
- Daily K-lines: 1 hour
- Financial data: 7 days
- Shareholder data: 30 days
4. Scheduled Tasks
# 立即执行
python scheduler.py --run-now
# 后台运行调度器
python scheduler.py
Configure config.yaml to set monitored stocks and execution times.
Output Format
All scripts output by default in Markdown format, which can be previewed or saved directly:
python analyze_investment.py 002475 -o 分析报告.md
File Structure
akshare-stock/
├── SKILL.md # 本文档
├── config.yaml # 配置文件
├── references/
│ ├── api_reference.md # API 参考
│ └── official_docs.md # 官方文档索引
└── scripts/
├── analyze_investment.py # 智能分析
├── calc_technical.py # 技术指标
├── cache_manager.py # 数据缓存
├── scheduler.py # 定时任务
├── stock_analyzer.py # 综合分析
├── get_realtime_quote.py # 实时行情
├── get_history_kline.py # 历史K线
├── get_valuation.py # 估值指标
├── get_fund_flow.py # 资金流向
├── get_financial.py # 财务数据
├── get_shareholders.py # 股东信息
└── get_dividend.py # 分红数据