Browse Source

Remove log performance + plus further work on performance calculation

pull/5027/head
Dan 2 months ago
parent
commit
043a77b71a
  1. 1
      apps/api/src/app/portfolio/calculator/roi/portfolio-calculator-symbolmetrics-helper.ts
  2. 27
      apps/api/src/app/portfolio/calculator/roi/portfolio-calculator.ts

1
apps/api/src/app/portfolio/calculator/roi/portfolio-calculator-symbolmetrics-helper.ts

@ -121,7 +121,6 @@ export class RoiPortfolioCalculatorSymbolMetricsHelper {
} }
} }
@LogPerformance
public processOrderMetrics( public processOrderMetrics(
orders: PortfolioOrderItem[], orders: PortfolioOrderItem[],
i: number, i: number,

27
apps/api/src/app/portfolio/calculator/roi/portfolio-calculator.ts

@ -52,11 +52,34 @@ export class RoiPortfolioCalculator extends PortfolioCalculator {
let netPerformanceWithCurrencyEffect: number; let netPerformanceWithCurrencyEffect: number;
let netPerformanceInPercentageWithCurrencyEffect: 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) { for (const position of positions) {
netPerformance = netPerformance + position.netPerformance.toNumber(); netPerformance = netPerformance + position.netPerformance.toNumber();
// TODO GET Net performance with currency effect
netPerformanceInPercentage = netPerformanceInPercentage =
netPerformanceInPercentage * netPerformanceInPercentage +
position.valueInBaseCurrency.div(netWorth).toNumber(); 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 //TODO Calculate performance values not using chart
} }

Loading…
Cancel
Save