Browse Source

Stake Handling

pull/5027/head
Dan 10 months ago
parent
commit
8141c66473
  1. 9
      apps/api/src/app/portfolio/calculator/twr/portfolio-calculator.ts

9
apps/api/src/app/portfolio/calculator/twr/portfolio-calculator.ts

@ -503,6 +503,13 @@ export class TWRPortfolioCalculator extends PortfolioCalculator {
.mul(order.quantity)
.mul(getFactor(order.type));
}
} else if (order.type === 'STAKE') {
transactionInvestment = new Big(0);
transactionInvestmentWithCurrencyEffect = new Big(0);
totalQuantityFromBuyTransactions =
totalQuantityFromBuyTransactions.plus(order.quantity);
}
if (PortfolioCalculator.ENABLE_LOGGING) {
@ -634,7 +641,7 @@ export class TWRPortfolioCalculator extends PortfolioCalculator {
// the time weighted investment
if (
valueOfInvestmentBeforeTransaction.gt(0) &&
['BUY', 'SELL'].includes(order.type)
['BUY', 'SELL', 'STAKE'].includes(order.type)
) {
// Calculate the number of days since the previous order
const orderDate = new Date(order.date);

Loading…
Cancel
Save