arbitrage-engine/docs/V52-TODO.md
root 45bad25156 fix(P0): pnl_r calculation + cooldown bypass + partition month bug
P0-1: Reverse signal now bypasses cooldown - evaluate_signal always
      outputs direction, main loop checks direction+score>=60 for
      closing positions against trend (not blocked by COOLDOWN_MS)

P0-2: pnl_r unified to (exit-entry)/risk_distance across all exit
      scenarios (tp, sl, sl_be, timeout) in both paper_monitor.py
      and signal_engine.py. Old hardcoded values (1.5R/2.25R) were
      ~2x too high vs actual risk_distance basis.

P1-1: ensure_partitions month calculation fixed from timedelta(30d)
      to proper month arithmetic. Also fixed UTC timezone for
      partition boundaries.

docs: V52-TODO.md with full audit backlog for V5.2
2026-03-01 09:29:32 +00:00

62 lines
3.5 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.

# V5.2 待修复清单
> 来源Claude Code审阅报告 + 露露复查
> 创建2026-03-01
## 已在V5.1-hotfix中修复P0
| ID | 问题 | 修复 |
|----|------|------|
| P0-1 | 冷却期阻断反向信号平仓 | evaluate_signal始终输出direction主循环基于direction+score>=60触发反向平仓 |
| P0-2 | pnl_r TP场景虚高2倍 | paper_monitor+signal_engine统一用(exit-entry)/risk_distance计算 |
| P1-1 | 分区月份Bug(timedelta 30天) | 改为正确的月份加法 + UTC时区 |
| P2-2 | 分区边界用本地时区 | 改为datetime.timezone.utc |
## V5.2 必须修复
### 后端
| ID | 优先级 | 文件 | 问题 | 建议修复 |
|----|--------|------|------|---------|
| P0-3 | P1 | signal_engine.py | 开仓价用30分VWAP而非实时价 | 改用win_fast.trades[-1][2]最新成交价 |
| P0-4 | P2 | signal_engine+paper_monitor | 双进程并发写竞态 | SELECT FOR UPDATE SKIP LOCKED |
| P1-2 | P2 | signal_engine.py | 浮点精度漂移(buy_vol/sell_vol) | 每N次trim后从deque重算sums |
| P1-3 | P1 | market_data_collector.py | 单连接无重连 | 改用db.get_sync_conn()连接池 |
| P1-4 | P3 | db.py | 连接池初始化线程不安全 | 加threading.Lock双重检查 |
| P2-1 | P2 | market_data_collector.py | XRP/SOL coinbase_premium KeyError | 不在pair_map中的跳过 |
| P2-3 | P2 | agg_trades_collector.py | flush_buffer每秒调ensure_partitions | 移到定时任务(每小时) |
| P2-4 | P3 | liquidation_collector.py | elif条件冗余 | 改为else |
| P2-5 | P2 | signal_engine.py | atr_percentile @property有写副作用 | 移到显式update_atr_history() |
| P2-6 | P2 | main.py | 1R=$200硬编码 | 从paper_config.json读取 |
| P3-1 | P2 | auth.py | JWT密钥硬编码默认值 | 启动时强制校验环境变量 |
| P3-2 | P3 | main.py | CORS allow_origins=["*"] | 限制为前端域名 |
| P3-3 | P3 | auth.py | refresh token刷新非原子 | UPDATE...RETURNING原子操作 |
| P3-4 | P3 | auth.py | 登录无频率限制 | slowapi或Redis计数器 |
| NEW | P1 | signal_engine.py | 冷启动warmup只有4小时 | 分批加载24小时数据加载完再出信号 |
### 前端
| ID | 优先级 | 文件 | 问题 | 建议修复 |
|----|--------|------|------|---------|
| FE-P1-1 | P1 | lib/auth.tsx | 并发401多次refresh竞态 | 单例Promise防并发刷新 |
| FE-P1-2 | P1 | lib/auth.tsx | 刷新失败AuthContext未同步 | 事件总线通知强制logout |
| FE-P1-3 | P1 | 所有页面 | catch{}静默吞掉API错误 | 加error state+用户提示 |
| FE-P1-4 | P2 | paper/page.tsx | LatestSignals串行4请求 | Promise.allSettled并行 |
| FE-P2-1 | P3 | app/page.tsx | MiniKChart每30秒销毁重建 | 只更新数据不重建chart |
| FE-P2-3 | P2 | paper/page.tsx | ControlPanel非admin可见 | 校验isAdmin |
| FE-P2-4 | P1 | paper/page.tsx | WebSocket无断线重连 | 指数退避重连+断线提示 |
| FE-P2-5 | P2 | paper/page.tsx | 1R=$200前端硬编码 | 从API读取配置 |
| FE-P2-6 | P2 | signals/page.tsx | 5秒轮询5分钟数据 | 改为300秒间隔 |
| FE-P2-8 | P3 | paper/signals | 大量any类型 | 定义TypeScript interface |
| FE-P3-1 | P3 | lib/auth.tsx | Token存localStorage | 评估httpOnly cookie |
| FE-P3-3 | P3 | app/page.tsx | Promise.all任一失败全丢 | 改Promise.allSettled |
## V5.2 新功能(同步开发)
| 功能 | 说明 |
|------|------|
| FR+清算加入评分 | 8信号源完整接入 |
| 策略配置化框架 | 一套代码多份配置 |
| AB测试 | V5.1 vs V5.2两套权重对比 |
| 24h warmup | 启动时分批加载24小时数据 |