Browse Source

Fix return of TotalDaysInvested

pull/5027/head
Daniel Devaud 1 year ago
parent
commit
f6d8d759c9
  1. 63
      apps/api/src/app/portfolio/portfolio-calculator.ts

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

@ -422,7 +422,6 @@ export class PortfolioCalculator {
accumulatedValuesByDate accumulatedValuesByDate
); );
} }
let values;
const { const {
investmentValueWithCurrencyEffect, investmentValueWithCurrencyEffect,
@ -1443,7 +1442,8 @@ export class PortfolioCalculator {
averagePriceAtEndDate, averagePriceAtEndDate,
initialValue, initialValue,
fees, fees,
netPerformanceValuesPercentage netPerformanceValuesPercentage,
totalInvestmentDays
} = this.handleOrders( } = this.handleOrders(
orders, orders,
indexOfStartOrder, indexOfStartOrder,
@ -1757,31 +1757,32 @@ export class PortfolioCalculator {
grossPerformance.WithCurrencyEffect; grossPerformance.WithCurrencyEffect;
} }
this.calculatePerformancesForDate( totalInvestmentDays =
isChartMode, this.calculatePerformancesForDateAndReturnTotalInvestmentDays(
i, isChartMode,
indexOfStartOrder, i,
currentValues, indexOfStartOrder,
order, currentValues,
valueOfInvestment, order,
valueOfInvestmentBeforeTransaction, valueOfInvestment,
netPerformanceValues, valueOfInvestmentBeforeTransaction,
grossPerformance, netPerformanceValues,
grossPerformanceAtStartDate, grossPerformance,
fees, grossPerformanceAtStartDate,
feesAtStartDate, fees,
investmentValues, feesAtStartDate,
investmentValuesAccumulated, investmentValues,
totalInvestment, investmentValuesAccumulated,
timeWeightedInvestmentValues, totalInvestment,
previousOrderDateString, timeWeightedInvestmentValues,
totalInvestmentDays, previousOrderDateString,
sumOfTimeWeightedInvestments, totalInvestmentDays,
valueAtStartDate, sumOfTimeWeightedInvestments,
investmentAtStartDate, valueAtStartDate,
totalInvestmentBeforeTransaction, investmentAtStartDate,
transactionInvestment.WithCurrencyEffect totalInvestmentBeforeTransaction,
); transactionInvestment.WithCurrencyEffect
);
this.handleLoggingOfInvestmentMetrics( this.handleLoggingOfInvestmentMetrics(
totalInvestment, totalInvestment,
@ -1811,7 +1812,8 @@ export class PortfolioCalculator {
averagePriceAtEndDate, averagePriceAtEndDate,
initialValue, initialValue,
fees, fees,
netPerformanceValuesPercentage netPerformanceValuesPercentage,
totalInvestmentDays
}; };
} }
@ -2147,7 +2149,7 @@ export class PortfolioCalculator {
}; };
} }
private calculatePerformancesForDate( private calculatePerformancesForDateAndReturnTotalInvestmentDays(
isChartMode: boolean, isChartMode: boolean,
i: number, i: number,
indexOfStartOrder: number, indexOfStartOrder: number,
@ -2171,7 +2173,7 @@ export class PortfolioCalculator {
investmentAtStartDate: WithCurrencyEffect<Big>, investmentAtStartDate: WithCurrencyEffect<Big>,
totalInvestmentBeforeTransaction: WithCurrencyEffect<Big>, totalInvestmentBeforeTransaction: WithCurrencyEffect<Big>,
transactionInvestmentWithCurrencyEffect: Big transactionInvestmentWithCurrencyEffect: Big
) { ): number {
if (i > indexOfStartOrder) { if (i > indexOfStartOrder) {
if (valueOfInvestmentBeforeTransaction.Value.gt(0)) { if (valueOfInvestmentBeforeTransaction.Value.gt(0)) {
// Calculate the number of days since the previous order // Calculate the number of days since the previous order
@ -2246,6 +2248,7 @@ export class PortfolioCalculator {
: new Big(0); : new Big(0);
} }
} }
return totalInvestmentDays;
} }
private calculateSellOrders( private calculateSellOrders(

Loading…
Cancel
Save