|
|
|
@ -2,6 +2,7 @@ import { ConfigurationService } from '@ghostfolio/api/services/configuration/con
|
|
|
|
|
import { CryptocurrencyService } from '@ghostfolio/api/services/cryptocurrency/cryptocurrency.service';
|
|
|
|
|
import {
|
|
|
|
|
DataProviderInterface,
|
|
|
|
|
GetAssetProfileParams,
|
|
|
|
|
GetDividendsParams,
|
|
|
|
|
GetHistoricalParams,
|
|
|
|
|
GetQuotesParams,
|
|
|
|
@ -56,10 +57,9 @@ export class FinancialModelingPrepService implements DataProviderInterface {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async getAssetProfile({
|
|
|
|
|
requestTimeout = this.configurationService.get('REQUEST_TIMEOUT'),
|
|
|
|
|
symbol
|
|
|
|
|
}: {
|
|
|
|
|
symbol: string;
|
|
|
|
|
}): Promise<Partial<SymbolProfile>> {
|
|
|
|
|
}: GetAssetProfileParams): Promise<Partial<SymbolProfile>> {
|
|
|
|
|
const response: Partial<SymbolProfile> = {
|
|
|
|
|
symbol,
|
|
|
|
|
dataSource: this.getName()
|
|
|
|
@ -70,9 +70,7 @@ export class FinancialModelingPrepService implements DataProviderInterface {
|
|
|
|
|
const [quote] = await fetch(
|
|
|
|
|
`${this.URL}/quote/${symbol}?apikey=${this.apiKey}`,
|
|
|
|
|
{
|
|
|
|
|
signal: AbortSignal.timeout(
|
|
|
|
|
this.configurationService.get('REQUEST_TIMEOUT')
|
|
|
|
|
)
|
|
|
|
|
signal: AbortSignal.timeout(requestTimeout)
|
|
|
|
|
}
|
|
|
|
|
).then((res) => res.json());
|
|
|
|
|
|
|
|
|
@ -84,9 +82,7 @@ export class FinancialModelingPrepService implements DataProviderInterface {
|
|
|
|
|
const [assetProfile] = await fetch(
|
|
|
|
|
`${this.URL}/profile/${symbol}?apikey=${this.apiKey}`,
|
|
|
|
|
{
|
|
|
|
|
signal: AbortSignal.timeout(
|
|
|
|
|
this.configurationService.get('REQUEST_TIMEOUT')
|
|
|
|
|
)
|
|
|
|
|
signal: AbortSignal.timeout(requestTimeout)
|
|
|
|
|
}
|
|
|
|
|
).then((res) => res.json());
|
|
|
|
|
|
|
|
|
@ -100,9 +96,7 @@ export class FinancialModelingPrepService implements DataProviderInterface {
|
|
|
|
|
const etfCountryWeightings = await fetch(
|
|
|
|
|
`${this.URL}/etf-country-weightings/${symbol}?apikey=${this.apiKey}`,
|
|
|
|
|
{
|
|
|
|
|
signal: AbortSignal.timeout(
|
|
|
|
|
this.configurationService.get('REQUEST_TIMEOUT')
|
|
|
|
|
)
|
|
|
|
|
signal: AbortSignal.timeout(requestTimeout)
|
|
|
|
|
}
|
|
|
|
|
).then((res) => res.json());
|
|
|
|
|
|
|
|
|
@ -127,9 +121,7 @@ export class FinancialModelingPrepService implements DataProviderInterface {
|
|
|
|
|
const [etfInformation] = await fetch(
|
|
|
|
|
`${this.getUrl({ version: 4 })}/etf-info?symbol=${symbol}&apikey=${this.apiKey}`,
|
|
|
|
|
{
|
|
|
|
|
signal: AbortSignal.timeout(
|
|
|
|
|
this.configurationService.get('REQUEST_TIMEOUT')
|
|
|
|
|
)
|
|
|
|
|
signal: AbortSignal.timeout(requestTimeout)
|
|
|
|
|
}
|
|
|
|
|
).then((res) => res.json());
|
|
|
|
|
|
|
|
|
@ -140,9 +132,7 @@ export class FinancialModelingPrepService implements DataProviderInterface {
|
|
|
|
|
const [portfolioDate] = await fetch(
|
|
|
|
|
`${this.getUrl({ version: 4 })}/etf-holdings/portfolio-date?symbol=${symbol}&apikey=${this.apiKey}`,
|
|
|
|
|
{
|
|
|
|
|
signal: AbortSignal.timeout(
|
|
|
|
|
this.configurationService.get('REQUEST_TIMEOUT')
|
|
|
|
|
)
|
|
|
|
|
signal: AbortSignal.timeout(requestTimeout)
|
|
|
|
|
}
|
|
|
|
|
).then((res) => res.json());
|
|
|
|
|
|
|
|
|
@ -150,9 +140,7 @@ export class FinancialModelingPrepService implements DataProviderInterface {
|
|
|
|
|
const etfHoldings = await fetch(
|
|
|
|
|
`${this.getUrl({ version: 4 })}/etf-holdings?date=${portfolioDate.date}&symbol=${symbol}&apikey=${this.apiKey}`,
|
|
|
|
|
{
|
|
|
|
|
signal: AbortSignal.timeout(
|
|
|
|
|
this.configurationService.get('REQUEST_TIMEOUT')
|
|
|
|
|
)
|
|
|
|
|
signal: AbortSignal.timeout(requestTimeout)
|
|
|
|
|
}
|
|
|
|
|
).then((res) => res.json());
|
|
|
|
|
|
|
|
|
@ -170,9 +158,7 @@ export class FinancialModelingPrepService implements DataProviderInterface {
|
|
|
|
|
const etfSectorWeightings = await fetch(
|
|
|
|
|
`${this.URL}/etf-sector-weightings/${symbol}?apikey=${this.apiKey}`,
|
|
|
|
|
{
|
|
|
|
|
signal: AbortSignal.timeout(
|
|
|
|
|
this.configurationService.get('REQUEST_TIMEOUT')
|
|
|
|
|
)
|
|
|
|
|
signal: AbortSignal.timeout(requestTimeout)
|
|
|
|
|
}
|
|
|
|
|
).then((res) => res.json());
|
|
|
|
|
|
|
|
|
@ -211,7 +197,7 @@ export class FinancialModelingPrepService implements DataProviderInterface {
|
|
|
|
|
|
|
|
|
|
if (error?.name === 'AbortError') {
|
|
|
|
|
message = `RequestError: The operation to get the asset profile for ${symbol} was aborted because the request to the data provider took more than ${(
|
|
|
|
|
this.configurationService.get('REQUEST_TIMEOUT') / 1000
|
|
|
|
|
requestTimeout / 1000
|
|
|
|
|
).toFixed(3)} seconds`;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -376,7 +362,7 @@ export class FinancialModelingPrepService implements DataProviderInterface {
|
|
|
|
|
|
|
|
|
|
if (error?.name === 'AbortError') {
|
|
|
|
|
message = `RequestError: The operation to get the quotes was aborted because the request to the data provider took more than ${(
|
|
|
|
|
this.configurationService.get('REQUEST_TIMEOUT') / 1000
|
|
|
|
|
requestTimeout / 1000
|
|
|
|
|
).toFixed(3)} seconds`;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|