|
@ -11,6 +11,7 @@ import { |
|
|
IDataProviderHistoricalResponse, |
|
|
IDataProviderHistoricalResponse, |
|
|
IDataProviderResponse |
|
|
IDataProviderResponse |
|
|
} from '@ghostfolio/api/services/interfaces/interfaces'; |
|
|
} from '@ghostfolio/api/services/interfaces/interfaces'; |
|
|
|
|
|
import { SymbolProfileService } from '@ghostfolio/api/services/symbol-profile/symbol-profile.service'; |
|
|
import { |
|
|
import { |
|
|
DEFAULT_CURRENCY, |
|
|
DEFAULT_CURRENCY, |
|
|
REPLACE_NAME_PARTS |
|
|
REPLACE_NAME_PARTS |
|
@ -35,7 +36,8 @@ export class EodHistoricalDataService implements DataProviderInterface { |
|
|
private readonly URL = 'https://eodhistoricaldata.com/api'; |
|
|
private readonly URL = 'https://eodhistoricaldata.com/api'; |
|
|
|
|
|
|
|
|
public constructor( |
|
|
public constructor( |
|
|
private readonly configurationService: ConfigurationService |
|
|
private readonly configurationService: ConfigurationService, |
|
|
|
|
|
private readonly symbolProfileService: SymbolProfileService |
|
|
) { |
|
|
) { |
|
|
this.apiKey = this.configurationService.get('API_KEY_EOD_HISTORICAL_DATA'); |
|
|
this.apiKey = this.configurationService.get('API_KEY_EOD_HISTORICAL_DATA'); |
|
|
} |
|
|
} |
|
@ -228,27 +230,22 @@ export class EodHistoricalDataService implements DataProviderInterface { |
|
|
? [realTimeResponse] |
|
|
? [realTimeResponse] |
|
|
: realTimeResponse; |
|
|
: realTimeResponse; |
|
|
|
|
|
|
|
|
const searchResponse = await Promise.all( |
|
|
const symbolProfiles = await this.symbolProfileService.getSymbolProfiles( |
|
|
eodHistoricalDataSymbols |
|
|
symbols.map((symbol) => { |
|
|
.filter((symbol) => { |
|
|
return { |
|
|
return !symbol.endsWith('.FOREX'); |
|
|
symbol, |
|
|
}) |
|
|
dataSource: this.getName() |
|
|
.map((symbol) => { |
|
|
}; |
|
|
return this.search({ query: symbol }); |
|
|
}) |
|
|
}) |
|
|
|
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
const lookupItems = searchResponse.flat().map(({ items }) => { |
|
|
|
|
|
return items[0]; |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
response = quotes.reduce( |
|
|
response = quotes.reduce( |
|
|
( |
|
|
( |
|
|
result: { [symbol: string]: IDataProviderResponse }, |
|
|
result: { [symbol: string]: IDataProviderResponse }, |
|
|
{ close, code, timestamp } |
|
|
{ close, code, timestamp } |
|
|
) => { |
|
|
) => { |
|
|
const currency = lookupItems.find((lookupItem) => { |
|
|
const currency = symbolProfiles.find(({ symbol }) => { |
|
|
return lookupItem.symbol === code; |
|
|
return symbol === code; |
|
|
})?.currency; |
|
|
})?.currency; |
|
|
|
|
|
|
|
|
if (isNumber(close)) { |
|
|
if (isNumber(close)) { |
|
|