Skip to content

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

Bugfix/missing benchmark in performance chart for calendar year date ranges (#7631)

Aaryaman Vyas38b5d73c757b
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 29d0e85f1e..a27af813e4 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 4b6a3f1c9d..beff7ffa60 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
)}`
);