Restructure into modules/ with single-process CTP and config/ layout.

Move business code under modules/, env template to config/, PM2 single qihuo process, and _legacy shims for old imports.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-01 14:42:16 +08:00
parent b354d6c701
commit e5a586f903
209 changed files with 21962 additions and 20963 deletions
+50
View File
@@ -0,0 +1,50 @@
# 主目录结构
```
qihuo/ # 主文件夹(仓库根)
├── app.py # 主程序入口(Flask 启动)
├── requirements.txt
├── deploy.sh # 一键部署脚本
├── ecosystem.config.cjs # PM2 启动配置
├── config/
│ ├── .env.example # 环境变量模板
│ └── .env # 运行时配置(git 忽略)
├── modules/ # 业务模块(每个模块 register(deps)
│ ├── core/ # DB、路径、公共工具
│ ├── web/ # 页面路由 + static/ + templates/
│ ├── trading/ # 下单监控、持仓、推荐
│ ├── ctp/ # vn.py / CTP 连接与报单
│ ├── risk/ # 账户风控
│ ├── strategy/ # 趋势、滚仓策略
│ ├── keys/ # 关键位
│ ├── plans/ # 开单计划
│ ├── market/ # 行情、K 线
│ ├── records/ # 交易记录、复盘
│ ├── stats/ # 统计、看板
│ ├── settings/ # 系统设置
│ ├── notify/ # 微信、AI 消息
│ ├── fees/ # 手续费
│ └── backup/ # 备份
├── _legacy/ # 旧 import 兼容 shimPM2 PYTHONPATH
├── data/ # 静态数据(如 fee_rates.json
├── docs/ # 文档
├── scripts/ # 运维/诊断脚本(非运行时)
├── futures.db # SQLite(未配 PG 时)
├── uploads/
└── logs/
```
根目录 `_legacy/` 为旧 `import db_conn` 等路径的兼容层;新代码请 `from modules.xxx import ...`
## 进程模型
- **单进程**PM2 仅 `qihuo``app.py` + CTP 同进程)
- 详见 [DEPLOY.md](./DEPLOY.md)
## 模块契约
每个 `modules/<name>/` 提供 `register(deps: AppDeps)`;主程序 `app.py` 只做串联,不写业务。
## 发布
见 [DEPLOY.md](./DEPLOY.md)**本地修改 → git push → 服务器 git pull**,禁止 SCP。