|
@ -84,33 +84,42 @@ export class GhostfolioScraperApiService implements DataProviderInterface { |
|
|
public async getQuotes( |
|
|
public async getQuotes( |
|
|
aSymbols: string[] |
|
|
aSymbols: string[] |
|
|
): Promise<{ [symbol: string]: IDataProviderResponse }> { |
|
|
): Promise<{ [symbol: string]: IDataProviderResponse }> { |
|
|
|
|
|
const response: { [symbol: string]: IDataProviderResponse } = {}; |
|
|
|
|
|
|
|
|
if (aSymbols.length <= 0) { |
|
|
if (aSymbols.length <= 0) { |
|
|
return {}; |
|
|
return response; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
try { |
|
|
try { |
|
|
const [symbol] = aSymbols; |
|
|
const symbolProfiles = await this.symbolProfileService.getSymbolProfiles( |
|
|
const [symbolProfile] = await this.symbolProfileService.getSymbolProfiles( |
|
|
aSymbols |
|
|
[symbol] |
|
|
|
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
const { marketPrice } = await this.prismaService.marketData.findFirst({ |
|
|
const marketData = await this.prismaService.marketData.findMany({ |
|
|
|
|
|
distinct: ['symbol'], |
|
|
orderBy: { |
|
|
orderBy: { |
|
|
date: 'desc' |
|
|
date: 'desc' |
|
|
}, |
|
|
}, |
|
|
|
|
|
take: aSymbols.length, |
|
|
where: { |
|
|
where: { |
|
|
symbol |
|
|
symbol: { |
|
|
|
|
|
in: aSymbols |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
return { |
|
|
for (const symbolProfile of symbolProfiles) { |
|
|
[symbol]: { |
|
|
response[symbolProfile.symbol] = { |
|
|
marketPrice, |
|
|
currency: symbolProfile.currency, |
|
|
currency: symbolProfile?.currency, |
|
|
|
|
|
dataSource: this.getName(), |
|
|
dataSource: this.getName(), |
|
|
|
|
|
marketPrice: marketData.find((marketDataItem) => { |
|
|
|
|
|
return marketDataItem.symbol === symbolProfile.symbol; |
|
|
|
|
|
}).marketPrice, |
|
|
marketState: MarketState.delayed |
|
|
marketState: MarketState.delayed |
|
|
} |
|
|
|
|
|
}; |
|
|
}; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return response; |
|
|
} catch (error) { |
|
|
} catch (error) { |
|
|
Logger.error(error, 'GhostfolioScraperApiService'); |
|
|
Logger.error(error, 'GhostfolioScraperApiService'); |
|
|
} |
|
|
} |
|
|