|
|
@ -166,11 +166,42 @@ export class ManualService implements DataProviderInterface {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const symbolProfilesWithScraperConfigurationAndInstantMode =
|
|
|
|
|
|
|
|
symbolProfiles.filter(({ scraperConfiguration }) => {
|
|
|
|
|
|
|
|
return scraperConfiguration?.mode === 'instant';
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const scraperResultPromises =
|
|
|
|
|
|
|
|
symbolProfilesWithScraperConfigurationAndInstantMode.map(
|
|
|
|
|
|
|
|
async ({ scraperConfiguration, symbol }) => {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
const marketPrice = await this.scrape(scraperConfiguration);
|
|
|
|
|
|
|
|
return { marketPrice, symbol };
|
|
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
|
|
Logger.error(
|
|
|
|
|
|
|
|
`Could not get quote for ${symbol} (${this.getName()}): [${error.name}] ${error.message}`,
|
|
|
|
|
|
|
|
'ManualService'
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
return { symbol, marketPrice: undefined };
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Wait for all scraping requests to complete concurrently
|
|
|
|
|
|
|
|
const scraperResults = await Promise.all(scraperResultPromises);
|
|
|
|
|
|
|
|
|
|
|
|
for (const { currency, symbol } of symbolProfiles) {
|
|
|
|
for (const { currency, symbol } of symbolProfiles) {
|
|
|
|
let marketPrice =
|
|
|
|
let { marketPrice } =
|
|
|
|
|
|
|
|
scraperResults.find((result) => {
|
|
|
|
|
|
|
|
return result.symbol === symbol;
|
|
|
|
|
|
|
|
}) ?? {};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
marketPrice =
|
|
|
|
|
|
|
|
marketPrice ??
|
|
|
|
marketData.find((marketDataItem) => {
|
|
|
|
marketData.find((marketDataItem) => {
|
|
|
|
return marketDataItem.symbol === symbol;
|
|
|
|
return marketDataItem.symbol === symbol;
|
|
|
|
})?.marketPrice ?? 0;
|
|
|
|
})?.marketPrice ??
|
|
|
|
|
|
|
|
0;
|
|
|
|
|
|
|
|
|
|
|
|
response[symbol] = {
|
|
|
|
response[symbol] = {
|
|
|
|
currency,
|
|
|
|
currency,
|
|
|
|