feat(engine): 殘倉過濾 — 市值<0.1% 部位不進分散度/診斷/未分類計數 (closes #172)#176
Merged
Conversation
owner 拍板(#172):1 股殘倉(股息零頭/賣到剩一絲的尾倉)讓「持股數」對用戶失去意義、 也讓假分散判定的啟動門檻恆成立(n_holdings≥8 恆真)。判準用**相對佔比**(市值<0.1%), 非絕對股數(1 股 MSTR 可能好幾百鎊)/固定金額(對不同帳戶規模失真)。 - `meaningful_tickers(held, last_px)`:市值佔全持倉 ≥0.1% 的 ticker set(缺價用成本近似,離線可算) - main 統一過濾:去殘 `held_dx` 餵 `dim_diversify`(n/top3/max_sector/ai_pct 分母)、`what_if`、 `ticker_diagnosis`;`unclassified_drivers` 計數也排除殘倉(核能小倉 LEU 之類不冒充「連歸類都做不到」) - **overview(P&L)/dim_size/n_held/state 不動**:市值基準會把「重倉崩 99%」的部位當殘倉, 但只從『集中度診斷』排除、不從『總覽 P&L』排除 → 虧損不藏、對帳 held_n 全量一致 - 常數 `RESIDUAL_POS_TH = 0.001` 放檔頭常數區 驗證:run_all 十套綠;全 13 mock div_n==held_n(無殘倉→零影響,現有 persona 卡面不變); 端到端 fixture(0.02 股 AAPL 殘倉)→ dim_diversify n 排除、overview held_n 保留; 單元測試(市值基準/崩倉靠市值排除/dim_diversify n 去殘/零市值邊界)。 closes #172 · cross-ref #138(同動 dim_diversify,判準不同,無 open PR 重疊) Co-Authored-By: Claude Opus 4.8 <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.
這個 PR 做什麼
owner 拍板 #172 的第 2 問。1 股殘倉(股息零頭 / 賣到剩一絲的尾倉)讓「持股數」對用戶失去意義,也讓假分散判定的啟動門檻(
n_holdings≥8)恆成立。判準用相對佔比(市值 <0.1%) —— owner 明確排除:❌ 絕對股數門檻(1 股 MSTR 可能好幾百鎊)、❌ 固定金額門檻(對不同帳戶規模失真)。相對佔比自適應帳戶規模。
動哪裡(統一過濾,#172 指定範圍)
meaningful_tickers(held, last_px):市值佔全持倉 ≥0.1% 的 ticker set(缺價用成本近似,離線可算)held_dx,餵給 →dim_diversify(n/top3/max_sector_pct/ai_pct分母)、what_if、ticker_diagnosis;unclassified_drivers計數也排除殘倉RESIDUAL_POS_TH = 0.001放檔頭常數區關鍵安全設計:市值基準 + 只濾診斷,不濾 P&L
市值基準會把「重倉後崩 99%」的部位(市值極小)判成殘倉。但過濾只作用在集中度診斷,不作用在
overview(P&L) → 該部位從分散度診斷排除、它的未實現虧損仍留在總覽 → 虧損不藏、對帳held_n全量一致。dim_size(單筆過重本就只看大倉)、n_held(對帳全量)一併不動。dim_diversifyn/集中度、what_if、ticker_diagnosis、unclassified計數overview已實現/未實現、dim_size、n_held、state.holdings測試 / 核對
run_all十套全綠div_n == held_n(無殘倉 → 過濾零影響,現有 persona 卡面不變)dim_diversify n排除、overview held_n保留dim_diversifyn 去殘 / 零市值邊界closes #172 · cross-ref #138(同動
dim_diversify,判準不同,查無 open PR 重疊)🤖 Generated with Claude Code