diff --git a/apps/api/src/app/portfolio/calculator/roi/portfolio-calculator-symbolmetrics-helper.ts b/apps/api/src/app/portfolio/calculator/roi/portfolio-calculator-symbolmetrics-helper.ts index 2bae172a6..656988f63 100644 --- a/apps/api/src/app/portfolio/calculator/roi/portfolio-calculator-symbolmetrics-helper.ts +++ b/apps/api/src/app/portfolio/calculator/roi/portfolio-calculator-symbolmetrics-helper.ts @@ -121,7 +121,6 @@ export class RoiPortfolioCalculatorSymbolMetricsHelper { } } - @LogPerformance public processOrderMetrics( orders: PortfolioOrderItem[], i: number, diff --git a/apps/api/src/app/portfolio/calculator/roi/portfolio-calculator.ts b/apps/api/src/app/portfolio/calculator/roi/portfolio-calculator.ts index b11896557..156dff719 100644 --- a/apps/api/src/app/portfolio/calculator/roi/portfolio-calculator.ts +++ b/apps/api/src/app/portfolio/calculator/roi/portfolio-calculator.ts @@ -52,11 +52,34 @@ export class RoiPortfolioCalculator extends PortfolioCalculator { let netPerformanceWithCurrencyEffect: number; let netPerformanceInPercentageWithCurrencyEffect: number; + const totalInvestments = positions.reduce( + (total, position) => { + return { + total: total.total.plus(position.investment), + totalWithCurrencyEffect: total.totalWithCurrencyEffect.plus( + position.investmentWithCurrencyEffect + ) + }; + }, + { total: new Big(0), totalWithCurrencyEffect: new Big(0) } + ); for (const position of positions) { netPerformance = netPerformance + position.netPerformance.toNumber(); + // TODO GET Net performance with currency effect netPerformanceInPercentage = - netPerformanceInPercentage * - position.valueInBaseCurrency.div(netWorth).toNumber(); + netPerformanceInPercentage + + position.netPerformancePercentage + .mul(position.investment.div(totalInvestments.total)) + .toNumber(); + netPerformanceInPercentageWithCurrencyEffect = + netPerformanceInPercentageWithCurrencyEffect + + position.netPerformancePercentage + .mul( + position.investmentWithCurrencyEffect.div( + totalInvestments.totalWithCurrencyEffect + ) + ) + .toNumber(); //TODO Calculate performance values not using chart }