Skip to content

fix: buy order 價格偏離 — simulation 使用策略歷史價格而非即時行情 #484

@cct08311github

Description

@cct08311github

問題描述

2382 在 3/19 以 220.2 買入,但當日 EOD 收盤價為 286.5,偏離幅度 23%。原因:simulation 模式下 Shioaji 以委託價成交,而策略模組送出的委託價使用了歷史/過時價格。

影響

  • positions.avg_price = 220.0 vs 實際市場 ~287 → unrealized PnL +31K 為虛假數據
  • 績效指標全部失真
  • 回測與 live 表現會有巨大落差

修復方案

  1. buy order 委託價強制使用即時行情(Shioaji tick)或最新 EOD close
  2. 加入 buy_price_max_deviation_pct = 2.0:若委託價偏離最新 EOD close 超過 2%,拒絕送單並記 incident
  3. 影響範圍:ticker_watcher.py 中建立買單的邏輯

驗證

  • 新買單委託價與最新 EOD close 偏離 <2%
  • 偏離超標時寫入 incidents 表並跳過下單
  • 現有 positions 表中的歷史買入價標註警告

來源:每日策略審核 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