Skip to content

Open Source Wealth Management Software. Angular + NestJS + Prisma + Nx + TypeScript 🤍

Feature/handle currency pair inconsistency in yahoo finance service (#1069)

Thomas Kaul2388c494dfd6
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 92e5c25ec0..8586116b46 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Extended the investment timeline grouped by month
+### Changed
+
+- Handled an occasional currency pair inconsistency in the _Yahoo Finance_ service (`GBP=X` instead of `USDGBP=X`)
+
### Fixed
- Fixed the content height of the account detail dialog
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 b2c79284bb..34556b061f 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
@@ -37,10 +37,15 @@ export class YahooFinanceService implements DataProviderInterface {
}
public convertFromYahooFinanceSymbol(aYahooFinanceSymbol: string) {
- const symbol = aYahooFinanceSymbol.replace(
+ let symbol = aYahooFinanceSymbol.replace(
new RegExp(`-${this.baseCurrency}$`),
this.baseCurrency
);
+
+ if (symbol.includes('=X') && !symbol.includes(this.baseCurrency)) {
+ symbol = `${this.baseCurrency}${symbol}`;
+ }
+
return symbol.replace('=X', '');
}