Files
myquant/djapi/continuation.md
T
simonandClaude Opus 4.7 271a9343a5 Initial commit: cc-cursor 全链路量化研究平台
7 Sprints 全部完成:
  Sprint 0: 基础设施 (DataManager + MariaDB)
  Sprint 1: 因子引擎 (34因子/12分类)
  Sprint 2: VectorBT 回测 (5策略+截面)
  Sprint 3: Optuna 优化 (+Walk-Forward)
  Sprint 4: ML 模型 (LightGBM+CatBoost)
  Sprint 5: Qwen 情绪因子 (三源新闻+日期对齐)
  Sprint 6: Agent 系统 (4Agent+日报.md/.html)

生产加固 (15项): Tushare双源fallback, SSH自动恢复, pool_pre_ping,
  save_daily先删后插, load_dotenv绝对路径, 日报5d/20d修复,
  RiskAgent改上证指数, 昨日对比+数据截止, mac_report utf8mb4,
  CLAUDE-*.md 9条已知Bug, demo全参数化, djapi数据源归一化,
  indexDatas API修正

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-07 15:59:05 +08:00

97 lines
3.4 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.
# continuation.md
## 当前项目状态
djapi — Django 5.2 金融数据 API 项目,2026-06-03 已部署。
服务器:`simon@doorcome.cn`,路径 `/home/simon/myquant/djapi/`,虚拟环境 `/opt/miniconda/envs/django/`
## 已完成
### 1. 安全:密钥统一管理
- 所有密钥 → 环境变量,`.env` 统一管理
- `djapi/env_loader.py`Django 端)+ `api/video/env.py`video 端)双加载器
- 共享 `MySQLDB``api/utils/mysql_handler.py`
- `.env.example``.gitignore`
### 2. 代码质量
- `api/views.py`227 → ~130 行,消除重复
- `api/stock/stock_utils.py``viewFunc_singleParam()` 包装器
- `api/stock/config.py`:拆分为 config / strategy_config / scan_config
### 3. drf-spectacular 集成
- 15 端点 `@api_view` + `@extend_schema`8 tag 分组
- 13 SerializerSwagger `/api/docs/`
### 4. 新功能
- akshare 股息率 API`api/stock/getDivData_AK.py``GET /api/getdivak/`
### 5. video 模块重构
- 新增 `api/video/env.py` — .env 加载
- `newsRedo.py` 重写 — 三分支智能重处理
- **P0 修复**`getVideo5.py` 日期校验 bug`start_date > start_date``start_date > end_date`
- **P1 清理**:删除 `ai.py`(两个函数均为死代码),清理 `newsProcess.py` 冗余 import
### 6. 文档与测试
- `CLAUDE.md``README.md``continuation.md`
- 18 个单元测试
## video 目录文件现状(9 个 .py
| 文件 | 职责 |
|------|------|
| `env.py` | .env 加载 |
| `getVideo5.py` | 主流程:抓取→下载→ASR→入库 |
| `audioRead.py` | 音频转换、分割、ASR 识别 |
| `deepseek.py` | DeepSeek API 封装(类 + 函数) |
| `newsProcess.py` | AI 新闻分割+标题提取 |
| `newsRedo.py` | 手动重处理(三分支) |
| `main.py` | 定时任务入口(当天) |
| `main_videos.py` | 批量补缺(扫描缺失日期) |
| `mysqlHandle.py` | MySQLDB 重新导出 |
## 所有 API 端点(15 个)
| 端点 | 数据源 | 说明 |
|------|--------|------|
| `stockbasic/` | Tushare | 日线行情 |
| `stockinfo/` | Tushare | 个股基本信息 |
| `industrys/` | Tushare | 行业股票列表 |
| `stockparam/` | Tushare | 个股参数 |
| `stockep/` | Tushare | TTM EPS |
| `quarterlyEps/` | Tushare | 季度 EPS |
| `indexByName/` | Tushare | 指数查询 |
| `indexDatas/` | Tushare | 指数行情 |
| `dailymargin/` | Tushare | 每日融资融券汇总 |
| `stockmargin/` | Tushare | 个股融资融券 |
| `finance/` | Tushare | 财务报表分析 |
| `getdiv/` | Tushare | 股息率 |
| `getdivak/` | akshare | 股息率(无需 token |
| `xwlbNews/` | MySQL | 新闻联播原始文本 |
| `xwlbFine/` | MySQL | 新闻联播 AI 精编 |
## 部署
```bash
# 全量同步
rsync -avz --delete \
--exclude='.env' --exclude='db.sqlite3' \
--exclude='*.log' --exclude='uwsgi.pid' \
--exclude='__pycache__/' --exclude='*.pyc' \
--exclude='xwlb_video/' --exclude='audio_processing/' \
/Users/summer/Downloads/cc-cursor/djapi/ \
simon@doorcome.cn:/home/simon/myquant/djapi/
# 单文件同步必须写完整路径
# 正确:rsync api/views.py simon@...:/.../djapi/api/views.py
# 重启
ssh simon@doorcome.cn "kill \$(lsof -ti:5004); sleep 2; /opt/miniconda/envs/django/bin/uwsgi --ini /home/simon/myquant/djapi/uwsgi.ini"
```
## 关键设计决策
- video 模块保护、向后兼容优先、不使用 python-dotenv
- rsync 陷阱:多文件源会展平路径
- `.env` 双加载:Django 端 `djapi/env_loader.py` + video 端 `api/video/env.py`