fix: concentration_guard infinite loop, HWM backfill, time stop (#483, #484, #485)#486
Merged
cct08311github merged 2 commits intomainfrom Mar 27, 2026
Merged
Conversation
…stop concentration_guard.py (#483): - Extend dedup window from 360s to 3600s and include filled orders - Add daily sell cap of 3 per symbol to prevent infinite loop ticker_watcher.py (#484, #485): - Add EOD price deviation guard blocking buys >5% from last close - Sync positions table after proposal sells - Add time-based stop loss: held >5d + loss >5% → force sell pnl_engine.py (#485): - Include entry_trading_day in sync_positions_table - Add _backfill_high_water_mark from eod_prices Fixes #483, Fixes #484, Fixes #485 Branch: fix/483-484-485-strategy-bugs Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This was referenced Mar 27, 2026
…er_mark columns and logger - test_pnl_engine: add ts_submit to orders, entry_trading_day + high_water_mark to positions - test_position_quarantine: add entry_trading_day + high_water_mark columns, fix positional INSERT - pnl_engine: add missing logger for _backfill_high_water_mark warning Fixes #485 Branch: fix/483-484-485-strategy-bugs Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
修復每日策略審核發現的三個 CRITICAL bug:
submitted狀態,filled後又重新觸發,導致 2382 產生 48 筆 sell orders(16,852 股賣出 vs 720 股持有)。修正:擴展 dedup 視窗至 1 小時含 filled 狀態 + 每日最多 3 筆 sell cap。high_water_mark和entry_trading_day為 NULL 導致 1303 持倉跌 16% 未觸發止損。修正:sync_positions_table自動回填 HWM(從 eod_prices max close)+ 加入時間止損(持有 >5 天且虧損 >5% → 強制 sell)。Changes
concentration_guard.pyticker_watcher.pypnl_engine.pyTest plan
pytest tests/ -q→ 887 passed, 4 failed (all pre-existing)pytest frontend/backend/tests/ -q→ 581 passed, 1 failed (pre-existing)Fixes #483, Fixes #484, Fixes #485
🤖 Generated with Claude Code