diff --git a/CHANGELOG.md b/CHANGELOG.md index 9bb08f79c..50b40d4bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added an indicator for excluded accounts in the accounts table - Added a blog post: _Black Friday 2022_ +### Fixed + +- Fixed an issue with the currency inconsistency in the _Yahoo Finance_ service (convert from `ZAc` to `ZAR`) + ## 1.212.0 - 11.11.2022 ### Changed 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 64d318ac8..01dcf79a1 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 @@ -206,6 +206,9 @@ export class YahooFinanceService implements DataProviderInterface { } else if (symbol === `${this.baseCurrency}ILA`) { // Convert ILS to ILA marketPrice = new Big(marketPrice).mul(100).toNumber(); + } else if (symbol === `${this.baseCurrency}ZAc`) { + // Convert ZAR to ZAc (cents) + marketPrice = new Big(marketPrice).mul(100).toNumber(); } response[symbol][format(historicalItem.date, DATE_FORMAT)] = { @@ -287,6 +290,18 @@ export class YahooFinanceService implements DataProviderInterface { .mul(100) .toNumber() }; + } else if ( + symbol === `${this.baseCurrency}ZAR` && + yahooFinanceSymbols.includes(`${this.baseCurrency}ZAc=X`) + ) { + // Convert ZAR to ZAc (cents) + response[`${this.baseCurrency}ZAc`] = { + ...response[symbol], + currency: 'ZAc', + marketPrice: new Big(response[symbol].marketPrice) + .mul(100) + .toNumber() + }; } }