From e8f185e484c0e74608800f054b5b2c30bd33ecfb Mon Sep 17 00:00:00 2001 From: Kenrick Tandrian <60643640+KenTandrian@users.noreply.github.com> Date: Sat, 7 Jun 2025 13:31:55 +0700 Subject: [PATCH] Bugfix/fix issue in annualized performance calculation (#4840) * Fix issue in annualized performance calculation * Update changelog --- CHANGELOG.md | 1 + libs/common/src/lib/calculation-helper.ts | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e443f44e8..706edd865 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Fixed an issue where the import button was not correctly enabled in the import activities dialog +- Fixed an issue in the annualized performance calculation ## 2.166.0 - 2025-06-05 diff --git a/libs/common/src/lib/calculation-helper.ts b/libs/common/src/lib/calculation-helper.ts index 4292f2383..d67384a30 100644 --- a/libs/common/src/lib/calculation-helper.ts +++ b/libs/common/src/lib/calculation-helper.ts @@ -23,10 +23,14 @@ 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); + if (!isNaN(growthFactor)) { + return new Big(growthFactor).minus(1); + } } return new Big(0);