Fix: Incorrect Currency Assignment for Stock Prices (#1623) #1798
Reference in New Issue
Block a user
Delete Branch "fix/stock-currency-assignment"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes #1623
Issue Description
Stocks from non-USD markets (such as Saudi and Indian stock exchanges) were incorrectly assigned USD as their currency, which distorted portfolio calculations. The issue was due to the application extracting the currency from the
pricesarray instead of the main response object.Root Cause
The application was fetching stock price data from Synth Finance's "Open/Close Prices" API, but it incorrectly attempted to extract the currency from within each price entry under
prices[], even though the API returns the correct currency in the main object undercurrency. This caused the system to default to "USD" when currency information was missing at the price level.Solution
body.dig("currency")) instead of from the price entry.Impact
✅ Fixes incorrect currency assignment for stock prices in non-USD markets.
✅ Prevents miscalculations of portfolio value due to incorrect currency conversion.
✅ Ensures compatibility with Synth Finance’s API response structure.
Testing
Awesome, fix makes sense! Thanks for the explanation and testing.