Browse Source
Feature/parallelize asset profile requests in get quotes functionality of Financial Modeling Prep service (#4569)
* Parallelize asset profile requests
* Update changelog
pull/4575/head^2
Thomas Kaul
1 week ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with
14 additions and
3 deletions
-
CHANGELOG.md
-
apps/api/src/services/data-provider/financial-modeling-prep/financial-modeling-prep.service.ts
|
|
@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 |
|
|
|
### Changed |
|
|
|
|
|
|
|
- Made the historical market data editor expandable in the admin control panel |
|
|
|
- Parallelized the requests in the get quotes functionality of the _Financial Modeling Prep_ service |
|
|
|
|
|
|
|
### Fixed |
|
|
|
|
|
|
|
|
|
@ -357,6 +357,10 @@ export class FinancialModelingPrepService implements DataProviderInterface { |
|
|
|
} |
|
|
|
|
|
|
|
try { |
|
|
|
const currencyBySymbolMap: { |
|
|
|
[symbol: string]: Pick<SymbolProfile, 'currency'>; |
|
|
|
} = {}; |
|
|
|
|
|
|
|
const quotes = await fetch( |
|
|
|
`${this.getUrl({ version: 'stable' })}/batch-quote-short?symbols=${symbols.join(',')}&apikey=${this.apiKey}`, |
|
|
|
{ |
|
|
@ -364,11 +368,17 @@ export class FinancialModelingPrepService implements DataProviderInterface { |
|
|
|
} |
|
|
|
).then((res) => res.json()); |
|
|
|
|
|
|
|
for (const { price, symbol } of quotes) { |
|
|
|
const { currency } = await this.getAssetProfile({ symbol }); |
|
|
|
await Promise.all( |
|
|
|
quotes.map(({ symbol }) => { |
|
|
|
return this.getAssetProfile({ symbol }).then(({ currency }) => { |
|
|
|
currencyBySymbolMap[symbol] = { currency }; |
|
|
|
}); |
|
|
|
}) |
|
|
|
); |
|
|
|
|
|
|
|
for (const { price, symbol } of quotes) { |
|
|
|
response[symbol] = { |
|
|
|
currency, |
|
|
|
currency: currencyBySymbolMap[symbol]?.currency, |
|
|
|
dataProviderInfo: this.getDataProviderInfo(), |
|
|
|
dataSource: DataSource.FINANCIAL_MODELING_PREP, |
|
|
|
marketPrice: price, |
|
|
|