Open Source Wealth Management Software. Angular + NestJS + Prisma + Nx + TypeScript 🤍
TypeScript angularetffinancefintechghostfoliohacktoberfestinvestingnestjsosspersonal-financeportfolioprismasoftwarestocktrackertradingtypescriptwealth-managementweb
Handle division by zero (#1398)
Thomas Kaul5c6cc4fed595
diff --git a/apps/api/src/app/portfolio/portfolio-calculator.ts b/apps/api/src/app/portfolio/portfolio-calculator.tsindex ea1f8e10c1..4a09141ca6 100644--- a/apps/api/src/app/portfolio/portfolio-calculator.ts+++ b/apps/api/src/app/portfolio/portfolio-calculator.ts@@ -1036,10 +1036,12 @@ export class PortfolioCalculator {const transactionInvestment =order.type === 'BUY'? order.quantity.mul(order.unitPrice).mul(this.getFactor(order.type))- : totalInvestment+ : totalUnits.gt(0)+ ? totalInvestment.div(totalUnits).mul(order.quantity)- .mul(this.getFactor(order.type));+ .mul(this.getFactor(order.type))+ : new Big(0);if (PortfolioCalculator.ENABLE_LOGGING) {console.log('totalInvestment', totalInvestment.toNumber());