From 33de8a10bb967fe176eb0664ff9c6284bdc8ec53 Mon Sep 17 00:00:00 2001 From: ceroma <678940+ceroma@users.noreply.github.com> Date: Sat, 28 Sep 2024 05:23:35 -0300 Subject: [PATCH] Feature/optimize portfolio calculations with smarter cloning of activities (#3827) * Optimize portfolio calculations with smarter cloning of activities * Update changelog --- CHANGELOG.md | 1 + .../app/portfolio/calculator/twr/portfolio-calculator.ts | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0ee1f0c04..69be6319b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +- Optimized the portfolio calculations with smarter cloning of activities - Integrated the add currency functionality into the market data section of the admin control panel - Improved the language localization for German (`de`) - Upgraded `prisma` from version `5.19.1` to `5.20.0` diff --git a/apps/api/src/app/portfolio/calculator/twr/portfolio-calculator.ts b/apps/api/src/app/portfolio/calculator/twr/portfolio-calculator.ts index fba0ead84..3b64cd185 100644 --- a/apps/api/src/app/portfolio/calculator/twr/portfolio-calculator.ts +++ b/apps/api/src/app/portfolio/calculator/twr/portfolio-calculator.ts @@ -180,10 +180,10 @@ export class TWRPortfolioCalculator extends PortfolioCalculator { let valueAtStartDateWithCurrencyEffect: Big; // Clone orders to keep the original values in this.orders - let orders: PortfolioOrderItem[] = cloneDeep(this.activities).filter( - ({ SymbolProfile }) => { + let orders: PortfolioOrderItem[] = cloneDeep( + this.activities.filter(({ SymbolProfile }) => { return SymbolProfile.symbol === symbol; - } + }) ); if (orders.length <= 0) {