diff --git a/apps/api/src/app/portfolio/portfolio.service.ts b/apps/api/src/app/portfolio/portfolio.service.ts index d0baa06b8..082721701 100644 --- a/apps/api/src/app/portfolio/portfolio.service.ts +++ b/apps/api/src/app/portfolio/portfolio.service.ts @@ -317,14 +317,21 @@ export class PortfolioService { withDataDecimation: false }); - let investments = items.map( - ({ date, investmentValueWithCurrencyEffect }) => { + let investments: InvestmentItem[]; + + if (groupBy) { + investments = portfolioCalculator.getInvestmentsByGroup({ + groupBy, + data: items + }); + } else { + investments = items.map(({ date, investmentValueWithCurrencyEffect }) => { return { date, investment: investmentValueWithCurrencyEffect }; - } - ); + }); + } let streaks: PortfolioInvestments['streaks'];