#236 fixed change rate calc bug

This commit is contained in:
amueller 2024-10-17 17:22:46 +02:00
parent d80f4872dc
commit 5f27218dcb

View File

@ -108,12 +108,13 @@ func FetchMarketsDataFromYahoo(marketRequests []MarketRequest) (Markets, error)
if marketRequests[i].Currency != "" { if marketRequests[i].Currency != "" {
exchangeRate, err := FetchUSDExchangeRate(marketRequests[i].Currency) exchangeRate, err := FetchUSDExchangeRate(marketRequests[i].Currency)
if err != nil { if err != nil {
slog.Error("Failed to fetch USD/EUR exchange rate", "error", err) slog.Error("Failed to fetch USD exchange rate", "error", err)
continue continue
} }
if response.Chart.Result[0].Meta.Currency == "USD" { if response.Chart.Result[0].Meta.Currency == "USD" {
response.Chart.Result[0].Meta.RegularMarketPrice *= exchangeRate response.Chart.Result[0].Meta.RegularMarketPrice *= exchangeRate
previous *= exchangeRate
currency = currencyToSymbol[marketRequests[i].Currency] currency = currencyToSymbol[marketRequests[i].Currency]
} }
} }