diff --git a/CHANGELOG.md b/CHANGELOG.md index 67a88add2..5a9103aed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## Unreleased + +### Fixed + +- Fixed an issue with the currency inconsistency in the _Yahoo Finance_ service (convert from `USX` to `USD`) + ## 1.172.0 - 23.07.2022 ### Added diff --git a/apps/api/src/services/data-provider/yahoo-finance/yahoo-finance.service.ts b/apps/api/src/services/data-provider/yahoo-finance/yahoo-finance.service.ts index 34556b061..bddd529c2 100644 --- a/apps/api/src/services/data-provider/yahoo-finance/yahoo-finance.service.ts +++ b/apps/api/src/services/data-provider/yahoo-finance/yahoo-finance.service.ts @@ -266,6 +266,16 @@ export class YahooFinanceService implements DataProviderInterface { } } + if (yahooFinanceSymbols.includes('USDUSX=X')) { + // Convert USD to USX (cent) + response['USDUSX'] = { + currency: 'USX', + dataSource: this.getName(), + marketPrice: new Big(1).mul(100).toNumber(), + marketState: 'open' + }; + } + return response; } catch (error) { Logger.error(error, 'YahooFinanceService'); diff --git a/apps/api/src/services/exchange-rate-data.service.ts b/apps/api/src/services/exchange-rate-data.service.ts index eb4c84599..25ccc73b8 100644 --- a/apps/api/src/services/exchange-rate-data.service.ts +++ b/apps/api/src/services/exchange-rate-data.service.ts @@ -122,15 +122,6 @@ export class ExchangeRateDataService { return 0; } - const hasNaN = Object.values(this.exchangeRates).some((exchangeRate) => { - return isNaN(exchangeRate); - }); - - if (hasNaN) { - // Reinitialize if data is not loaded correctly - this.initialize(); - } - let factor = 1; if (aFromCurrency !== aToCurrency) {