|
@ -877,8 +877,6 @@ export class TWRPortfolioCalculator extends PortfolioCalculator { |
|
|
startDate = addDays(start, 1); |
|
|
startDate = addDays(start, 1); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
let average = new Big(0); |
|
|
|
|
|
|
|
|
|
|
|
const currentValuesAtStartDateWithCurrencyEffect = |
|
|
const currentValuesAtStartDateWithCurrencyEffect = |
|
|
currentValuesWithCurrencyEffect[format(startDate, DATE_FORMAT)] ?? |
|
|
currentValuesWithCurrencyEffect[format(startDate, DATE_FORMAT)] ?? |
|
|
new Big(0); |
|
|
new Big(0); |
|
@ -901,11 +899,13 @@ export class TWRPortfolioCalculator extends PortfolioCalculator { |
|
|
return format(date, DATE_FORMAT); |
|
|
return format(date, DATE_FORMAT); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
let average = new Big(0); |
|
|
let dayCount = 0; |
|
|
let dayCount = 0; |
|
|
|
|
|
|
|
|
for (const date of dates) { |
|
|
for (const date of dates) { |
|
|
if ( |
|
|
if ( |
|
|
investmentValuesAccumulatedWithCurrencyEffect[date] instanceof Big |
|
|
investmentValuesAccumulatedWithCurrencyEffect[date] instanceof Big && |
|
|
|
|
|
investmentValuesAccumulatedWithCurrencyEffect[date].gt(0) |
|
|
) { |
|
|
) { |
|
|
average = average.add( |
|
|
average = average.add( |
|
|
investmentValuesAccumulatedWithCurrencyEffect[date].add( |
|
|
investmentValuesAccumulatedWithCurrencyEffect[date].add( |
|
@ -917,18 +917,16 @@ export class TWRPortfolioCalculator extends PortfolioCalculator { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (dayCount > 0) { |
|
|
average = average.div(dayCount); |
|
|
average = average.div(dayCount); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// TODO: Why without minus?
|
|
|
netPerformanceWithCurrencyEffectMap[dateRange] = |
|
|
netPerformanceWithCurrencyEffectMap[dateRange] = average.gt(0) |
|
|
|
|
|
? netPerformanceValuesWithCurrencyEffect[ |
|
|
|
|
|
format(endDate, DATE_FORMAT) |
|
|
|
|
|
] /*.minus( |
|
|
|
|
|
netPerformanceValuesWithCurrencyEffect[ |
|
|
netPerformanceValuesWithCurrencyEffect[ |
|
|
format(startDate, DATE_FORMAT) |
|
|
format(endDate, DATE_FORMAT) |
|
|
] |
|
|
].minus( |
|
|
)*/ |
|
|
netPerformanceValuesWithCurrencyEffect[format(startDate, DATE_FORMAT)] |
|
|
: new Big(0); |
|
|
); |
|
|
|
|
|
|
|
|
netPerformancePercentageWithCurrencyEffectMap[dateRange] = average.gt(0) |
|
|
netPerformancePercentageWithCurrencyEffectMap[dateRange] = average.gt(0) |
|
|
? netPerformanceWithCurrencyEffectMap[dateRange].div(average) |
|
|
? netPerformanceWithCurrencyEffectMap[dateRange].div(average) |
|
|