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

* Handle occasional currency pair inconsistency: GBP=X instead of USDGBP=X

* Update changelog
This commit is contained in:
Thomas Kaul 2022-07-10 22:24:27 +02:00 committed by GitHub
parent d71ab10eed
commit 2388c494df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View File

@ -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 - 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
- Fixed the content height of the account detail dialog - Fixed the content height of the account detail dialog

View File

@ -37,10 +37,15 @@ export class YahooFinanceService implements DataProviderInterface {
} }
public convertFromYahooFinanceSymbol(aYahooFinanceSymbol: string) { public convertFromYahooFinanceSymbol(aYahooFinanceSymbol: string) {
const symbol = aYahooFinanceSymbol.replace( let symbol = aYahooFinanceSymbol.replace(
new RegExp(`-${this.baseCurrency}$`), new RegExp(`-${this.baseCurrency}$`),
this.baseCurrency this.baseCurrency
); );
if (symbol.includes('=X') && !symbol.includes(this.baseCurrency)) {
symbol = `${this.baseCurrency}${symbol}`;
}
return symbol.replace('=X', ''); return symbol.replace('=X', '');
} }