mirror of
https://github.com/we-promise/sure.git
synced 2026-04-19 03:54:08 +00:00
Remove "value" from the market_value fallback chain in the SimpleFIN HoldingsProcessor and add it to the cost_basis fallback chain instead. Some brokerages (Vanguard, Fidelity) use "value" to represent cost basis, causing the system to display average cost per share as the current price and show massive phantom losses. https://claude.ai/code/session_01V2gC6BPT3sF7Hu4XQgUQT4 Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -42,9 +42,12 @@ class SimplefinAccount::Investments::HoldingsProcessor
|
||||
end
|
||||
|
||||
# Parse provider data with robust fallbacks across SimpleFin sources
|
||||
# NOTE: "value" is intentionally excluded from the market_value fallback chain
|
||||
# because some brokerages (e.g. Vanguard, Fidelity) use "value" to mean cost basis,
|
||||
# which would cause the system to display average cost as current price. (GH #1182)
|
||||
qty = parse_decimal(any_of(simplefin_holding, %w[shares quantity qty units]))
|
||||
market_value = parse_decimal(any_of(simplefin_holding, %w[market_value value current_value]))
|
||||
cost_basis = parse_decimal(any_of(simplefin_holding, %w[cost_basis basis total_cost]))
|
||||
market_value = parse_decimal(any_of(simplefin_holding, %w[market_value current_value]))
|
||||
cost_basis = parse_decimal(any_of(simplefin_holding, %w[cost_basis basis total_cost value]))
|
||||
|
||||
# Derive price from market_value when possible; otherwise fall back to any price field
|
||||
fallback_price = parse_decimal(any_of(simplefin_holding, %w[purchase_price price unit_price average_cost avg_cost]))
|
||||
|
||||
Reference in New Issue
Block a user