Feature/harmonize big.js operators (#686)

* Harmonize big.js operators

* Update changelog
pull/687/head
Thomas Kaul 2 years ago committed by GitHub
parent 6eb4eae4a9
commit 86943a5f5b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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 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
### Fixed

@ -82,7 +82,7 @@ export class PortfolioCalculatorNew {
: unitPrice
.mul(order.quantity)
.mul(factor)
.add(oldAccumulatedSymbol.investment),
.plus(oldAccumulatedSymbol.investment),
quantity: newQuantity,
symbol: order.symbol,
transactionCount: oldAccumulatedSymbol.transactionCount + 1
@ -452,7 +452,7 @@ export class PortfolioCalculatorNew {
.eq(0)
) {
const grossHoldingPeriodReturn = valueOfInvestmentBeforeTransaction
.sub(
.minus(
lastValueOfInvestmentBeforeTransaction.plus(
lastTransactionInvestment
)
@ -469,8 +469,8 @@ export class PortfolioCalculatorNew {
);
const netHoldingPeriodReturn = valueOfInvestmentBeforeTransaction
.sub(fees.minus(feesAtStartDate))
.sub(
.minus(fees.minus(feesAtStartDate))
.minus(
lastValueOfInvestmentBeforeTransaction.plus(
lastTransactionInvestment
)
@ -509,10 +509,10 @@ export class PortfolioCalculatorNew {
}
timeWeightedGrossPerformancePercentage =
timeWeightedGrossPerformancePercentage.sub(1);
timeWeightedGrossPerformancePercentage.minus(1);
timeWeightedNetPerformancePercentage =
timeWeightedNetPerformancePercentage.sub(1);
timeWeightedNetPerformancePercentage.minus(1);
const totalGrossPerformance = grossPerformance.minus(
grossPerformanceAtStartDate
@ -525,7 +525,7 @@ export class PortfolioCalculatorNew {
let valueOfInvestmentSum = new Big(0);
for (const holdingPeriodPerformance of holdingPeriodPerformances) {
valueOfInvestmentSum = valueOfInvestmentSum.add(
valueOfInvestmentSum = valueOfInvestmentSum.plus(
holdingPeriodPerformance.valueOfInvestment
);
}
@ -568,7 +568,7 @@ export class PortfolioCalculatorNew {
date: transactionPoint.date,
investment: transactionPoint.items.reduce(
(investment, transactionPointSymbol) =>
investment.add(transactionPointSymbol.investment),
investment.plus(transactionPointSymbol.investment),
new Big(0)
)
};
@ -685,13 +685,13 @@ export class PortfolioCalculatorNew {
for (const currentPosition of positions) {
if (currentPosition.marketPrice) {
currentValue = currentValue.add(
currentValue = currentValue.plus(
new Big(currentPosition.marketPrice).mul(currentPosition.quantity)
);
} else {
hasErrors = true;
}
totalInvestment = totalInvestment.add(currentPosition.investment);
totalInvestment = totalInvestment.plus(currentPosition.investment);
if (currentPosition.grossPerformance) {
grossPerformance = grossPerformance.plus(
currentPosition.grossPerformance
@ -760,8 +760,8 @@ export class PortfolioCalculatorNew {
dataSource: item.dataSource,
symbol: item.symbol
});
investment = investment.add(item.investment);
fees = fees.add(item.fee);
investment = investment.plus(item.investment);
fees = fees.plus(item.fee);
}
let marketSymbols: GetValueObject[] = [];
@ -817,7 +817,7 @@ export class PortfolioCalculatorNew {
invalid = true;
break;
}
value = value.add(
value = value.plus(
item.quantity.mul(marketSymbolMap[currentDateAsString][item.symbol])
);
}

@ -69,7 +69,7 @@ export class PortfolioCalculator {
: unitPrice
.mul(order.quantity)
.mul(factor)
.add(oldAccumulatedSymbol.investment),
.plus(oldAccumulatedSymbol.investment),
quantity: newQuantity,
symbol: order.symbol,
transactionCount: oldAccumulatedSymbol.transactionCount + 1
@ -354,7 +354,7 @@ export class PortfolioCalculator {
date: transactionPoint.date,
investment: transactionPoint.items.reduce(
(investment, transactionPointSymbol) =>
investment.add(transactionPointSymbol.investment),
investment.plus(transactionPointSymbol.investment),
new Big(0)
)
};
@ -475,13 +475,13 @@ export class PortfolioCalculator {
for (const currentPosition of positions) {
if (currentPosition.marketPrice) {
currentValue = currentValue.add(
currentValue = currentValue.plus(
new Big(currentPosition.marketPrice).mul(currentPosition.quantity)
);
} else {
hasErrors = true;
}
totalInvestment = totalInvestment.add(currentPosition.investment);
totalInvestment = totalInvestment.plus(currentPosition.investment);
if (currentPosition.grossPerformance) {
grossPerformance = grossPerformance.plus(
currentPosition.grossPerformance
@ -562,8 +562,8 @@ export class PortfolioCalculator {
dataSource: item.dataSource,
symbol: item.symbol
});
investment = investment.add(item.investment);
fees = fees.add(item.fee);
investment = investment.plus(item.investment);
fees = fees.plus(item.fee);
}
let marketSymbols: GetValueObject[] = [];
@ -619,7 +619,7 @@ export class PortfolioCalculator {
invalid = true;
break;
}
value = value.add(
value = value.plus(
item.quantity.mul(marketSymbolMap[currentDateAsString][item.symbol])
);
}

@ -895,7 +895,7 @@ export class PortfolioServiceNew {
const totalBuy = this.getTotalByType(orders, userCurrency, 'BUY');
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)
.plus(performanceInformation.performance.currentValue)

@ -873,7 +873,7 @@ export class PortfolioService {
const totalBuy = this.getTotalByType(orders, userCurrency, 'BUY');
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)
.plus(performanceInformation.performance.currentValue)

Loading…
Cancel
Save