Browse Source

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
pull/7726/head
Aaryaman Vyas 3 days ago
committed by GitHub
parent
commit
38b5d73c75
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 1
      CHANGELOG.md
  2. 12
      apps/api/src/app/endpoints/benchmarks/benchmarks.service.ts

1
CHANGELOG.md

@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed ### 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 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 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 - Fixed the asset profile data gathering of a symbol in the admin control panel by removing an existing job before enqueueing a new one

12
apps/api/src/app/endpoints/benchmarks/benchmarks.service.ts

@ -88,6 +88,12 @@ export class BenchmarksService {
return { marketData }; return { marketData };
} }
if (chart.length === 0) {
return { marketData };
}
const baselineDate = resetHours(parseDate(chart[0].date));
const exchangeRates = const exchangeRates =
await this.exchangeRateDataService.getExchangeRatesByCurrency({ await this.exchangeRateDataService.getExchangeRatesByCurrency({
startDate, startDate,
@ -97,17 +103,17 @@ export class BenchmarksService {
const exchangeRateAtStartDate = const exchangeRateAtStartDate =
exchangeRates[`${currentSymbolItem.currency}${userCurrency}`]?.[ exchangeRates[`${currentSymbolItem.currency}${userCurrency}`]?.[
format(startDate, DATE_FORMAT) format(baselineDate, DATE_FORMAT)
]; ];
const marketPriceAtStartDate = marketDataItems?.find(({ date }) => { const marketPriceAtStartDate = marketDataItems?.find(({ date }) => {
return isSameDay(date, startDate); return isSameDay(date, baselineDate);
})?.marketPrice; })?.marketPrice;
if (!marketPriceAtStartDate) { if (!marketPriceAtStartDate) {
this.logger.error( this.logger.error(
`No historical market data has been found for ${symbol} (${dataSource}) at ${format( `No historical market data has been found for ${symbol} (${dataSource}) at ${format(
startDate, baselineDate,
DATE_FORMAT DATE_FORMAT
)}` )}`
); );

Loading…
Cancel
Save