Files
dekun 169136dd4a Add modular docs with index, WeChat templates, and AI guide.
Document per-module order logic, risk rules, and WeChat message templates with a central INDEX for navigation.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-28 10:49:10 +08:00

109 lines
2.6 KiB
Markdown
Raw Permalink 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.
# 开单计划
**页面路径**`/plans`
**相关文件**`app.py``check_order_plans``background_task`
---
## 功能概述
录入 **当日交易计划**:品种、方向、决策价格区间、止损、止盈、决策理由。系统轮询现价,进入区间后 **微信提醒** 并激活监控;触及 TP/SL 后记录结果并结案。
> **不自动向 CTP 下单**,仅提醒 + 记录。
---
## 计划状态
```
planned → active → closed
↘ expired(过期,非当日)
```
| 状态 | 含义 |
|------|------|
| `planned` | 已录入,等待价格进入决策区间 |
| `active` | 已进入区间,监控 TP/SL |
| `closed` | 触及止盈或止损,已结案 |
| `expired` | 非当日计划自动过期 |
---
## 下单逻辑
本模块 **无 CTP 报单**
### 1. 录入(用户操作)
- 主力合约、方向(多/空)
- **决策区间**`zone_lower` ~ `zone_upper`
- 止损价、止盈价
- 决策理由(可选,推送时展示)
### 2. 触发激活(后台 ~3 秒)
条件:`status=planned``zone_lower ≤ 现价 ≤ zone_upper`
动作:
1. 发送微信 [WECHAT §9](./WECHAT.md#9-开单计划)
2. `status → active`,记录 `triggered_at`
### 3. 止盈止损监控(active
| 方向 | 止盈 | 止损 |
|------|------|------|
| 多 | 现价 ≥ take_profit | 现价 ≤ stop_loss |
| 空 | 现价 ≤ take_profit | 现价 ≥ stop_loss |
触发后:
1. 微信 [WECHAT §10](./WECHAT.md#10-开单计划结果)
2. 写入 `trade_records`monitor_type=开单计划)
3. `status → closed`
### 4. 前端轮询
列表约 1 秒请求 `/api/plan_prices` 刷新现价。
---
## 风控规则
| 项 | 说明 |
|----|------|
| 账户冷静期 | **不校验** — 计划不自动开仓 |
| 保证金 / 品种 | **不校验** |
| 交易时段 | 轮询全天运行,非交易时段仍可推送 |
| 同日计划 | `plan_date` 为当日;跨日 `expire_old_plans()` |
用户收到提醒后若手动下单,须自行遵守 [RISK.md](./RISK.md)。
---
## 微信推送
| 事件 | 文档 |
|------|------|
| 进入决策区间 | [WECHAT §9](./WECHAT.md#9-开单计划) |
| 触及 TP/SL | [WECHAT §10](./WECHAT.md#10-开单计划结果) |
**配置**:系统设置 → 企业微信 Webhook。
---
## 数据库
`order_plans`symbol、direction、zone_upper/lower、stop_loss、take_profit、status、plan_date 等。
触发结果写入 `trade_records`(非 `trade_logs`,不计入 CTP 同步统计主表)。
---
## 相关文档
- [WECHAT.md](./WECHAT.md)
- [ORDER_MONITOR.md](./ORDER_MONITOR.md) — 收到提醒后手动下单
- [RECORDS.md](./RECORDS.md)