|
@ -24,6 +24,7 @@ import { |
|
|
import { Injectable, Logger } from '@nestjs/common'; |
|
|
import { Injectable, Logger } from '@nestjs/common'; |
|
|
import { DataSource, SymbolProfile } from '@prisma/client'; |
|
|
import { DataSource, SymbolProfile } from '@prisma/client'; |
|
|
import { addDays, format, isSameDay } from 'date-fns'; |
|
|
import { addDays, format, isSameDay } from 'date-fns'; |
|
|
|
|
|
import { uniqBy } from 'lodash'; |
|
|
import YahooFinance from 'yahoo-finance2'; |
|
|
import YahooFinance from 'yahoo-finance2'; |
|
|
import { ChartResultArray } from 'yahoo-finance2/esm/src/modules/chart'; |
|
|
import { ChartResultArray } from 'yahoo-finance2/esm/src/modules/chart'; |
|
|
import { |
|
|
import { |
|
@ -290,7 +291,9 @@ export class YahooFinanceService implements DataProviderInterface { |
|
|
|
|
|
|
|
|
try { |
|
|
try { |
|
|
marketData = await this.yahooFinance.quote( |
|
|
marketData = await this.yahooFinance.quote( |
|
|
quotes.map(({ symbol }) => { |
|
|
uniqBy(quotes, ({ symbol }) => { |
|
|
|
|
|
return symbol; |
|
|
|
|
|
}).map(({ symbol }) => { |
|
|
return symbol; |
|
|
return symbol; |
|
|
}) |
|
|
}) |
|
|
); |
|
|
); |
|
@ -300,35 +303,35 @@ export class YahooFinanceService implements DataProviderInterface { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
for (const marketDataItem of marketData) { |
|
|
for (const { |
|
|
const quote = quotes.find((currentQuote) => { |
|
|
currency, |
|
|
return currentQuote.symbol === marketDataItem.symbol; |
|
|
longName, |
|
|
}); |
|
|
quoteType, |
|
|
|
|
|
shortName, |
|
|
const symbol = |
|
|
symbol |
|
|
this.yahooFinanceDataEnhancerService.convertFromYahooFinanceSymbol( |
|
|
} of marketData) { |
|
|
marketDataItem.symbol |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
const { assetClass, assetSubClass } = |
|
|
const { assetClass, assetSubClass } = |
|
|
this.yahooFinanceDataEnhancerService.parseAssetClass({ |
|
|
this.yahooFinanceDataEnhancerService.parseAssetClass({ |
|
|
quoteType: quote.quoteType, |
|
|
quoteType, |
|
|
shortName: quote.shortname |
|
|
shortName |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
items.push({ |
|
|
items.push({ |
|
|
assetClass, |
|
|
assetClass, |
|
|
assetSubClass, |
|
|
assetSubClass, |
|
|
symbol, |
|
|
currency, |
|
|
currency: marketDataItem.currency, |
|
|
|
|
|
dataProviderInfo: this.getDataProviderInfo(), |
|
|
dataProviderInfo: this.getDataProviderInfo(), |
|
|
dataSource: this.getName(), |
|
|
dataSource: this.getName(), |
|
|
name: this.yahooFinanceDataEnhancerService.formatName({ |
|
|
name: this.yahooFinanceDataEnhancerService.formatName({ |
|
|
longName: quote.longname, |
|
|
longName, |
|
|
quoteType: quote.quoteType, |
|
|
quoteType, |
|
|
shortName: quote.shortname, |
|
|
shortName, |
|
|
symbol: quote.symbol |
|
|
symbol |
|
|
}) |
|
|
}), |
|
|
|
|
|
symbol: |
|
|
|
|
|
this.yahooFinanceDataEnhancerService.convertFromYahooFinanceSymbol( |
|
|
|
|
|
symbol |
|
|
|
|
|
) |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
} catch (error) { |
|
|
} catch (error) { |
|
|