|
|
@ -532,15 +532,18 @@ export class RoaiPortfolioCalculator extends PortfolioCalculator { |
|
|
); |
|
|
); |
|
|
} else if (order.type === 'SELL') { |
|
|
} else if (order.type === 'SELL') { |
|
|
if (totalUnits.gt(0)) { |
|
|
if (totalUnits.gt(0)) { |
|
|
|
|
|
const remainingUnits = totalUnits.minus(order.quantity); |
|
|
|
|
|
|
|
|
transactionInvestment = totalInvestment |
|
|
transactionInvestment = totalInvestment |
|
|
|
|
|
.mul(remainingUnits) |
|
|
.div(totalUnits) |
|
|
.div(totalUnits) |
|
|
.mul(order.quantity) |
|
|
.minus(totalInvestment); |
|
|
.mul(getFactor(order.type)); |
|
|
|
|
|
transactionInvestmentWithCurrencyEffect = |
|
|
transactionInvestmentWithCurrencyEffect = |
|
|
totalInvestmentWithCurrencyEffect |
|
|
totalInvestmentWithCurrencyEffect |
|
|
|
|
|
.mul(remainingUnits) |
|
|
.div(totalUnits) |
|
|
.div(totalUnits) |
|
|
.mul(order.quantity) |
|
|
.minus(totalInvestmentWithCurrencyEffect); |
|
|
.mul(getFactor(order.type)); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -636,10 +639,8 @@ export class RoaiPortfolioCalculator extends PortfolioCalculator { |
|
|
|
|
|
|
|
|
if (totalUnits.eq(0)) { |
|
|
if (totalUnits.eq(0)) { |
|
|
// Reset tracking variables when position is fully closed
|
|
|
// Reset tracking variables when position is fully closed
|
|
|
totalInvestment = new Big(0); |
|
|
|
|
|
totalInvestmentFromBuyTransactions = new Big(0); |
|
|
totalInvestmentFromBuyTransactions = new Big(0); |
|
|
totalInvestmentFromBuyTransactionsWithCurrencyEffect = new Big(0); |
|
|
totalInvestmentFromBuyTransactionsWithCurrencyEffect = new Big(0); |
|
|
totalInvestmentWithCurrencyEffect = new Big(0); |
|
|
|
|
|
totalQuantityFromBuyTransactions = new Big(0); |
|
|
totalQuantityFromBuyTransactions = new Big(0); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|