Browse Source

Small fix

pull/3392/head
Reto Kaul 1 year ago
parent
commit
68712868d7
  1. 18
      apps/api/src/app/portfolio/calculator/portfolio-calculator.ts

18
apps/api/src/app/portfolio/calculator/portfolio-calculator.ts

@ -1101,11 +1101,11 @@ export abstract class PortfolioCalculator {
let netPerformanceAtStartDate; let netPerformanceAtStartDate;
let netPerformanceWithCurrencyEffectAtStartDate; let netPerformanceWithCurrencyEffectAtStartDate;
let netPerformanceInPercentageWithCurrencyEffectAtStartDate; let netPerformanceInPercentageWithCurrencyEffectAtStartDate;
let investmentValuesWithCurrencyEffect = []; let totalInvestmentValuesWithCurrencyEffect = [];
for (let historicalDataItem of chartData) { for (let historicalDataItem of chartData) {
if ( if (
!isBefore(parseDate(historicalDataItem.date), start) && !isBefore(parseDate(historicalDataItem.date), subDays(start, 1)) &&
!isAfter(parseDate(historicalDataItem.date), end) !isAfter(parseDate(historicalDataItem.date), end)
) { ) {
if (!netPerformanceAtStartDate) { if (!netPerformanceAtStartDate) {
@ -1118,8 +1118,8 @@ export abstract class PortfolioCalculator {
historicalDataItem.netPerformanceInPercentageWithCurrencyEffect; historicalDataItem.netPerformanceInPercentageWithCurrencyEffect;
} }
investmentValuesWithCurrencyEffect.push( totalInvestmentValuesWithCurrencyEffect.push(
historicalDataItem.investmentValueWithCurrencyEffect historicalDataItem.totalInvestmentValueWithCurrencyEffect
); );
// TODO: Normalize remaining metrics // TODO: Normalize remaining metrics
@ -1131,10 +1131,12 @@ export abstract class PortfolioCalculator {
historicalDataItem.netPerformanceWithCurrencyEffect - historicalDataItem.netPerformanceWithCurrencyEffect -
netPerformanceWithCurrencyEffectAtStartDate, netPerformanceWithCurrencyEffectAtStartDate,
netPerformanceInPercentageWithCurrencyEffect: netPerformanceInPercentageWithCurrencyEffect:
historicalDataItem.netPerformanceWithCurrencyEffect / ((historicalDataItem.netPerformanceWithCurrencyEffect -
// TODO: This is not correct yet netPerformanceWithCurrencyEffectAtStartDate) /
(sum(investmentValuesWithCurrencyEffect) / // TODO: Not sure if this is correct
investmentValuesWithCurrencyEffect.length) (sum(totalInvestmentValuesWithCurrencyEffect) /
totalInvestmentValuesWithCurrencyEffect.length)) *
100
}); });
} }
} }

Loading…
Cancel
Save