|
|
@ -132,41 +132,34 @@ export class FinancialModelingPrepService implements DataProviderInterface { |
|
|
|
} |
|
|
|
); |
|
|
|
|
|
|
|
const [etfInformation] = await fetch( |
|
|
|
`${this.getUrl({ version: 4 })}/etf-info?symbol=${symbol}&apikey=${this.apiKey}`, |
|
|
|
const etfHoldings = await fetch( |
|
|
|
`${this.getUrl({ version: 'stable' })}/etf/holdings?symbol=${symbol}&apikey=${this.apiKey}`, |
|
|
|
{ |
|
|
|
signal: AbortSignal.timeout(requestTimeout) |
|
|
|
} |
|
|
|
).then((res) => res.json()); |
|
|
|
|
|
|
|
if (etfInformation.website) { |
|
|
|
response.url = etfInformation.website; |
|
|
|
} |
|
|
|
const sortedTopHoldings = etfHoldings |
|
|
|
.sort((a, b) => { |
|
|
|
return b.weightPercentage - a.weightPercentage; |
|
|
|
}) |
|
|
|
.slice(0, 10); |
|
|
|
|
|
|
|
response.holdings = sortedTopHoldings.map( |
|
|
|
({ name, weightPercentage }) => { |
|
|
|
return { name, weight: weightPercentage / 100 }; |
|
|
|
} |
|
|
|
); |
|
|
|
|
|
|
|
const [portfolioDate] = await fetch( |
|
|
|
`${this.getUrl({ version: 4 })}/etf-holdings/portfolio-date?symbol=${symbol}&apikey=${this.apiKey}`, |
|
|
|
const [etfInformation] = await fetch( |
|
|
|
`${this.getUrl({ version: 'stable' })}/etf/info?symbol=${symbol}&apikey=${this.apiKey}`, |
|
|
|
{ |
|
|
|
signal: AbortSignal.timeout(requestTimeout) |
|
|
|
} |
|
|
|
).then((res) => res.json()); |
|
|
|
|
|
|
|
if (portfolioDate) { |
|
|
|
const etfHoldings = await fetch( |
|
|
|
`${this.getUrl({ version: 4 })}/etf-holdings?date=${portfolioDate.date}&symbol=${symbol}&apikey=${this.apiKey}`, |
|
|
|
{ |
|
|
|
signal: AbortSignal.timeout(requestTimeout) |
|
|
|
} |
|
|
|
).then((res) => res.json()); |
|
|
|
|
|
|
|
const sortedTopHoldings = etfHoldings |
|
|
|
.sort((a, b) => { |
|
|
|
return b.pctVal - a.pctVal; |
|
|
|
}) |
|
|
|
.slice(0, 10); |
|
|
|
|
|
|
|
response.holdings = sortedTopHoldings.map(({ name, pctVal }) => { |
|
|
|
return { name, weight: pctVal / 100 }; |
|
|
|
}); |
|
|
|
if (etfInformation.website) { |
|
|
|
response.url = etfInformation.website; |
|
|
|
} |
|
|
|
|
|
|
|
const etfSectorWeightings = await fetch( |
|
|
|