Skip to content

fix: concentration_guard 無限循環 — simulation 模式下 dedup 機制缺失 #483

@cct08311github

Description

@cct08311github

問題描述

concentration_guard 在 simulation 模式下每 3 分鐘重複觸發賣單,因為 simulation 填單後 positions 表持倉不實際減少,導致下一輪仍偵測到集中度超標(78.5% > 60%),無限循環。

3/25 單日數據

  • 2382 sell orders:95 筆(48 filled / 47 rejected)
  • 訂單間隔:每 3 分鐘一筆,從 01:00 到 05:39 UTC
  • 訂單拒絕率:50.5%

影響

  • 產生大量無效訂單,污染 orders 表
  • 執行資源浪費(Shioaji API 呼叫)
  • 若切換實盤會造成大量真實交易

修復方案

  1. concentration_guard.py 加入 dedup 機制:同一 symbol 60 分鐘內已有 filled/submitted 賣單則跳過
  2. 加入 daily_sell_cap=3 次/symbol/日
  3. ticker_watcher.py 呼叫 concentration_guard 前檢查是否已有 pending sell order

新增參數

concentration_guard_dedup_window_min = 60
concentration_guard_daily_sell_cap = 3

驗證

  • simulation 模式下 2382 不再每 3 分鐘觸發賣單
  • 集中度 >60% 時仍正常觸發首次賣單
  • daily_sell_cap 計數正確重置

來源:每日策略審核 2026-03-27

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions