From 2268a758adb652726fed593665a59156dc1da0c5 Mon Sep 17 00:00:00 2001 From: KenTandrian Date: Fri, 6 Jun 2025 12:16:20 +0700 Subject: [PATCH] fix(lib): add NaN check to growth factor --- libs/common/src/lib/calculation-helper.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libs/common/src/lib/calculation-helper.ts b/libs/common/src/lib/calculation-helper.ts index 4292f2383..76ae3eae6 100644 --- a/libs/common/src/lib/calculation-helper.ts +++ b/libs/common/src/lib/calculation-helper.ts @@ -23,10 +23,12 @@ export function getAnnualizedPerformancePercent({ }): Big { if (isNumber(daysInMarket) && daysInMarket > 0) { const exponent = new Big(365).div(daysInMarket).toNumber(); + const growthFactor = Math.pow( + netPerformancePercentage.plus(1).toNumber(), + exponent + ); - return new Big( - Math.pow(netPerformancePercentage.plus(1).toNumber(), exponent) - ).minus(1); + return !isNaN(growthFactor) ? new Big(growthFactor).minus(1) : new Big(0); } return new Big(0);