@ -24,7 +24,7 @@ import {
MAX_CHART_ITEMS ,
MAX_CHART_ITEMS ,
UNKNOWN_KEY
UNKNOWN_KEY
} from '@ghostfolio/common/config' ;
} from '@ghostfolio/common/config' ;
import { DATE_FORMAT , parseDate } from '@ghostfolio/common/helper' ;
import { DATE_FORMAT , getSum , parseDate } from '@ghostfolio/common/helper' ;
import {
import {
Accounts ,
Accounts ,
EnhancedSymbolProfile ,
EnhancedSymbolProfile ,
@ -678,6 +678,8 @@ export class PortfolioService {
return {
return {
tags ,
tags ,
averagePrice : undefined ,
averagePrice : undefined ,
dividendInBaseCurrency : undefined ,
feeInBaseCurrency : undefined ,
firstBuyDate : undefined ,
firstBuyDate : undefined ,
grossPerformance : undefined ,
grossPerformance : undefined ,
grossPerformancePercent : undefined ,
grossPerformancePercent : undefined ,
@ -744,12 +746,23 @@ export class PortfolioService {
averagePrice ,
averagePrice ,
currency ,
currency ,
dataSource ,
dataSource ,
fee ,
firstBuyDate ,
firstBuyDate ,
marketPrice ,
marketPrice ,
quantity ,
quantity ,
transactionCount
transactionCount
} = position ;
} = position ;
const dividendInBaseCurrency = getSum (
orders
. filter ( ( { type } ) = > {
return type === 'DIVIDEND' ;
} )
. map ( ( { valueInBaseCurrency } ) = > {
return new Big ( valueInBaseCurrency ) ;
} )
) ;
// Convert investment, gross and net performance to currency of user
// Convert investment, gross and net performance to currency of user
const investment = this . exchangeRateDataService . toCurrency (
const investment = this . exchangeRateDataService . toCurrency (
position . investment ? . toNumber ( ) ,
position . investment ? . toNumber ( ) ,
@ -836,6 +849,12 @@ export class PortfolioService {
tags ,
tags ,
transactionCount ,
transactionCount ,
averagePrice : averagePrice.toNumber ( ) ,
averagePrice : averagePrice.toNumber ( ) ,
dividendInBaseCurrency : dividendInBaseCurrency.toNumber ( ) ,
feeInBaseCurrency : this.exchangeRateDataService.toCurrency (
fee . toNumber ( ) ,
SymbolProfile . currency ,
userCurrency
) ,
grossPerformancePercent :
grossPerformancePercent :
position . grossPerformancePercentage ? . toNumber ( ) ,
position . grossPerformancePercentage ? . toNumber ( ) ,
historicalData : historicalDataArray ,
historicalData : historicalDataArray ,
@ -892,6 +911,8 @@ export class PortfolioService {
SymbolProfile ,
SymbolProfile ,
tags ,
tags ,
averagePrice : 0 ,
averagePrice : 0 ,
dividendInBaseCurrency : 0 ,
feeInBaseCurrency : 0 ,
firstBuyDate : undefined ,
firstBuyDate : undefined ,
grossPerformance : undefined ,
grossPerformance : undefined ,
grossPerformancePercent : undefined ,
grossPerformancePercent : undefined ,