|  | @ -46,7 +46,12 @@ import type { | 
			
		
	
		
		
			
				
					|  |  | } from '@ghostfolio/common/types'; |  |  | } from '@ghostfolio/common/types'; | 
			
		
	
		
		
			
				
					|  |  | import { Inject, Injectable } from '@nestjs/common'; |  |  | import { Inject, Injectable } from '@nestjs/common'; | 
			
		
	
		
		
			
				
					|  |  | import { REQUEST } from '@nestjs/core'; |  |  | import { REQUEST } from '@nestjs/core'; | 
			
		
	
		
		
			
				
					
					|  |  | import { AssetClass, DataSource, Type as TypeOfOrder } from '@prisma/client'; |  |  | import { | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					|  |  |  |  |  |   AssetClass, | 
			
		
	
		
		
			
				
					|  |  |  |  |  |   DataSource, | 
			
		
	
		
		
			
				
					|  |  |  |  |  |   Tag, | 
			
		
	
		
		
			
				
					|  |  |  |  |  |   Type as TypeOfOrder | 
			
		
	
		
		
			
				
					|  |  |  |  |  | } from '@prisma/client'; | 
			
		
	
		
		
			
				
					|  |  | import Big from 'big.js'; |  |  | import Big from 'big.js'; | 
			
		
	
		
		
			
				
					|  |  | import { |  |  | import { | 
			
		
	
		
		
			
				
					|  |  |   differenceInDays, |  |  |   differenceInDays, | 
			
		
	
	
		
		
			
				
					|  | @ -62,7 +67,7 @@ import { | 
			
		
	
		
		
			
				
					|  |  |   subDays, |  |  |   subDays, | 
			
		
	
		
		
			
				
					|  |  |   subYears |  |  |   subYears | 
			
		
	
		
		
			
				
					|  |  | } from 'date-fns'; |  |  | } from 'date-fns'; | 
			
		
	
		
		
			
				
					
					|  |  | import { isEmpty, sortBy } from 'lodash'; |  |  | import { isEmpty, sortBy, uniqBy } from 'lodash'; | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  | import { |  |  | import { | 
			
		
	
		
		
			
				
					|  |  |   HistoricalDataContainer, |  |  |   HistoricalDataContainer, | 
			
		
	
	
		
		
			
				
					|  | @ -476,8 +481,11 @@ export class PortfolioService { | 
			
		
	
		
		
			
				
					|  |  |       ); |  |  |       ); | 
			
		
	
		
		
			
				
					|  |  |     }); |  |  |     }); | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     let tags: Tag[] = []; | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |     if (orders.length <= 0) { |  |  |     if (orders.length <= 0) { | 
			
		
	
		
		
			
				
					|  |  |       return { |  |  |       return { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         tags, | 
			
		
	
		
		
			
				
					|  |  |         averagePrice: undefined, |  |  |         averagePrice: undefined, | 
			
		
	
		
		
			
				
					|  |  |         firstBuyDate: undefined, |  |  |         firstBuyDate: undefined, | 
			
		
	
		
		
			
				
					|  |  |         grossPerformance: undefined, |  |  |         grossPerformance: undefined, | 
			
		
	
	
		
		
			
				
					|  | @ -504,6 +512,8 @@ export class PortfolioService { | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |     const portfolioOrders: PortfolioOrder[] = orders |  |  |     const portfolioOrders: PortfolioOrder[] = orders | 
			
		
	
		
		
			
				
					|  |  |       .filter((order) => { |  |  |       .filter((order) => { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         tags = tags.concat(order.tags); | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |         return order.type === 'BUY' || order.type === 'SELL'; |  |  |         return order.type === 'BUY' || order.type === 'SELL'; | 
			
		
	
		
		
			
				
					|  |  |       }) |  |  |       }) | 
			
		
	
		
		
			
				
					|  |  |       .map((order) => ({ |  |  |       .map((order) => ({ | 
			
		
	
	
		
		
			
				
					|  | @ -518,6 +528,8 @@ export class PortfolioService { | 
			
		
	
		
		
			
				
					|  |  |         unitPrice: new Big(order.unitPrice) |  |  |         unitPrice: new Big(order.unitPrice) | 
			
		
	
		
		
			
				
					|  |  |       })); |  |  |       })); | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     tags = uniqBy(tags, 'id'); | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |     const portfolioCalculator = new PortfolioCalculator({ |  |  |     const portfolioCalculator = new PortfolioCalculator({ | 
			
		
	
		
		
			
				
					|  |  |       currency: positionCurrency, |  |  |       currency: positionCurrency, | 
			
		
	
		
		
			
				
					|  |  |       currentRateService: this.currentRateService, |  |  |       currentRateService: this.currentRateService, | 
			
		
	
	
		
		
			
				
					|  | @ -626,6 +638,7 @@ export class PortfolioService { | 
			
		
	
		
		
			
				
					|  |  |         netPerformance, |  |  |         netPerformance, | 
			
		
	
		
		
			
				
					|  |  |         orders, |  |  |         orders, | 
			
		
	
		
		
			
				
					|  |  |         SymbolProfile, |  |  |         SymbolProfile, | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         tags, | 
			
		
	
		
		
			
				
					|  |  |         transactionCount, |  |  |         transactionCount, | 
			
		
	
		
		
			
				
					|  |  |         averagePrice: averagePrice.toNumber(), |  |  |         averagePrice: averagePrice.toNumber(), | 
			
		
	
		
		
			
				
					|  |  |         grossPerformancePercent: |  |  |         grossPerformancePercent: | 
			
		
	
	
		
		
			
				
					|  | @ -682,6 +695,7 @@ export class PortfolioService { | 
			
		
	
		
		
			
				
					|  |  |         minPrice, |  |  |         minPrice, | 
			
		
	
		
		
			
				
					|  |  |         orders, |  |  |         orders, | 
			
		
	
		
		
			
				
					|  |  |         SymbolProfile, |  |  |         SymbolProfile, | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         tags, | 
			
		
	
		
		
			
				
					|  |  |         averagePrice: 0, |  |  |         averagePrice: 0, | 
			
		
	
		
		
			
				
					|  |  |         firstBuyDate: undefined, |  |  |         firstBuyDate: undefined, | 
			
		
	
		
		
			
				
					|  |  |         grossPerformance: undefined, |  |  |         grossPerformance: undefined, | 
			
		
	
	
		
		
			
				
					|  | 
 |