|
|
@ -591,28 +591,17 @@ export class FinancialModelingPrepService |
|
|
}; |
|
|
}; |
|
|
}); |
|
|
}); |
|
|
} else { |
|
|
} else { |
|
|
const queryParams = new URLSearchParams({ |
|
|
|
|
|
query, |
|
|
|
|
|
apikey: this.apiKey |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
const [nameResults, symbolResults] = await Promise.all([ |
|
|
const [nameResults, symbolResults] = await Promise.all([ |
|
|
this.fetchService |
|
|
this.getSearchResults({ |
|
|
.fetch( |
|
|
query, |
|
|
`${this.getUrl({ version: 'stable' })}/search-name?${queryParams.toString()}`, |
|
|
requestTimeout, |
|
|
{ |
|
|
endpoint: 'search-name' |
|
|
signal: AbortSignal.timeout(requestTimeout) |
|
|
}), |
|
|
} |
|
|
this.getSearchResults({ |
|
|
) |
|
|
query, |
|
|
.then((res) => res.json()), |
|
|
requestTimeout, |
|
|
this.fetchService |
|
|
endpoint: 'search-symbol' |
|
|
.fetch( |
|
|
}) |
|
|
`${this.getUrl({ version: 'stable' })}/search-symbol?${queryParams.toString()}`, |
|
|
|
|
|
{ |
|
|
|
|
|
signal: AbortSignal.timeout(requestTimeout) |
|
|
|
|
|
} |
|
|
|
|
|
) |
|
|
|
|
|
.then((res) => res.json()) |
|
|
|
|
|
]); |
|
|
]); |
|
|
|
|
|
|
|
|
const result = uniqBy( |
|
|
const result = uniqBy( |
|
|
@ -682,20 +671,12 @@ export class FinancialModelingPrepService |
|
|
requestTimeout: number; |
|
|
requestTimeout: number; |
|
|
symbol: string; |
|
|
symbol: string; |
|
|
}): Promise<Pick<SymbolProfile, 'currency' | 'name'>> { |
|
|
}): Promise<Pick<SymbolProfile, 'currency' | 'name'>> { |
|
|
const queryParams = new URLSearchParams({ |
|
|
const results = await this.getSearchResults({ |
|
|
apikey: this.apiKey, |
|
|
requestTimeout, |
|
|
|
|
|
endpoint: 'search-symbol', |
|
|
query: symbol |
|
|
query: symbol |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
const results = await this.fetchService |
|
|
|
|
|
.fetch( |
|
|
|
|
|
`${this.getUrl({ version: 'stable' })}/search-symbol?${queryParams.toString()}`, |
|
|
|
|
|
{ |
|
|
|
|
|
signal: AbortSignal.timeout(requestTimeout) |
|
|
|
|
|
} |
|
|
|
|
|
) |
|
|
|
|
|
.then((res) => res.json()); |
|
|
|
|
|
|
|
|
|
|
|
const index = results?.find(({ exchange, symbol: symbolOfResult }) => { |
|
|
const index = results?.find(({ exchange, symbol: symbolOfResult }) => { |
|
|
return exchange === 'INDEX' && symbolOfResult === symbol; |
|
|
return exchange === 'INDEX' && symbolOfResult === symbol; |
|
|
}); |
|
|
}); |
|
|
@ -710,6 +691,30 @@ export class FinancialModelingPrepService |
|
|
}; |
|
|
}; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private async getSearchResults({ |
|
|
|
|
|
endpoint, |
|
|
|
|
|
query, |
|
|
|
|
|
requestTimeout |
|
|
|
|
|
}: { |
|
|
|
|
|
endpoint: 'search-name' | 'search-symbol'; |
|
|
|
|
|
query: string; |
|
|
|
|
|
requestTimeout: number; |
|
|
|
|
|
}) { |
|
|
|
|
|
const queryParams = new URLSearchParams({ |
|
|
|
|
|
query, |
|
|
|
|
|
apikey: this.apiKey |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
return this.fetchService |
|
|
|
|
|
.fetch( |
|
|
|
|
|
`${this.getUrl({ version: 'stable' })}/${endpoint}?${queryParams.toString()}`, |
|
|
|
|
|
{ |
|
|
|
|
|
signal: AbortSignal.timeout(requestTimeout) |
|
|
|
|
|
} |
|
|
|
|
|
) |
|
|
|
|
|
.then((res) => res.json()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
private getUrl({ version }: { version: number | 'stable' }) { |
|
|
private getUrl({ version }: { version: number | 'stable' }) { |
|
|
const baseUrl = 'https://financialmodelingprep.com'; |
|
|
const baseUrl = 'https://financialmodelingprep.com'; |
|
|
|
|
|
|
|
|
|