| 
						
						
							
								
							
						
						
					 | 
					@ -2,7 +2,11 @@ import { DataProviderService } from '@ghostfolio/api/services/data-provider/data | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import { ExchangeRateDataService } from '@ghostfolio/api/services/exchange-rate-data/exchange-rate-data.service'; | 
					 | 
					 | 
					import { ExchangeRateDataService } from '@ghostfolio/api/services/exchange-rate-data/exchange-rate-data.service'; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import { MarketDataService } from '@ghostfolio/api/services/market-data/market-data.service'; | 
					 | 
					 | 
					import { MarketDataService } from '@ghostfolio/api/services/market-data/market-data.service'; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import { resetHours } from '@ghostfolio/common/helper'; | 
					 | 
					 | 
					import { resetHours } from '@ghostfolio/common/helper'; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					import { DataProviderInfo, ResponseError } from '@ghostfolio/common/interfaces'; | 
					 | 
					 | 
					import { | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					  DataProviderInfo, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					  ResponseError, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					  UniqueAsset | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					} from '@ghostfolio/common/interfaces'; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import { Injectable } from '@nestjs/common'; | 
					 | 
					 | 
					import { Injectable } from '@nestjs/common'; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import { isBefore, isToday } from 'date-fns'; | 
					 | 
					 | 
					import { isBefore, isToday } from 'date-fns'; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import { flatten, isEmpty, uniqBy } from 'lodash'; | 
					 | 
					 | 
					import { flatten, isEmpty, uniqBy } from 'lodash'; | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					@ -52,6 +56,7 @@ export class CurrentRateService { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					              if (dataResultProvider?.[dataGatheringItem.symbol]?.marketPrice) { | 
					 | 
					 | 
					              if (dataResultProvider?.[dataGatheringItem.symbol]?.marketPrice) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                result.push({ | 
					 | 
					 | 
					                result.push({ | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                  dataSource: dataGatheringItem.dataSource, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                  date: today, | 
					 | 
					 | 
					                  date: today, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                  marketPriceInBaseCurrency: | 
					 | 
					 | 
					                  marketPriceInBaseCurrency: | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                    this.exchangeRateDataService.toCurrency( | 
					 | 
					 | 
					                    this.exchangeRateDataService.toCurrency( | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					@ -75,27 +80,30 @@ export class CurrentRateService { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					      ); | 
					 | 
					 | 
					      ); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    } | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					    const symbols = dataGatheringItems.map((dataGatheringItem) => { | 
					 | 
					 | 
					    const uniqueAssets: UniqueAsset[] = dataGatheringItems.map( | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					      return dataGatheringItem.symbol; | 
					 | 
					 | 
					      ({ dataSource, symbol }) => { | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					    }); | 
					 | 
					 | 
					        return { dataSource, symbol }; | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    ); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    promises.push( | 
					 | 
					 | 
					    promises.push( | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					      this.marketDataService | 
					 | 
					 | 
					      this.marketDataService | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        .getRange({ | 
					 | 
					 | 
					        .getRange({ | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					          dateQuery, | 
					 | 
					 | 
					          dateQuery, | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					          symbols | 
					 | 
					 | 
					          uniqueAssets | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					        }) | 
					 | 
					 | 
					        }) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        .then((data) => { | 
					 | 
					 | 
					        .then((data) => { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					          return data.map((marketDataItem) => { | 
					 | 
					 | 
					          return data.map(({ dataSource, date, marketPrice, symbol }) => { | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					            return { | 
					 | 
					 | 
					            return { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					              date: marketDataItem.date, | 
					 | 
					 | 
					              dataSource, | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					              date, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					              symbol, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					              marketPriceInBaseCurrency: | 
					 | 
					 | 
					              marketPriceInBaseCurrency: | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                this.exchangeRateDataService.toCurrency( | 
					 | 
					 | 
					                this.exchangeRateDataService.toCurrency( | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					                  marketDataItem.marketPrice, | 
					 | 
					 | 
					                  marketPrice, | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					                  currencies[marketDataItem.symbol], | 
					 | 
					 | 
					                  currencies[symbol], | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					                  userCurrency | 
					 | 
					 | 
					                  userCurrency | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					                ), | 
					 | 
					 | 
					                ) | 
				
			
			
				
				
			
		
	
		
		
			
				
					 | 
					 | 
					              symbol: marketDataItem.symbol | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					            }; | 
					 | 
					 | 
					            }; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					          }); | 
					 | 
					 | 
					          }); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        }) | 
					 | 
					 | 
					        }) | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					@ -112,7 +120,7 @@ export class CurrentRateService { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    }; | 
					 | 
					 | 
					    }; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    if (!isEmpty(quoteErrors)) { | 
					 | 
					 | 
					    if (!isEmpty(quoteErrors)) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					      for (const { symbol } of quoteErrors) { | 
					 | 
					 | 
					      for (const { dataSource, symbol } of quoteErrors) { | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					        try { | 
					 | 
					 | 
					        try { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					          // If missing quote, fallback to the latest available historical market price
 | 
					 | 
					 | 
					          // If missing quote, fallback to the latest available historical market price
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					          let value: GetValueObject = response.values.find((currentValue) => { | 
					 | 
					 | 
					          let value: GetValueObject = response.values.find((currentValue) => { | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					@ -121,6 +129,7 @@ export class CurrentRateService { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					          if (!value) { | 
					 | 
					 | 
					          if (!value) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            value = { | 
					 | 
					 | 
					            value = { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					              dataSource, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					              symbol, | 
					 | 
					 | 
					              symbol, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					              date: today, | 
					 | 
					 | 
					              date: today, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					              marketPriceInBaseCurrency: 0 | 
					 | 
					 | 
					              marketPriceInBaseCurrency: 0 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
					
  |