|
|
|
@ -57,6 +57,7 @@ import { |
|
|
|
InvestmentItem, |
|
|
|
PortfolioDetails, |
|
|
|
PortfolioHoldingResponse, |
|
|
|
PortfolioHoldingsResponse, |
|
|
|
PortfolioInvestmentsResponse, |
|
|
|
PortfolioPerformanceResponse, |
|
|
|
PortfolioPosition, |
|
|
|
@ -505,7 +506,14 @@ export class PortfolioService { |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
return holdings; |
|
|
|
return { |
|
|
|
holdings, |
|
|
|
totalValueInBaseCurrency: getSum( |
|
|
|
holdings.map(({ valueInBaseCurrency }) => { |
|
|
|
return new Big(valueInBaseCurrency ?? 0); |
|
|
|
}) |
|
|
|
).toNumber() |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
public async getInvestments({ |
|
|
|
@ -1185,7 +1193,7 @@ export class PortfolioService { |
|
|
|
currency: userCurrency |
|
|
|
}); |
|
|
|
|
|
|
|
const { errors, hasErrors, historicalData } = |
|
|
|
const { currentValueInBaseCurrency, errors, hasErrors, historicalData } = |
|
|
|
await portfolioCalculator.getSnapshot(); |
|
|
|
|
|
|
|
const { endDate, startDate } = getIntervalFromDateRange({ dateRange }); |
|
|
|
@ -1202,8 +1210,7 @@ export class PortfolioService { |
|
|
|
netPerformanceWithCurrencyEffect, |
|
|
|
netWorth, |
|
|
|
totalInvestment, |
|
|
|
totalInvestmentValueWithCurrencyEffect, |
|
|
|
valueWithCurrencyEffect |
|
|
|
totalInvestmentValueWithCurrencyEffect |
|
|
|
} = chart?.at(-1) ?? { |
|
|
|
netPerformance: 0, |
|
|
|
netPerformanceInPercentage: 0, |
|
|
|
@ -1211,7 +1218,7 @@ export class PortfolioService { |
|
|
|
netPerformanceWithCurrencyEffect: 0, |
|
|
|
netWorth: 0, |
|
|
|
totalInvestment: 0, |
|
|
|
valueWithCurrencyEffect: 0 |
|
|
|
totalInvestmentValueWithCurrencyEffect: 0 |
|
|
|
}; |
|
|
|
|
|
|
|
return { |
|
|
|
@ -1225,7 +1232,7 @@ export class PortfolioService { |
|
|
|
totalInvestment, |
|
|
|
totalInvestmentValueWithCurrencyEffect, |
|
|
|
currentNetWorth: netWorth, |
|
|
|
currentValueInBaseCurrency: valueWithCurrencyEffect, |
|
|
|
currentValueInBaseCurrency: currentValueInBaseCurrency.toNumber(), |
|
|
|
netPerformancePercentage: netPerformanceInPercentage, |
|
|
|
netPerformancePercentageWithCurrencyEffect: |
|
|
|
netPerformanceInPercentageWithCurrencyEffect |
|
|
|
|