|
|
@ -24,15 +24,30 @@ export class SymbolService { |
|
|
|
|
|
|
|
|
public async get({ |
|
|
public async get({ |
|
|
dataGatheringItem, |
|
|
dataGatheringItem, |
|
|
includeHistoricalData |
|
|
includeHistoricalData, |
|
|
|
|
|
useIntradayData = false |
|
|
}: { |
|
|
}: { |
|
|
dataGatheringItem: DataGatheringItem; |
|
|
dataGatheringItem: DataGatheringItem; |
|
|
includeHistoricalData?: number; |
|
|
includeHistoricalData?: number; |
|
|
|
|
|
useIntradayData?: boolean; |
|
|
}): Promise<SymbolItem> { |
|
|
}): Promise<SymbolItem> { |
|
|
|
|
|
let currency: string; |
|
|
|
|
|
let marketPrice: number; |
|
|
|
|
|
|
|
|
|
|
|
if (useIntradayData) { |
|
|
|
|
|
const latestMarketData = await this.marketDataService.getLatest({ |
|
|
|
|
|
dataSource: dataGatheringItem.dataSource, |
|
|
|
|
|
symbol: dataGatheringItem.symbol |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
marketPrice = latestMarketData?.marketPrice; |
|
|
|
|
|
} else { |
|
|
const quotes = await this.dataProviderService.getQuotes({ |
|
|
const quotes = await this.dataProviderService.getQuotes({ |
|
|
items: [dataGatheringItem] |
|
|
items: [dataGatheringItem] |
|
|
}); |
|
|
}); |
|
|
const { currency, marketPrice } = quotes[dataGatheringItem.symbol] ?? {}; |
|
|
|
|
|
|
|
|
({ currency, marketPrice } = quotes[dataGatheringItem.symbol] ?? {}); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (dataGatheringItem.dataSource && marketPrice >= 0) { |
|
|
if (dataGatheringItem.dataSource && marketPrice >= 0) { |
|
|
let historicalData: HistoricalDataItem[] = []; |
|
|
let historicalData: HistoricalDataItem[] = []; |
|
|
|