From 266c0a9a2c0a006212f128e8dd267cbb860db496 Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Sun, 18 Feb 2024 14:14:25 +0100 Subject: [PATCH] Feature/eliminate search request in get quotes of eod service (#3019) * Eliminate search request to get quotes * Update changelog --- CHANGELOG.md | 1 + .../eod-historical-data.service.ts | 27 +++++++++---------- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b3d9f3513..5f75b1e55 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Improved the usability of the holdings table - Refactored the query to filter activities of excluded accounts +- Eliminated the search request to get quotes in the _EOD Historical Data_ service - Improved the language localization for German (`de`) - Upgraded `ng-extract-i18n-merge` from version `2.9.1` to `2.10.0` 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 3d3bf39e5..798973be6 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,6 +11,7 @@ import { IDataProviderHistoricalResponse, IDataProviderResponse } from '@ghostfolio/api/services/interfaces/interfaces'; +import { SymbolProfileService } from '@ghostfolio/api/services/symbol-profile/symbol-profile.service'; import { DEFAULT_CURRENCY, REPLACE_NAME_PARTS @@ -35,7 +36,8 @@ export class EodHistoricalDataService implements DataProviderInterface { private readonly URL = 'https://eodhistoricaldata.com/api'; public constructor( - private readonly configurationService: ConfigurationService + private readonly configurationService: ConfigurationService, + private readonly symbolProfileService: SymbolProfileService ) { this.apiKey = this.configurationService.get('API_KEY_EOD_HISTORICAL_DATA'); } @@ -228,27 +230,22 @@ export class EodHistoricalDataService implements DataProviderInterface { ? [realTimeResponse] : realTimeResponse; - const searchResponse = await Promise.all( - eodHistoricalDataSymbols - .filter((symbol) => { - return !symbol.endsWith('.FOREX'); - }) - .map((symbol) => { - return this.search({ query: symbol }); - }) + const symbolProfiles = await this.symbolProfileService.getSymbolProfiles( + symbols.map((symbol) => { + return { + symbol, + dataSource: this.getName() + }; + }) ); - const lookupItems = searchResponse.flat().map(({ items }) => { - return items[0]; - }); - response = quotes.reduce( ( result: { [symbol: string]: IDataProviderResponse }, { close, code, timestamp } ) => { - const currency = lookupItems.find((lookupItem) => { - return lookupItem.symbol === code; + const currency = symbolProfiles.find(({ symbol }) => { + return symbol === code; })?.currency; if (isNumber(close)) {