From 38b5d73c757babdec4f2773b837e578a8d2c3a32 Mon Sep 17 00:00:00 2001 From: Aaryaman Vyas <163023807+AaryamanVyas@users.noreply.github.com> Date: Wed, 26 Aug 2026 00:11:33 +0530 Subject: [PATCH] Bugfix/missing benchmark in performance chart for calendar year date ranges (#7631) * Fix missing benchmark in performance chart for calendar year date ranges * Update changelog --- CHANGELOG.md | 1 + .../app/endpoints/benchmarks/benchmarks.service.ts | 12 +++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 29d0e85f1..a27af813e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed +- Fixed the missing benchmark in the performance chart for calendar year date ranges on the analysis page - Fixed the country mapping of Macau in the _Financial Modeling Prep_ service - Fixed the asset profile and historical market data gathering of a symbol getting blocked permanently by a failed job by discarding the failed jobs - Fixed the asset profile data gathering of a symbol in the admin control panel by removing an existing job before enqueueing a new one diff --git a/apps/api/src/app/endpoints/benchmarks/benchmarks.service.ts b/apps/api/src/app/endpoints/benchmarks/benchmarks.service.ts index 4b6a3f1c9..beff7ffa6 100644 --- a/apps/api/src/app/endpoints/benchmarks/benchmarks.service.ts +++ b/apps/api/src/app/endpoints/benchmarks/benchmarks.service.ts @@ -88,6 +88,12 @@ export class BenchmarksService { return { marketData }; } + if (chart.length === 0) { + return { marketData }; + } + + const baselineDate = resetHours(parseDate(chart[0].date)); + const exchangeRates = await this.exchangeRateDataService.getExchangeRatesByCurrency({ startDate, @@ -97,17 +103,17 @@ export class BenchmarksService { const exchangeRateAtStartDate = exchangeRates[`${currentSymbolItem.currency}${userCurrency}`]?.[ - format(startDate, DATE_FORMAT) + format(baselineDate, DATE_FORMAT) ]; const marketPriceAtStartDate = marketDataItems?.find(({ date }) => { - return isSameDay(date, startDate); + return isSameDay(date, baselineDate); })?.marketPrice; if (!marketPriceAtStartDate) { this.logger.error( `No historical market data has been found for ${symbol} (${dataSource}) at ${format( - startDate, + baselineDate, DATE_FORMAT )}` );