feat(skill+engine): 台股入列 — Step 0 認格式標 .TW/.TWO + 混幣錨點 fx 補洞 (closes #173)#177
Merged
Conversation
…173) 問題(#173):engine 只吃 Firstrade schema,台股對帳單連 load() 的門都進不了 → 「最大單點依賴」把台積電漏掉、AI 曝險分母不含台股(engine 世界裡根本沒有台股)。 架構分工(符合 #89 engine 不 hardcode 格式):認格式是 Claude Step 0 的世界知識職責, engine 只吃標準 CSV。方案 = Step 0 把台股 Symbol 標成**完整 yfinance 代號** (2330.TW/.TWO)+ Market/Currency 欄 → engine 內部一路同 key、抓價天然對,零映射表。 實測 #132 既有多市場基礎設施(MARKET_BENCH TW→^TWII、per-market α/β、混幣聚合入 USD、 last_px staleness 降級)已足夠支撐台股,engine 抓價/α-β/聚合零改動。 engine 真改動只有一處 latent gap:混幣時現金餘額錨點(anchor.amount)沒經 fx 換算, TWD 錨點被當 USD 直接加 → cash_weight 放大數十倍。抽 _anchor_to_aggregate() 補換。 - engine: _anchor_to_aggregate() 純函式 + main 混幣接線呼叫 - SKILL Step 0: 多市場 prose(非美股標 Market/Currency;台股 .TW/.TWO/TWD、民國年換西元) - mock: sample_tw_mixed 台美混倉 persona(台積電最大 combined 依賴 + 半導體橫跨台美) - 測試: test_engine_units +anchor fx 換算(純函式,紅綠雙向); test_sample_styles +混市場結構(離線)+ combined 口徑(network smoke) - EVALS B18 + eval-design C-3 + 鏡像對照同步 驗收(network smoke 實跑):台積電是聚合 USD 視圖最大依賴(59%)、半導體 combined 曝險 含台股(82%)、α/β 台股對 ^TWII 不合成總 α、混幣現金錨點正確換算。run_all 十套綠。 遺留(下個 session):多幣別現金桶——單一 TR_CASH 只表一種幣,台美各帳戶現金需多錨點。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
atomchung
pushed a commit
that referenced
this pull request
Jul 12, 2026
) 問題:單一 TR_CASH 只表一種幣,台美各帳戶現金無法各自錨定 → 混市場帳戶 現金比重/入金判讀算不準(台股 session #173 挖出的遺留)。 cash_position 重構成 per-currency:每個幣別各自錨點(錨點+其後該幣別現金流) 或 csv_sum,用 fx 聚合成 USD total。#177 的 _anchor_to_aggregate(單一 anchor 換算)是此設計的特例,併入退役。 - TR_CASH 支援 list(台美多帳戶各一錨點,向後相容單 dict) - 輸出保持 {balance,weight,source,reliable,recent_net_deposit} 契約 + by_currency 明細 - reliable:全幣別有錨點=true / 部分=partial / 全無=csv_sum - honesty_ledger cash_reliability 對 partial 揭露 unanchored_currencies(只講缺的帳戶、別把已可信的那半講不準) - SKILL Step 0 TR_CASH list 格式 + card-spec partial 講法 + EVALS B17 同步 驗證:run_all 十套綠(離線+network);tw_mixed 雙錨點聚合(TWD 250k + USD 4k → 11788 USD reliable + by_currency);單幣 mock 向後相容(noisy_broker 單 USD 錨點 balance=22284 anchored,數字不變)。 stacked on #177(台股,claude/silly-sutherland-974463);#177 merge 後 retarget main。 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.
Closes #173
問題(#173)
engine 只吃 Firstrade schema,台股對帳單連
load()的門都進不了 → 「最大單點依賴」把台積電漏掉、AI 曝險分母不含台股(engine 世界裡根本沒有台股)。設計選擇(請 review 這點)
issue 原設想「engine 端
fetch_prices掛.TW/.TWOsuffix」。實作時改走更符合 #89(engine 不 hardcode 格式)的分工:Symbol標成完整 yfinance 代號(2330.TW/.TWO)+Market/Currency欄 → engine 內部一路同 key、抓價天然對,零映射表、零 rename、零 bug 面。上市/上櫃判別留 Step 0(世界知識),engine 只做機械聚合。MARKET_BENCHTW→^TWII、per-market α/β、混幣聚合入 USD、last_pxstaleness 降級——engine 抓價/α-β/聚合零改動。engine 真改動只有一處 latent gap:混幣時現金餘額錨點(
anchor.amount)沒經 fx 換算,TWD 錨點被當 USD 直接加 →cash_weight放大數十倍。抽_anchor_to_aggregate()補換。改動
engine/trade_recap.py_anchor_to_aggregate()純函式 + main 混幣接線呼叫SKILL.mdStep 0Market/Currency;台股.TW/.TWO/TWD、民國年換西元mock/sample_tw_mixed.*tests/EVALS.mdB18 /eval-design.mdC-3驗收(network smoke 實跑)
^TWII不合成總 α(scope=TW)、混幣現金錨點正確換算(250k TWD→~7.8k USD)2330.TW/6488.TWOyfinance)、缺報價誠實降級run_all十套綠(離線+network)遺留(下個 session)
多幣別現金桶:單一
TR_CASH只表一種幣,台美各帳戶現金需多錨點。本 PR 先把單一錨點的 fx 換算修對。🤖 Generated with Claude Code