From f4b3a671c75ca76eff2d0ec22db0811908e6286c Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Sat, 13 Jun 2026 17:08:59 +0200 Subject: [PATCH] Task/optimize portfolio holding endpoint by improving processing of historical market data (#7023) * Improve processing of historical market data * Update changelog --- CHANGELOG.md | 1 + .../src/services/data-provider/data-provider.service.ts | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 021e69a07..ab6db98a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Improved the dynamic numerical precision for various values in the account detail dialog on mobile - Improved the dynamic numerical precision for various values in the holding detail dialog on mobile +- Optimized the endpoint `GET api/v1/portfolio/holding/:dataSource/:symbol` by improving the processing of the historical market data ### Fixed diff --git a/apps/api/src/services/data-provider/data-provider.service.ts b/apps/api/src/services/data-provider/data-provider.service.ts index 1ea2d6436..5b54afb0b 100644 --- a/apps/api/src/services/data-provider/data-provider.service.ts +++ b/apps/api/src/services/data-provider/data-provider.service.ts @@ -385,10 +385,11 @@ export class DataProviderService implements OnModuleInit { response = marketDataByGranularity.reduce((r, marketData) => { const { date, marketPrice, symbol } = marketData; - r[symbol] = { - ...(r[symbol] || {}), - [format(new Date(date), DATE_FORMAT)]: { marketPrice } - }; + if (!r[symbol]) { + r[symbol] = {}; + } + + r[symbol][format(new Date(date), DATE_FORMAT)] = { marketPrice }; return r; }, {});