Skip to content

Open Source Wealth Management Software. Angular + NestJS + Prisma + Nx + TypeScript 🤍

Feature/optimize portfolio calculations with smarter cloning of activities (#3827)

ceroma33de8a10bb96
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0ee1f0c042..69be6319bc 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 fba0ead84e..3b64cd185c 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) {