Browse Source

fix: should not validate result when symbol has market/index suffix since they not have currency attribute

pull/4725/head
qvanphong 3 months ago
parent
commit
ca95ea3bc4
  1. 19
      apps/api/src/services/data-provider/yahoo-finance/yahoo-finance.service.ts

19
apps/api/src/services/data-provider/yahoo-finance/yahoo-finance.service.ts

@ -32,7 +32,10 @@ import {
HistoricalDividendsResult, HistoricalDividendsResult,
HistoricalHistoryResult HistoricalHistoryResult
} from 'yahoo-finance2/esm/src/modules/historical'; } 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'; import { SearchQuoteNonYahoo } from 'yahoo-finance2/script/src/modules/search';
@Injectable() @Injectable()
@ -201,7 +204,13 @@ export class YahooFinanceService implements DataProviderInterface {
>[] = []; >[] = [];
try { try {
quotes = await this.yahooFinance.quote(yahooFinanceSymbols); quotes = await this.yahooFinance.quote(
yahooFinanceSymbols,
{} as QuoteOptionsWithReturnArray,
{
validateResult: determineStockCurrency(symbols[0]) == null
} as ModuleOptionsWithValidateTrue
);
} catch (error) { } catch (error) {
Logger.error(error, 'YahooFinanceService'); Logger.error(error, 'YahooFinanceService');
@ -294,7 +303,11 @@ export class YahooFinanceService implements DataProviderInterface {
const marketData = await this.yahooFinance.quote( const marketData = await this.yahooFinance.quote(
quotes.map(({ symbol }) => { quotes.map(({ symbol }) => {
return symbol; return symbol;
}) }),
{} as QuoteOptionsWithReturnArray,
{
validateResult: determineStockCurrency(quotes[0].symbol) == null
} as ModuleOptionsWithValidateTrue
); );
for (const marketDataItem of marketData) { for (const marketDataItem of marketData) {

Loading…
Cancel
Save