|
@ -708,16 +708,22 @@ export class RoaiPortfolioCalculator extends PortfolioCalculator { |
|
|
investmentValuesWithCurrencyEffect[order.date] ?? new Big(0) |
|
|
investmentValuesWithCurrencyEffect[order.date] ?? new Big(0) |
|
|
).add(transactionInvestmentWithCurrencyEffect); |
|
|
).add(transactionInvestmentWithCurrencyEffect); |
|
|
|
|
|
|
|
|
|
|
|
// If duration is effectively zero (first day), use the actual investment as the base.
|
|
|
|
|
|
// Otherwise, use the calculated time-weighted average.
|
|
|
timeWeightedInvestmentValues[order.date] = |
|
|
timeWeightedInvestmentValues[order.date] = |
|
|
totalInvestmentDays > 0 |
|
|
totalInvestmentDays > Number.EPSILON |
|
|
? sumOfTimeWeightedInvestments.div(totalInvestmentDays) |
|
|
? sumOfTimeWeightedInvestments.div(totalInvestmentDays) |
|
|
|
|
|
: totalInvestment.gt(0) |
|
|
|
|
|
? totalInvestment |
|
|
: new Big(0); |
|
|
: new Big(0); |
|
|
|
|
|
|
|
|
timeWeightedInvestmentValuesWithCurrencyEffect[order.date] = |
|
|
timeWeightedInvestmentValuesWithCurrencyEffect[order.date] = |
|
|
totalInvestmentDays > 0 |
|
|
totalInvestmentDays > Number.EPSILON |
|
|
? sumOfTimeWeightedInvestmentsWithCurrencyEffect.div( |
|
|
? sumOfTimeWeightedInvestmentsWithCurrencyEffect.div( |
|
|
totalInvestmentDays |
|
|
totalInvestmentDays |
|
|
) |
|
|
) |
|
|
|
|
|
: totalInvestmentWithCurrencyEffect.gt(0) |
|
|
|
|
|
? totalInvestmentWithCurrencyEffect |
|
|
: new Big(0); |
|
|
: new Big(0); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|