|
|
|
@ -102,6 +102,10 @@ export class FinancialModelingPrepService implements DataProviderInterface { |
|
|
|
} |
|
|
|
).then((res) => res.json()); |
|
|
|
|
|
|
|
if (!assetProfile) { |
|
|
|
throw new Error(`${symbol} not found`); |
|
|
|
} |
|
|
|
|
|
|
|
const { assetClass, assetSubClass } = |
|
|
|
this.parseAssetClass(assetProfile); |
|
|
|
|
|
|
|
@ -373,26 +377,42 @@ export class FinancialModelingPrepService implements DataProviderInterface { |
|
|
|
{ |
|
|
|
signal: AbortSignal.timeout(requestTimeout) |
|
|
|
} |
|
|
|
).then((res) => res.json()) |
|
|
|
).then( |
|
|
|
(res) => res.json() as unknown as { price: number; symbol: string }[] |
|
|
|
) |
|
|
|
]); |
|
|
|
|
|
|
|
if (assetProfileResolutions.length === symbols.length) { |
|
|
|
for (const { currency, symbolTarget } of assetProfileResolutions) { |
|
|
|
currencyBySymbolMap[symbolTarget] = { currency }; |
|
|
|
for (const { currency, symbolTarget } of assetProfileResolutions) { |
|
|
|
currencyBySymbolMap[symbolTarget] = { currency }; |
|
|
|
} |
|
|
|
|
|
|
|
const resolvedSymbols = assetProfileResolutions.map( |
|
|
|
({ symbolTarget }) => { |
|
|
|
return symbolTarget; |
|
|
|
} |
|
|
|
} else { |
|
|
|
); |
|
|
|
|
|
|
|
const symbolsToFetch = quotes |
|
|
|
.map(({ symbol }) => { |
|
|
|
return symbol; |
|
|
|
}) |
|
|
|
.filter((symbol) => { |
|
|
|
return !resolvedSymbols.includes(symbol); |
|
|
|
}); |
|
|
|
|
|
|
|
if (symbolsToFetch.length > 0) { |
|
|
|
await Promise.all( |
|
|
|
quotes.map(({ symbol }) => { |
|
|
|
return this.getAssetProfile({ |
|
|
|
symbolsToFetch.map(async (symbol) => { |
|
|
|
const assetProfile = await this.getAssetProfile({ |
|
|
|
requestTimeout, |
|
|
|
symbol |
|
|
|
}).then((assetProfile) => { |
|
|
|
if (assetProfile?.currency) { |
|
|
|
currencyBySymbolMap[symbol] = { |
|
|
|
currency: assetProfile.currency |
|
|
|
}; |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
if (assetProfile?.currency) { |
|
|
|
currencyBySymbolMap[symbol] = { |
|
|
|
currency: assetProfile.currency |
|
|
|
}; |
|
|
|
} |
|
|
|
}) |
|
|
|
); |
|
|
|
} |
|
|
|
@ -438,6 +458,7 @@ export class FinancialModelingPrepService implements DataProviderInterface { |
|
|
|
} |
|
|
|
|
|
|
|
public async search({ |
|
|
|
includeIndices = false, |
|
|
|
query, |
|
|
|
requestTimeout = this.configurationService.get('REQUEST_TIMEOUT') |
|
|
|
}: GetSearchParams): Promise<LookupResponse> { |
|
|
|
@ -484,17 +505,25 @@ export class FinancialModelingPrepService implements DataProviderInterface { |
|
|
|
} |
|
|
|
).then((res) => res.json()); |
|
|
|
|
|
|
|
items = result.map(({ currency, name, symbol }) => { |
|
|
|
return { |
|
|
|
currency, |
|
|
|
symbol, |
|
|
|
assetClass: undefined, // TODO
|
|
|
|
assetSubClass: undefined, // TODO
|
|
|
|
dataProviderInfo: this.getDataProviderInfo(), |
|
|
|
dataSource: this.getName(), |
|
|
|
name: this.formatName({ name }) |
|
|
|
}; |
|
|
|
}); |
|
|
|
items = result |
|
|
|
.filter(({ symbol }) => { |
|
|
|
if (includeIndices === false && symbol.startsWith('^')) { |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
return true; |
|
|
|
}) |
|
|
|
.map(({ currency, name, symbol }) => { |
|
|
|
return { |
|
|
|
currency, |
|
|
|
symbol, |
|
|
|
assetClass: undefined, // TODO
|
|
|
|
assetSubClass: undefined, // TODO
|
|
|
|
dataProviderInfo: this.getDataProviderInfo(), |
|
|
|
dataSource: this.getName(), |
|
|
|
name: this.formatName({ name }) |
|
|
|
}; |
|
|
|
}); |
|
|
|
} |
|
|
|
} catch (error) { |
|
|
|
let message = error; |
|
|
|
|