diff --git a/CHANGELOG.md b/CHANGELOG.md index 6752784fa..9b16b7b8f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +- Formatted the name in the _EOD Historical Data_ service - Improved the language localization for German (`de`) ### Fixed diff --git a/apps/api/src/services/data-provider/data-enhancer/yahoo-finance/yahoo-finance.service.ts b/apps/api/src/services/data-provider/data-enhancer/yahoo-finance/yahoo-finance.service.ts index 930e0c7f1..f2a136151 100644 --- a/apps/api/src/services/data-provider/data-enhancer/yahoo-finance/yahoo-finance.service.ts +++ b/apps/api/src/services/data-provider/data-enhancer/yahoo-finance/yahoo-finance.service.ts @@ -1,7 +1,11 @@ import { ConfigurationService } from '@ghostfolio/api/services/configuration/configuration.service'; import { CryptocurrencyService } from '@ghostfolio/api/services/cryptocurrency/cryptocurrency.service'; import { DataEnhancerInterface } from '@ghostfolio/api/services/data-provider/interfaces/data-enhancer.interface'; -import { DEFAULT_CURRENCY, UNKNOWN_KEY } from '@ghostfolio/common/config'; +import { + DEFAULT_CURRENCY, + REPLACE_NAME_PARTS, + UNKNOWN_KEY +} from '@ghostfolio/common/config'; import { isCurrency } from '@ghostfolio/common/helper'; import { Injectable, Logger } from '@nestjs/common'; import { @@ -137,18 +141,11 @@ export class YahooFinanceDataEnhancerService implements DataEnhancerInterface { if (name) { name = name.replace('&', '&'); - name = name.replace('Amundi Index Solutions - ', ''); - name = name.replace('iShares ETF (CH) - ', ''); - name = name.replace('iShares III Public Limited Company - ', ''); - name = name.replace('iShares V PLC - ', ''); - name = name.replace('iShares VI Public Limited Company - ', ''); - name = name.replace('iShares VII PLC - ', ''); - name = name.replace('Multi Units Luxembourg - ', ''); - name = name.replace('VanEck ETFs N.V. - ', ''); - name = name.replace('Vaneck Vectors Ucits Etfs Plc - ', ''); - name = name.replace('Vanguard Funds Public Limited Company - ', ''); - name = name.replace('Vanguard Index Funds - ', ''); - name = name.replace('Xtrackers (IE) Plc - ', ''); + for (const part of REPLACE_NAME_PARTS) { + name = name.replace(part, ''); + } + + name = name.trim(); } if (quoteType === 'FUTURE') { diff --git a/apps/api/src/services/data-provider/eod-historical-data/eod-historical-data.service.ts b/apps/api/src/services/data-provider/eod-historical-data/eod-historical-data.service.ts index 39457320f..bcff104c0 100644 --- a/apps/api/src/services/data-provider/eod-historical-data/eod-historical-data.service.ts +++ b/apps/api/src/services/data-provider/eod-historical-data/eod-historical-data.service.ts @@ -11,7 +11,10 @@ import { IDataProviderHistoricalResponse, IDataProviderResponse } from '@ghostfolio/api/services/interfaces/interfaces'; -import { DEFAULT_CURRENCY } from '@ghostfolio/common/config'; +import { + DEFAULT_CURRENCY, + REPLACE_NAME_PARTS +} from '@ghostfolio/common/config'; import { DATE_FORMAT, isCurrency } from '@ghostfolio/common/helper'; import { Injectable, Logger } from '@nestjs/common'; import { @@ -362,6 +365,18 @@ export class EodHistoricalDataService implements DataProviderInterface { return aSymbol; } + private formatName({ name }: { name: string }) { + if (name) { + for (const part of REPLACE_NAME_PARTS) { + name = name.replace(part, ''); + } + + name = name.trim(); + } + + return name; + } + private async getSearchResult(aQuery: string): Promise< (LookupItem & { assetClass: AssetClass; @@ -397,9 +412,9 @@ export class EodHistoricalDataService implements DataProviderInterface { assetClass, assetSubClass, isin, - name, currency: this.convertCurrency(Currency), dataSource: this.getName(), + name: this.formatName({ name }), symbol: `${Code}.${Exchange}` }; } diff --git a/libs/common/src/lib/config.ts b/libs/common/src/lib/config.ts index df89ae9e9..b93d22f45 100644 --- a/libs/common/src/lib/config.ts +++ b/libs/common/src/lib/config.ts @@ -112,6 +112,21 @@ export const QUEUE_JOB_STATUS_LIST = [ 'waiting' ]; +export const REPLACE_NAME_PARTS = [ + 'Amundi Index Solutions -', + 'iShares ETF (CH) -', + 'iShares III Public Limited Company -', + 'iShares V PLC -', + 'iShares VI Public Limited Company -', + 'iShares VII PLC -', + 'Multi Units Luxembourg -', + 'VanEck ETFs N.V. -', + 'Vaneck Vectors Ucits Etfs Plc -', + 'Vanguard Funds Public Limited Company -', + 'Vanguard Index Funds -', + 'Xtrackers (IE) Plc -' +]; + export const SUPPORTED_LANGUAGE_CODES = [ 'de', 'en',