From ca95ea3bc42ce6d4c5d73e46a686e585d0c40539 Mon Sep 17 00:00:00 2001 From: qvanphong Date: Mon, 19 May 2025 23:03:42 +0700 Subject: [PATCH] fix: should not validate result when symbol has market/index suffix since they not have currency attribute --- .../yahoo-finance/yahoo-finance.service.ts | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) 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 ee07bec7a..c3924ad90 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 @@ -32,7 +32,10 @@ import { HistoricalDividendsResult, HistoricalHistoryResult } from 'yahoo-finance2/esm/src/modules/historical'; -import { Quote } from 'yahoo-finance2/esm/src/modules/quote'; +import { + Quote, + QuoteOptionsWithReturnArray +} from 'yahoo-finance2/esm/src/modules/quote'; import { SearchQuoteNonYahoo } from 'yahoo-finance2/script/src/modules/search'; @Injectable() @@ -201,7 +204,13 @@ export class YahooFinanceService implements DataProviderInterface { >[] = []; try { - quotes = await this.yahooFinance.quote(yahooFinanceSymbols); + quotes = await this.yahooFinance.quote( + yahooFinanceSymbols, + {} as QuoteOptionsWithReturnArray, + { + validateResult: determineStockCurrency(symbols[0]) == null + } as ModuleOptionsWithValidateTrue + ); } catch (error) { Logger.error(error, 'YahooFinanceService'); @@ -294,7 +303,11 @@ export class YahooFinanceService implements DataProviderInterface { const marketData = await this.yahooFinance.quote( quotes.map(({ symbol }) => { return symbol; - }) + }), + {} as QuoteOptionsWithReturnArray, + { + validateResult: determineStockCurrency(quotes[0].symbol) == null + } as ModuleOptionsWithValidateTrue ); for (const marketDataItem of marketData) {