|
@ -900,12 +900,12 @@ export class PortfolioCalculator { |
|
|
let investmentAtStartDate: Big; |
|
|
let investmentAtStartDate: Big; |
|
|
const investmentValues: { [date: string]: Big } = {}; |
|
|
const investmentValues: { [date: string]: Big } = {}; |
|
|
let lastAveragePrice = new Big(0); |
|
|
let lastAveragePrice = new Big(0); |
|
|
let lastTransactionInvestment = new Big(0); |
|
|
// let lastTransactionInvestment = new Big(0);
|
|
|
let lastValueOfInvestmentBeforeTransaction = new Big(0); |
|
|
// let lastValueOfInvestmentBeforeTransaction = new Big(0);
|
|
|
let maxTotalInvestment = new Big(0); |
|
|
let maxTotalInvestment = new Big(0); |
|
|
const netPerformanceValues: { [date: string]: Big } = {}; |
|
|
const netPerformanceValues: { [date: string]: Big } = {}; |
|
|
let timeWeightedGrossPerformancePercentage = new Big(1); |
|
|
// let timeWeightedGrossPerformancePercentage = new Big(1);
|
|
|
let timeWeightedNetPerformancePercentage = new Big(1); |
|
|
// let timeWeightedNetPerformancePercentage = new Big(1);
|
|
|
let totalInvestment = new Big(0); |
|
|
let totalInvestment = new Big(0); |
|
|
let totalInvestmentWithGrossPerformanceFromSell = new Big(0); |
|
|
let totalInvestmentWithGrossPerformanceFromSell = new Big(0); |
|
|
let totalUnits = new Big(0); |
|
|
let totalUnits = new Big(0); |
|
@ -1082,54 +1082,54 @@ export class PortfolioCalculator { |
|
|
.minus(totalInvestmentWithGrossPerformanceFromSell) |
|
|
.minus(totalInvestmentWithGrossPerformanceFromSell) |
|
|
.plus(grossPerformanceFromSells); |
|
|
.plus(grossPerformanceFromSells); |
|
|
|
|
|
|
|
|
if ( |
|
|
// if (
|
|
|
i > indexOfStartOrder && |
|
|
// i > indexOfStartOrder &&
|
|
|
!lastValueOfInvestmentBeforeTransaction |
|
|
// !lastValueOfInvestmentBeforeTransaction
|
|
|
.plus(lastTransactionInvestment) |
|
|
// .plus(lastTransactionInvestment)
|
|
|
.eq(0) |
|
|
// .eq(0)
|
|
|
) { |
|
|
// ) {
|
|
|
const grossHoldingPeriodReturn = valueOfInvestmentBeforeTransaction |
|
|
// const grossHoldingPeriodReturn = valueOfInvestmentBeforeTransaction
|
|
|
.minus( |
|
|
// .minus(
|
|
|
lastValueOfInvestmentBeforeTransaction.plus( |
|
|
// lastValueOfInvestmentBeforeTransaction.plus(
|
|
|
lastTransactionInvestment |
|
|
// lastTransactionInvestment
|
|
|
) |
|
|
// )
|
|
|
) |
|
|
// )
|
|
|
.div( |
|
|
// .div(
|
|
|
lastValueOfInvestmentBeforeTransaction.plus( |
|
|
// lastValueOfInvestmentBeforeTransaction.plus(
|
|
|
lastTransactionInvestment |
|
|
// lastTransactionInvestment
|
|
|
) |
|
|
// )
|
|
|
); |
|
|
// );
|
|
|
|
|
|
|
|
|
timeWeightedGrossPerformancePercentage = |
|
|
// timeWeightedGrossPerformancePercentage =
|
|
|
timeWeightedGrossPerformancePercentage.mul( |
|
|
// timeWeightedGrossPerformancePercentage.mul(
|
|
|
new Big(1).plus(grossHoldingPeriodReturn) |
|
|
// new Big(1).plus(grossHoldingPeriodReturn)
|
|
|
); |
|
|
// );
|
|
|
|
|
|
|
|
|
const netHoldingPeriodReturn = valueOfInvestmentBeforeTransaction |
|
|
// const netHoldingPeriodReturn = valueOfInvestmentBeforeTransaction
|
|
|
.minus(fees.minus(feesAtStartDate)) |
|
|
// .minus(fees.minus(feesAtStartDate))
|
|
|
.minus( |
|
|
// .minus(
|
|
|
lastValueOfInvestmentBeforeTransaction.plus( |
|
|
// lastValueOfInvestmentBeforeTransaction.plus(
|
|
|
lastTransactionInvestment |
|
|
// lastTransactionInvestment
|
|
|
) |
|
|
// )
|
|
|
) |
|
|
// )
|
|
|
.div( |
|
|
// .div(
|
|
|
lastValueOfInvestmentBeforeTransaction.plus( |
|
|
// lastValueOfInvestmentBeforeTransaction.plus(
|
|
|
lastTransactionInvestment |
|
|
// lastTransactionInvestment
|
|
|
) |
|
|
// )
|
|
|
); |
|
|
// );
|
|
|
|
|
|
|
|
|
timeWeightedNetPerformancePercentage = |
|
|
// timeWeightedNetPerformancePercentage =
|
|
|
timeWeightedNetPerformancePercentage.mul( |
|
|
// timeWeightedNetPerformancePercentage.mul(
|
|
|
new Big(1).plus(netHoldingPeriodReturn) |
|
|
// new Big(1).plus(netHoldingPeriodReturn)
|
|
|
); |
|
|
// );
|
|
|
} |
|
|
// }
|
|
|
|
|
|
|
|
|
grossPerformance = newGrossPerformance; |
|
|
grossPerformance = newGrossPerformance; |
|
|
|
|
|
|
|
|
lastTransactionInvestment = transactionInvestment; |
|
|
// lastTransactionInvestment = transactionInvestment;
|
|
|
|
|
|
|
|
|
lastValueOfInvestmentBeforeTransaction = |
|
|
// lastValueOfInvestmentBeforeTransaction =
|
|
|
valueOfInvestmentBeforeTransaction; |
|
|
// valueOfInvestmentBeforeTransaction;
|
|
|
|
|
|
|
|
|
if (order.itemType === 'start') { |
|
|
if (order.itemType === 'start') { |
|
|
feesAtStartDate = fees; |
|
|
feesAtStartDate = fees; |
|
@ -1149,11 +1149,11 @@ export class PortfolioCalculator { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
timeWeightedGrossPerformancePercentage = |
|
|
// timeWeightedGrossPerformancePercentage =
|
|
|
timeWeightedGrossPerformancePercentage.minus(1); |
|
|
// timeWeightedGrossPerformancePercentage.minus(1);
|
|
|
|
|
|
|
|
|
timeWeightedNetPerformancePercentage = |
|
|
// timeWeightedNetPerformancePercentage =
|
|
|
timeWeightedNetPerformancePercentage.minus(1); |
|
|
// timeWeightedNetPerformancePercentage.minus(1);
|
|
|
|
|
|
|
|
|
const totalGrossPerformance = grossPerformance.minus( |
|
|
const totalGrossPerformance = grossPerformance.minus( |
|
|
grossPerformanceAtStartDate |
|
|
grossPerformanceAtStartDate |
|
|