|
@ -11,7 +11,6 @@ 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 |
|
@ -36,8 +35,7 @@ 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'); |
|
|
} |
|
|
} |
|
@ -232,29 +230,24 @@ export class EodHistoricalDataService implements DataProviderInterface { |
|
|
? [realTimeResponse] |
|
|
? [realTimeResponse] |
|
|
: realTimeResponse; |
|
|
: realTimeResponse; |
|
|
|
|
|
|
|
|
const symbolProfiles = await this.symbolProfileService.getSymbolProfiles( |
|
|
|
|
|
symbols.map((symbol) => { |
|
|
|
|
|
return { |
|
|
|
|
|
symbol, |
|
|
|
|
|
dataSource: this.getName() |
|
|
|
|
|
}; |
|
|
|
|
|
}) |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
response = quotes.reduce( |
|
|
response = quotes.reduce( |
|
|
( |
|
|
async ( |
|
|
result: { [symbol: string]: IDataProviderResponse }, |
|
|
result: { [symbol: string]: IDataProviderResponse }, |
|
|
{ close, code, timestamp } |
|
|
{ close, code, timestamp } |
|
|
) => { |
|
|
) => { |
|
|
const currency = symbolProfiles.find(({ symbol }) => { |
|
|
let currency: string; |
|
|
return symbol === code; |
|
|
|
|
|
})?.currency; |
|
|
if (symbols.length === 1) { |
|
|
|
|
|
const { items } = await this.search({ query: symbols[0] }); |
|
|
|
|
|
|
|
|
|
|
|
if (items.length === 1) { |
|
|
|
|
|
currency = items[0].currency; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (isNumber(close)) { |
|
|
if (isNumber(close)) { |
|
|
result[this.convertFromEodSymbol(code)] = { |
|
|
result[this.convertFromEodSymbol(code)] = { |
|
|
currency: |
|
|
currency, |
|
|
currency ?? |
|
|
|
|
|
this.convertFromEodSymbol(code)?.replace(DEFAULT_CURRENCY, ''), |
|
|
|
|
|
dataSource: this.getName(), |
|
|
dataSource: this.getName(), |
|
|
marketPrice: close, |
|
|
marketPrice: close, |
|
|
marketState: isToday(new Date(timestamp * 1000)) |
|
|
marketState: isToday(new Date(timestamp * 1000)) |
|
|