From fd5d4bb4455b17c0d6e6e05f693cb1153fd78246 Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Mon, 13 Oct 2025 20:53:44 +0200 Subject: [PATCH] Refactoring --- apps/api/src/app/portfolio/portfolio.service.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/apps/api/src/app/portfolio/portfolio.service.ts b/apps/api/src/app/portfolio/portfolio.service.ts index b8f34b60a..53bfc7679 100644 --- a/apps/api/src/app/portfolio/portfolio.service.ts +++ b/apps/api/src/app/portfolio/portfolio.service.ts @@ -671,11 +671,15 @@ export class PortfolioService { // Gather historical exchange rate data for all currencies in cash positions const exchangeRatesByCurrency = await this.exchangeRateDataService.getExchangeRatesByCurrency({ - currencies: [ - ...new Set(cashDetails.accounts.map(({ currency }) => currency)) - ], endDate, startDate, + currencies: [ + ...new Set( + cashDetails.accounts.map(({ currency }) => { + return currency; + }) + ) + ], targetCurrency: userCurrency }); @@ -1694,8 +1698,10 @@ export class PortfolioService { if (cashPositions[account.currency]) { cashPositions[account.currency].investment += convertedBalance; + cashPositions[account.currency].netPerformanceWithCurrencyEffect += netPerformanceWithCurrencyEffect; + cashPositions[account.currency].valueInBaseCurrency += convertedBalance; } else { cashPositions[account.currency] = this.getInitialCashPosition({ @@ -1715,6 +1721,7 @@ export class PortfolioService { .div(value) .toNumber() : 0; + cashPositions[symbol].netPerformancePercentWithCurrencyEffect = cashPositions[symbol].investment > 0 ? new Big(cashPositions[symbol].netPerformanceWithCurrencyEffect)