|
|
|
@ -51,9 +51,13 @@ export class EodHistoricalDataService implements DataProviderInterface { |
|
|
|
} |
|
|
|
|
|
|
|
public async getAssetProfile({ |
|
|
|
requestTimeout = this.configurationService.get('REQUEST_TIMEOUT'), |
|
|
|
symbol |
|
|
|
}: GetAssetProfileParams): Promise<Partial<SymbolProfile>> { |
|
|
|
const [searchResult] = await this.getSearchResult(symbol); |
|
|
|
const [searchResult] = await this.getSearchResult({ |
|
|
|
requestTimeout, |
|
|
|
query: symbol |
|
|
|
}); |
|
|
|
|
|
|
|
if (!searchResult) { |
|
|
|
return undefined; |
|
|
|
@ -304,8 +308,11 @@ export class EodHistoricalDataService implements DataProviderInterface { |
|
|
|
return 'AAPL.US'; |
|
|
|
} |
|
|
|
|
|
|
|
public async search({ query }: GetSearchParams): Promise<LookupResponse> { |
|
|
|
const searchResult = await this.getSearchResult(query); |
|
|
|
public async search({ |
|
|
|
query, |
|
|
|
requestTimeout = this.configurationService.get('REQUEST_TIMEOUT') |
|
|
|
}: GetSearchParams): Promise<LookupResponse> { |
|
|
|
const searchResult = await this.getSearchResult({ query, requestTimeout }); |
|
|
|
|
|
|
|
return { |
|
|
|
items: searchResult |
|
|
|
@ -394,7 +401,13 @@ export class EodHistoricalDataService implements DataProviderInterface { |
|
|
|
return name; |
|
|
|
} |
|
|
|
|
|
|
|
private async getSearchResult(aQuery: string) { |
|
|
|
private async getSearchResult({ |
|
|
|
query, |
|
|
|
requestTimeout = this.configurationService.get('REQUEST_TIMEOUT') |
|
|
|
}: { |
|
|
|
query: string; |
|
|
|
requestTimeout?: number; |
|
|
|
}) { |
|
|
|
let searchResult: (LookupItem & { |
|
|
|
assetClass: AssetClass; |
|
|
|
assetSubClass: AssetSubClass; |
|
|
|
@ -403,11 +416,9 @@ export class EodHistoricalDataService implements DataProviderInterface { |
|
|
|
|
|
|
|
try { |
|
|
|
const response = await fetch( |
|
|
|
`${this.URL}/search/${aQuery}?api_token=${this.apiKey}`, |
|
|
|
`${this.URL}/search/${query}?api_token=${this.apiKey}`, |
|
|
|
{ |
|
|
|
signal: AbortSignal.timeout( |
|
|
|
this.configurationService.get('REQUEST_TIMEOUT') |
|
|
|
) |
|
|
|
signal: AbortSignal.timeout(requestTimeout) |
|
|
|
} |
|
|
|
).then((res) => res.json()); |
|
|
|
|
|
|
|
@ -433,7 +444,7 @@ export class EodHistoricalDataService implements DataProviderInterface { |
|
|
|
let message = error; |
|
|
|
|
|
|
|
if (['AbortError', 'TimeoutError'].includes(error?.name)) { |
|
|
|
message = `RequestError: The operation to search for ${aQuery} was aborted because the request to the data provider took more than ${( |
|
|
|
message = `RequestError: The operation to search for ${query} was aborted because the request to the data provider took more than ${( |
|
|
|
this.configurationService.get('REQUEST_TIMEOUT') / 1000 |
|
|
|
).toFixed(3)} seconds`;
|
|
|
|
} |
|
|
|
|