Fundamental_Analysis/backend/README.md

100 lines
2.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 基本面选股系统 - 后端服务
基于FastAPI的股票基本面分析后端服务提供报告生成、配置管理和进度追踪功能。
## 项目结构
```
backend/
├── main.py # FastAPI应用入口
├── requirements.txt # Python依赖
├── .env.example # 环境变量示例
├── README.md # 项目说明
└── app/
├── __init__.py
├── core/ # 核心模块
│ ├── config.py # 配置管理
│ ├── database.py # 数据库连接
│ └── dependencies.py # 依赖注入
├── models/ # 数据模型
│ ├── report.py
│ ├── analysis_module.py
│ ├── progress_tracking.py
│ └── system_config.py
├── schemas/ # Pydantic模式
│ ├── report.py
│ ├── config.py
│ └── progress.py
├── services/ # 业务服务
│ ├── config_manager.py
│ ├── data_fetcher.py
│ ├── report_generator.py
│ └── progress_tracker.py
└── routers/ # API路由
├── reports.py
├── config.py
└── progress.py
```
## 快速开始
1. 安装依赖:
```bash
pip install -r requirements.txt
```
2. 配置环境变量:
```bash
cp .env.example .env
# 编辑 .env 文件设置数据库连接和API密钥
```
3. 启动服务:
```bash
uvicorn main:app --reload --host 0.0.0.0 --port 8000
```
4. 访问API文档
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
## API端点
### 报告相关
- `GET /api/reports/{symbol}?market={market}` - 获取或创建报告
- `POST /api/reports/{symbol}/regenerate?market={market}` - 重新生成报告
- `GET /api/reports/{report_id}/details` - 获取报告详情
### 配置管理
- `GET /api/config` - 获取系统配置
- `PUT /api/config` - 更新系统配置
- `POST /api/config/test` - 测试配置连接
### 进度追踪
- `GET /api/progress/{report_id}` - 获取报告生成进度
## 数据库
系统使用PostgreSQL数据库包含以下主要表
- `reports` - 报告基本信息
- `analysis_modules` - 分析模块内容
- `progress_tracking` - 进度追踪记录
- `system_config` - 系统配置
## 开发
### 代码格式化
```bash
black app/
isort app/
```
### 类型检查
```bash
mypy app/
```
### 运行测试
```bash
pytest
```