|
|
|
@ -143,8 +143,7 @@ export class YahooFinanceService implements DataProviderInterface { |
|
|
|
[date: string]: DataProviderHistoricalResponse; |
|
|
|
}> { |
|
|
|
try { |
|
|
|
const historicalResult = this.convertToHistoricalResult( |
|
|
|
await this.yahooFinance.chart( |
|
|
|
const chartResult = await this.yahooFinance.chart( |
|
|
|
this.yahooFinanceDataEnhancerService.convertToYahooFinanceSymbol( |
|
|
|
symbol |
|
|
|
), |
|
|
|
@ -156,17 +155,27 @@ export class YahooFinanceService implements DataProviderInterface { |
|
|
|
DATE_FORMAT |
|
|
|
) |
|
|
|
} |
|
|
|
) |
|
|
|
); |
|
|
|
|
|
|
|
const historicalResult = this.convertToHistoricalResult(chartResult); |
|
|
|
|
|
|
|
const response: { |
|
|
|
[date: string]: DataProviderHistoricalResponse; |
|
|
|
} = {}; |
|
|
|
|
|
|
|
for (const historicalItem of historicalResult) { |
|
|
|
response[format(historicalItem.date, DATE_FORMAT)] = { |
|
|
|
marketPrice: historicalItem.close |
|
|
|
}; |
|
|
|
for (const { close, date } of historicalResult) { |
|
|
|
// The chart endpoint can omit the close price of a historical item, for
|
|
|
|
// example if the daily data of an exchange has not been consolidated yet.
|
|
|
|
// In this case, the market price of the corresponding quote is taken.
|
|
|
|
const marketPrice = |
|
|
|
close ?? |
|
|
|
(isSameDay(date, chartResult.meta.regularMarketTime) |
|
|
|
? chartResult.meta.regularMarketPrice |
|
|
|
: undefined); |
|
|
|
|
|
|
|
if (marketPrice) { |
|
|
|
response[format(date, DATE_FORMAT)] = { marketPrice }; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return response; |
|
|
|
|