Browse Source

Improve calculation

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

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

@ -1118,9 +1118,24 @@ export abstract class PortfolioCalculator {
historicalDataItem.netPerformanceInPercentageWithCurrencyEffect; historicalDataItem.netPerformanceInPercentageWithCurrencyEffect;
} }
totalInvestmentValuesWithCurrencyEffect.push( const netPerformanceWithCurrencyEffectSinceStartDate =
historicalDataItem.totalInvestmentValueWithCurrencyEffect historicalDataItem.netPerformanceWithCurrencyEffect -
); netPerformanceWithCurrencyEffectAtStartDate;
if (historicalDataItem.totalInvestmentValueWithCurrencyEffect > 0) {
totalInvestmentValuesWithCurrencyEffect.push(
historicalDataItem.totalInvestmentValueWithCurrencyEffect
);
}
const timeWeightedInvestmentValue =
totalInvestmentValuesWithCurrencyEffect.length > 0
? sum(totalInvestmentValuesWithCurrencyEffect) /
totalInvestmentValuesWithCurrencyEffect.length
: 0;
// TODO: Not sure if this is correct
console.log(historicalDataItem.totalInvestmentValueWithCurrencyEffect);
// TODO: Normalize remaining metrics // TODO: Normalize remaining metrics
newChartData.push({ newChartData.push({
@ -1128,14 +1143,10 @@ export abstract class PortfolioCalculator {
netPerformance: netPerformance:
historicalDataItem.netPerformance - netPerformanceAtStartDate, historicalDataItem.netPerformance - netPerformanceAtStartDate,
netPerformanceWithCurrencyEffect: netPerformanceWithCurrencyEffect:
historicalDataItem.netPerformanceWithCurrencyEffect - netPerformanceWithCurrencyEffectSinceStartDate,
netPerformanceWithCurrencyEffectAtStartDate,
netPerformanceInPercentageWithCurrencyEffect: netPerformanceInPercentageWithCurrencyEffect:
((historicalDataItem.netPerformanceWithCurrencyEffect - (netPerformanceWithCurrencyEffectSinceStartDate /
netPerformanceWithCurrencyEffectAtStartDate) / timeWeightedInvestmentValue) *
// TODO: Not sure if this is correct
(sum(totalInvestmentValuesWithCurrencyEffect) /
totalInvestmentValuesWithCurrencyEffect.length)) *
100 100
}); });
} }

Loading…
Cancel
Save