Feature/harmonize big.js operators (#686)
* Harmonize big.js operators * Update changelog
This commit is contained in:
parent
6eb4eae4a9
commit
86943a5f5b
@ -12,6 +12,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
- Improved the position of the currency column in the accounts table
|
- Improved the position of the currency column in the accounts table
|
||||||
- Improved the position of the currency column in the activities table
|
- Improved the position of the currency column in the activities table
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed an issue with the performance calculation in connection with fees in the new calculation engine
|
||||||
|
|
||||||
## 1.112.1 - 06.02.2022
|
## 1.112.1 - 06.02.2022
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
@ -82,7 +82,7 @@ export class PortfolioCalculatorNew {
|
|||||||
: unitPrice
|
: unitPrice
|
||||||
.mul(order.quantity)
|
.mul(order.quantity)
|
||||||
.mul(factor)
|
.mul(factor)
|
||||||
.add(oldAccumulatedSymbol.investment),
|
.plus(oldAccumulatedSymbol.investment),
|
||||||
quantity: newQuantity,
|
quantity: newQuantity,
|
||||||
symbol: order.symbol,
|
symbol: order.symbol,
|
||||||
transactionCount: oldAccumulatedSymbol.transactionCount + 1
|
transactionCount: oldAccumulatedSymbol.transactionCount + 1
|
||||||
@ -452,7 +452,7 @@ export class PortfolioCalculatorNew {
|
|||||||
.eq(0)
|
.eq(0)
|
||||||
) {
|
) {
|
||||||
const grossHoldingPeriodReturn = valueOfInvestmentBeforeTransaction
|
const grossHoldingPeriodReturn = valueOfInvestmentBeforeTransaction
|
||||||
.sub(
|
.minus(
|
||||||
lastValueOfInvestmentBeforeTransaction.plus(
|
lastValueOfInvestmentBeforeTransaction.plus(
|
||||||
lastTransactionInvestment
|
lastTransactionInvestment
|
||||||
)
|
)
|
||||||
@ -469,8 +469,8 @@ export class PortfolioCalculatorNew {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const netHoldingPeriodReturn = valueOfInvestmentBeforeTransaction
|
const netHoldingPeriodReturn = valueOfInvestmentBeforeTransaction
|
||||||
.sub(fees.minus(feesAtStartDate))
|
.minus(fees.minus(feesAtStartDate))
|
||||||
.sub(
|
.minus(
|
||||||
lastValueOfInvestmentBeforeTransaction.plus(
|
lastValueOfInvestmentBeforeTransaction.plus(
|
||||||
lastTransactionInvestment
|
lastTransactionInvestment
|
||||||
)
|
)
|
||||||
@ -509,10 +509,10 @@ export class PortfolioCalculatorNew {
|
|||||||
}
|
}
|
||||||
|
|
||||||
timeWeightedGrossPerformancePercentage =
|
timeWeightedGrossPerformancePercentage =
|
||||||
timeWeightedGrossPerformancePercentage.sub(1);
|
timeWeightedGrossPerformancePercentage.minus(1);
|
||||||
|
|
||||||
timeWeightedNetPerformancePercentage =
|
timeWeightedNetPerformancePercentage =
|
||||||
timeWeightedNetPerformancePercentage.sub(1);
|
timeWeightedNetPerformancePercentage.minus(1);
|
||||||
|
|
||||||
const totalGrossPerformance = grossPerformance.minus(
|
const totalGrossPerformance = grossPerformance.minus(
|
||||||
grossPerformanceAtStartDate
|
grossPerformanceAtStartDate
|
||||||
@ -525,7 +525,7 @@ export class PortfolioCalculatorNew {
|
|||||||
let valueOfInvestmentSum = new Big(0);
|
let valueOfInvestmentSum = new Big(0);
|
||||||
|
|
||||||
for (const holdingPeriodPerformance of holdingPeriodPerformances) {
|
for (const holdingPeriodPerformance of holdingPeriodPerformances) {
|
||||||
valueOfInvestmentSum = valueOfInvestmentSum.add(
|
valueOfInvestmentSum = valueOfInvestmentSum.plus(
|
||||||
holdingPeriodPerformance.valueOfInvestment
|
holdingPeriodPerformance.valueOfInvestment
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -568,7 +568,7 @@ export class PortfolioCalculatorNew {
|
|||||||
date: transactionPoint.date,
|
date: transactionPoint.date,
|
||||||
investment: transactionPoint.items.reduce(
|
investment: transactionPoint.items.reduce(
|
||||||
(investment, transactionPointSymbol) =>
|
(investment, transactionPointSymbol) =>
|
||||||
investment.add(transactionPointSymbol.investment),
|
investment.plus(transactionPointSymbol.investment),
|
||||||
new Big(0)
|
new Big(0)
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
@ -685,13 +685,13 @@ export class PortfolioCalculatorNew {
|
|||||||
|
|
||||||
for (const currentPosition of positions) {
|
for (const currentPosition of positions) {
|
||||||
if (currentPosition.marketPrice) {
|
if (currentPosition.marketPrice) {
|
||||||
currentValue = currentValue.add(
|
currentValue = currentValue.plus(
|
||||||
new Big(currentPosition.marketPrice).mul(currentPosition.quantity)
|
new Big(currentPosition.marketPrice).mul(currentPosition.quantity)
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
hasErrors = true;
|
hasErrors = true;
|
||||||
}
|
}
|
||||||
totalInvestment = totalInvestment.add(currentPosition.investment);
|
totalInvestment = totalInvestment.plus(currentPosition.investment);
|
||||||
if (currentPosition.grossPerformance) {
|
if (currentPosition.grossPerformance) {
|
||||||
grossPerformance = grossPerformance.plus(
|
grossPerformance = grossPerformance.plus(
|
||||||
currentPosition.grossPerformance
|
currentPosition.grossPerformance
|
||||||
@ -760,8 +760,8 @@ export class PortfolioCalculatorNew {
|
|||||||
dataSource: item.dataSource,
|
dataSource: item.dataSource,
|
||||||
symbol: item.symbol
|
symbol: item.symbol
|
||||||
});
|
});
|
||||||
investment = investment.add(item.investment);
|
investment = investment.plus(item.investment);
|
||||||
fees = fees.add(item.fee);
|
fees = fees.plus(item.fee);
|
||||||
}
|
}
|
||||||
|
|
||||||
let marketSymbols: GetValueObject[] = [];
|
let marketSymbols: GetValueObject[] = [];
|
||||||
@ -817,7 +817,7 @@ export class PortfolioCalculatorNew {
|
|||||||
invalid = true;
|
invalid = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
value = value.add(
|
value = value.plus(
|
||||||
item.quantity.mul(marketSymbolMap[currentDateAsString][item.symbol])
|
item.quantity.mul(marketSymbolMap[currentDateAsString][item.symbol])
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,7 @@ export class PortfolioCalculator {
|
|||||||
: unitPrice
|
: unitPrice
|
||||||
.mul(order.quantity)
|
.mul(order.quantity)
|
||||||
.mul(factor)
|
.mul(factor)
|
||||||
.add(oldAccumulatedSymbol.investment),
|
.plus(oldAccumulatedSymbol.investment),
|
||||||
quantity: newQuantity,
|
quantity: newQuantity,
|
||||||
symbol: order.symbol,
|
symbol: order.symbol,
|
||||||
transactionCount: oldAccumulatedSymbol.transactionCount + 1
|
transactionCount: oldAccumulatedSymbol.transactionCount + 1
|
||||||
@ -354,7 +354,7 @@ export class PortfolioCalculator {
|
|||||||
date: transactionPoint.date,
|
date: transactionPoint.date,
|
||||||
investment: transactionPoint.items.reduce(
|
investment: transactionPoint.items.reduce(
|
||||||
(investment, transactionPointSymbol) =>
|
(investment, transactionPointSymbol) =>
|
||||||
investment.add(transactionPointSymbol.investment),
|
investment.plus(transactionPointSymbol.investment),
|
||||||
new Big(0)
|
new Big(0)
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
@ -475,13 +475,13 @@ export class PortfolioCalculator {
|
|||||||
|
|
||||||
for (const currentPosition of positions) {
|
for (const currentPosition of positions) {
|
||||||
if (currentPosition.marketPrice) {
|
if (currentPosition.marketPrice) {
|
||||||
currentValue = currentValue.add(
|
currentValue = currentValue.plus(
|
||||||
new Big(currentPosition.marketPrice).mul(currentPosition.quantity)
|
new Big(currentPosition.marketPrice).mul(currentPosition.quantity)
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
hasErrors = true;
|
hasErrors = true;
|
||||||
}
|
}
|
||||||
totalInvestment = totalInvestment.add(currentPosition.investment);
|
totalInvestment = totalInvestment.plus(currentPosition.investment);
|
||||||
if (currentPosition.grossPerformance) {
|
if (currentPosition.grossPerformance) {
|
||||||
grossPerformance = grossPerformance.plus(
|
grossPerformance = grossPerformance.plus(
|
||||||
currentPosition.grossPerformance
|
currentPosition.grossPerformance
|
||||||
@ -562,8 +562,8 @@ export class PortfolioCalculator {
|
|||||||
dataSource: item.dataSource,
|
dataSource: item.dataSource,
|
||||||
symbol: item.symbol
|
symbol: item.symbol
|
||||||
});
|
});
|
||||||
investment = investment.add(item.investment);
|
investment = investment.plus(item.investment);
|
||||||
fees = fees.add(item.fee);
|
fees = fees.plus(item.fee);
|
||||||
}
|
}
|
||||||
|
|
||||||
let marketSymbols: GetValueObject[] = [];
|
let marketSymbols: GetValueObject[] = [];
|
||||||
@ -619,7 +619,7 @@ export class PortfolioCalculator {
|
|||||||
invalid = true;
|
invalid = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
value = value.add(
|
value = value.plus(
|
||||||
item.quantity.mul(marketSymbolMap[currentDateAsString][item.symbol])
|
item.quantity.mul(marketSymbolMap[currentDateAsString][item.symbol])
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -895,7 +895,7 @@ export class PortfolioServiceNew {
|
|||||||
const totalBuy = this.getTotalByType(orders, userCurrency, 'BUY');
|
const totalBuy = this.getTotalByType(orders, userCurrency, 'BUY');
|
||||||
const totalSell = this.getTotalByType(orders, userCurrency, 'SELL');
|
const totalSell = this.getTotalByType(orders, userCurrency, 'SELL');
|
||||||
|
|
||||||
const committedFunds = new Big(totalBuy).sub(totalSell);
|
const committedFunds = new Big(totalBuy).minus(totalSell);
|
||||||
|
|
||||||
const netWorth = new Big(balance)
|
const netWorth = new Big(balance)
|
||||||
.plus(performanceInformation.performance.currentValue)
|
.plus(performanceInformation.performance.currentValue)
|
||||||
|
@ -873,7 +873,7 @@ export class PortfolioService {
|
|||||||
const totalBuy = this.getTotalByType(orders, userCurrency, 'BUY');
|
const totalBuy = this.getTotalByType(orders, userCurrency, 'BUY');
|
||||||
const totalSell = this.getTotalByType(orders, userCurrency, 'SELL');
|
const totalSell = this.getTotalByType(orders, userCurrency, 'SELL');
|
||||||
|
|
||||||
const committedFunds = new Big(totalBuy).sub(totalSell);
|
const committedFunds = new Big(totalBuy).minus(totalSell);
|
||||||
|
|
||||||
const netWorth = new Big(balance)
|
const netWorth = new Big(balance)
|
||||||
.plus(performanceInformation.performance.currentValue)
|
.plus(performanceInformation.performance.currentValue)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user