Browse Source

Further fixes based on tests

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

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

@ -1328,11 +1328,11 @@ export class PortfolioCalculator {
initialValue, initialValue,
marketSymbolMap, marketSymbolMap,
fees, fees,
feesAtStartDate,
lastAveragePrice, lastAveragePrice,
grossPerformanceFromSells, grossPerformanceFromSells,
totalInvestmentWithGrossPerformanceFromSell, totalInvestmentWithGrossPerformanceFromSell,
grossPerformance, grossPerformance,
feesAtStartDate,
grossPerformanceAtStartDate, grossPerformanceAtStartDate,
isChartMode, isChartMode,
currentValues, currentValues,
@ -1351,9 +1351,9 @@ export class PortfolioCalculator {
return { return {
currentValues: result.currentValues.Value, currentValues: result.currentValues.Value,
currentValuesWithCurrencyEffect: result.currentValues.WithCurrencyEffect, currentValuesWithCurrencyEffect: result.currentValues.WithCurrencyEffect,
grossPerformancePercentage: result.grossPerformance.Value, grossPerformancePercentage: result.grossPerformancePercentage.Value,
grossPerformancePercentageWithCurrencyEffect: grossPerformancePercentageWithCurrencyEffect:
result.grossPerformance.WithCurrencyEffect, result.grossPerformancePercentage.WithCurrencyEffect,
initialValue: result.initialValue.Value, initialValue: result.initialValue.Value,
initialValueWithCurrencyEffect: result.initialValue.WithCurrencyEffect, initialValueWithCurrencyEffect: result.initialValue.WithCurrencyEffect,
investmentValuesWithCurrencyEffect: investmentValuesWithCurrencyEffect:
@ -1374,7 +1374,7 @@ export class PortfolioCalculator {
totalInvestment: result.totalInvestment.Value, totalInvestment: result.totalInvestment.Value,
totalInvestmentWithCurrencyEffect: totalInvestmentWithCurrencyEffect:
result.totalInvestment.WithCurrencyEffect, result.totalInvestment.WithCurrencyEffect,
netPerformanceValuesPercentage: result.netPerformancePercentage, netPerformanceValuesPercentage: result.netPerformanceValuesPercentage,
investmentValuesAccumulated: result.investmentValuesAccumulated.Value, investmentValuesAccumulated: result.investmentValuesAccumulated.Value,
investmentValuesAccumulatedWithCurrencyEffect: investmentValuesAccumulatedWithCurrencyEffect:
result.investmentValuesAccumulated.WithCurrencyEffect, result.investmentValuesAccumulated.WithCurrencyEffect,
@ -1404,11 +1404,11 @@ export class PortfolioCalculator {
initialValue: WithCurrencyEffect<Big>, initialValue: WithCurrencyEffect<Big>,
marketSymbolMap: { [date: string]: { [symbol: string]: Big } }, marketSymbolMap: { [date: string]: { [symbol: string]: Big } },
fees: WithCurrencyEffect<Big>, fees: WithCurrencyEffect<Big>,
feesAtStartDate: WithCurrencyEffect<Big>,
lastAveragePrice: WithCurrencyEffect<Big>, lastAveragePrice: WithCurrencyEffect<Big>,
grossPerformanceFromSells: WithCurrencyEffect<Big>, grossPerformanceFromSells: WithCurrencyEffect<Big>,
totalInvestmentWithGrossPerformanceFromSell: WithCurrencyEffect<Big>, totalInvestmentWithGrossPerformanceFromSell: WithCurrencyEffect<Big>,
grossPerformance: WithCurrencyEffect<Big>, grossPerformance: WithCurrencyEffect<Big>,
feesAtStartDate: WithCurrencyEffect<Big>,
grossPerformanceAtStartDate: WithCurrencyEffect<Big>, grossPerformanceAtStartDate: WithCurrencyEffect<Big>,
isChartMode: boolean, isChartMode: boolean,
currentValues: WithCurrencyEffect<{ [date: string]: Big }>, currentValues: WithCurrencyEffect<{ [date: string]: Big }>,
@ -1428,6 +1428,7 @@ export class PortfolioCalculator {
Value: new Big(0), Value: new Big(0),
WithCurrencyEffect: new Big(0) WithCurrencyEffect: new Big(0)
}; };
({ ({
lastAveragePrice, lastAveragePrice,
grossPerformance, grossPerformance,
@ -1456,13 +1457,13 @@ export class PortfolioCalculator {
averagePriceAtEndDate, averagePriceAtEndDate,
initialValue, initialValue,
fees, fees,
feesAtStartDate,
indexOfEndOrder, indexOfEndOrder,
marketSymbolMap, marketSymbolMap,
grossPerformanceFromSells, grossPerformanceFromSells,
totalInvestmentWithGrossPerformanceFromSell, totalInvestmentWithGrossPerformanceFromSell,
lastAveragePrice, lastAveragePrice,
grossPerformance, grossPerformance,
feesAtStartDate,
grossPerformanceAtStartDate, grossPerformanceAtStartDate,
isChartMode, isChartMode,
currentValues, currentValues,
@ -1601,13 +1602,13 @@ export class PortfolioCalculator {
averagePriceAtEndDate: Big, averagePriceAtEndDate: Big,
initialValue: WithCurrencyEffect<Big>, initialValue: WithCurrencyEffect<Big>,
fees: WithCurrencyEffect<Big>, fees: WithCurrencyEffect<Big>,
feesAtStartDate: WithCurrencyEffect<Big>,
indexOfEndOrder: number, indexOfEndOrder: number,
marketSymbolMap: { [date: string]: { [symbol: string]: Big } }, marketSymbolMap: { [date: string]: { [symbol: string]: Big } },
grossPerformanceFromSells: WithCurrencyEffect<Big>, grossPerformanceFromSells: WithCurrencyEffect<Big>,
totalInvestmentWithGrossPerformanceFromSell: WithCurrencyEffect<Big>, totalInvestmentWithGrossPerformanceFromSell: WithCurrencyEffect<Big>,
lastAveragePrice: WithCurrencyEffect<Big>, lastAveragePrice: WithCurrencyEffect<Big>,
grossPerformance: WithCurrencyEffect<Big>, grossPerformance: WithCurrencyEffect<Big>,
feesAtStartDate: WithCurrencyEffect<Big>,
grossPerformanceAtStartDate: WithCurrencyEffect<Big>, grossPerformanceAtStartDate: WithCurrencyEffect<Big>,
isChartMode: boolean, isChartMode: boolean,
currentValues: WithCurrencyEffect<{ [date: string]: Big }>, currentValues: WithCurrencyEffect<{ [date: string]: Big }>,
@ -1746,9 +1747,11 @@ export class PortfolioCalculator {
newGrossPerformanceWithCurrencyEffect; newGrossPerformanceWithCurrencyEffect;
if (order.itemType === 'start') { if (order.itemType === 'start') {
feesAtStartDate = fees; feesAtStartDate = {
feesAtStartDate.WithCurrencyEffect = fees.WithCurrencyEffect; Value: fees.Value,
grossPerformanceAtStartDate = grossPerformance; WithCurrencyEffect: fees.WithCurrencyEffect
};
grossPerformanceAtStartDate.Value = grossPerformance.Value;
grossPerformanceAtStartDate.WithCurrencyEffect = grossPerformanceAtStartDate.WithCurrencyEffect =
grossPerformance.WithCurrencyEffect; grossPerformance.WithCurrencyEffect;
@ -2301,7 +2304,7 @@ export class PortfolioCalculator {
marketSymbolMap: { [date: string]: { [symbol: string]: Big } }, marketSymbolMap: { [date: string]: { [symbol: string]: Big } },
initialValueWithCurrencyEffect: Big initialValueWithCurrencyEffect: Big
) { ) {
if (i >= indexOfStartOrder && !initialValue) { if (i >= indexOfStartOrder && initialValue.gt(0)) {
if ( if (
i === indexOfStartOrder && i === indexOfStartOrder &&
!valueOfInvestmentBeforeTransaction.Value.eq(0) !valueOfInvestmentBeforeTransaction.Value.eq(0)

Loading…
Cancel
Save