feat(ratewise): 新增來回換匯成本與計價基準判定工具(PR-A) - #996
Merged
Merged
Conversation
Contributor
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
Contributor
|
✅ SEO 審計通過!所有 2026 標準驗證項目都符合要求。
|
- roundTripCost:以 (sell - buy) / sell 量化換出再換回的損失率, 含 low/medium/high 分級與台幣損失金額換算 - deriveCashBuy:自 bankMid 代數還原現金買入價(cashBuy = 2*bankMid - cashSell), seo-rate-examples 未直接保留買入價 - 報價單位限定 TWD_PER_FOREIGN;換錢所 KRW_PER_TWD(sell 46.0 / buy 46.7) 方向相反,落入單位保護回傳 null 而非算出反號損失率 - rateBasisLabel:計價基準收斂為 mid/cross/direct 三種,僅揭露 RateTypeSelector 表達不出來的情境,direct 不顯示標籤 - 四語系補 rateBasis 文案並加 key 完整性守門 - 本次僅交付純函式模組,無使用者可見變更 測試:31 tests 通過(含 17 幣別真實牌告迴歸與換錢所單位保護)、 ratewise 全套 2806 tests 通過、pnpm typecheck 通過
s123104
force-pushed
the
feat/rate-basis-semantics
branch
from
August 8, 2026 09:02
742817e to
1dda1be
Compare
Contributor
|
✅ SEO 審計通過!所有 2026 標準驗證項目都符合要求。
|
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.
PRD
2026-08-08-rate-basis-buyback-direction的 PR-A:純函式模組 + 測試,無使用者可見變更。為什麼需要
「換出去再換回來」會被銀行賺兩次價差,但這個成本從未被量化。以 main 的實際牌告推導,17 幣別的來回損失率全距達 15 倍:
中位數 4.76%。換 30000 台幣的 IDR 再換回,損失約 9,633 元。
競品(比率網、TaiwanRate)只做「哪家銀行價格好」的橫向比較,不做「這筆交易划不划算」的縱向判斷。
本 PR 內容
utils/roundTripCost.tscomputeRoundTripCost(sell, buy)— 以(sell - buy) / sell計算損失率,回傳lossPct/spread/severityderiveCashBuy(bankMid, cashSell)—seo-rate-examples只保留bankMid = (cashBuy + cashSell) / 2,故買入價需代數還原為2 * bankMid - cashSell。這是還原不是估計,不引入誤差classifyRoundTripSeverity—low < 5%、medium 5–15%、high >= 15%,門檻依實測分布訂定computeRoundTripLossTwd(twdAmount, cost)防禦:缺值、非有限數、
sell <= 0、buy > sell(資料異常)皆回傳null而非 0。utils/rateBasisLabel.ts計價基準自 #433 的 8 種精簡為 3 種:
midrateMode === 'mid'crossdirect捨棄
shop-*四種 —— 與RateTypeSelector的可見狀態重複。優先序mid > cross > direct:中間價根本不可成交,此警示強於「跨了兩次價差」。設計原則:恆亮的標籤會退化為視覺壁紙,只在有話要說時出現才具訊號價值。
i18n
四語系補
rateBasis區塊,含 key 完整性守門與「不得為direct建立文案」的反向斷言。測試
40 tests 通過,含 17 幣別真實牌告迴歸:
bankMid的幣別皆可還原買入價並算出成本high、USD 為lowpnpm typecheck通過。不在本 PR 範圍
exchangeRateSpread(PR-B)SingleConverter.tsx與layout.ts,避免與進行中的 fold 工作衝突