diff --git a/apps/api/src/app/benchmark/benchmark.service.ts b/apps/api/src/app/benchmark/benchmark.service.ts index 59d0bd296..2547e57cc 100644 --- a/apps/api/src/app/benchmark/benchmark.service.ts +++ b/apps/api/src/app/benchmark/benchmark.service.ts @@ -64,7 +64,7 @@ export class BenchmarkService { const benchmarkAssetProfiles = await this.getBenchmarkAssetProfiles(); - const promises: Promise<{ marketPrice: number; date: Date }>[] = []; + const promises: Promise<{ date: Date; marketPrice: number }>[] = []; const quotes = await this.dataProviderService.getQuotes({ items: benchmarkAssetProfiles.map(({ dataSource, symbol }) => { @@ -85,7 +85,7 @@ export class BenchmarkService { let performancePercentFromAllTimeHigh = 0; - if (allTimeHigh && allTimeHigh.marketPrice && marketPrice) { + if (allTimeHigh?.marketPrice && marketPrice) { performancePercentFromAllTimeHigh = this.calculateChangeInPercentage( allTimeHigh.marketPrice, marketPrice @@ -100,8 +100,8 @@ export class BenchmarkService { name: benchmarkAssetProfiles[index].name, performances: { allTimeHigh: { - performancePercent: performancePercentFromAllTimeHigh, - date: allTimeHigh.date + date: allTimeHigh.date, + performancePercent: performancePercentFromAllTimeHigh } } }; diff --git a/apps/api/src/services/market-data/market-data.service.ts b/apps/api/src/services/market-data/market-data.service.ts index 724cce689..5760096bf 100644 --- a/apps/api/src/services/market-data/market-data.service.ts +++ b/apps/api/src/services/market-data/market-data.service.ts @@ -39,27 +39,22 @@ export class MarketDataService { }); } - public async getMax({ - dataSource, - symbol - }: UniqueAsset): Promise<{ marketPrice: number; date: Date }> { - const highestMarketPriceDataRow = - await this.prismaService.marketData.findFirst({ - select: { - marketPrice: true, - date: true - }, - where: { - dataSource, - symbol - }, - orderBy: [ - { - marketPrice: 'desc' - } - ] - }); - return highestMarketPriceDataRow; + public async getMax({ dataSource, symbol }: UniqueAsset) { + return this.prismaService.marketData.findFirst({ + select: { + date: true, + marketPrice: true + }, + orderBy: [ + { + marketPrice: 'desc' + } + ], + where: { + dataSource, + symbol + } + }); } public async getRange({ diff --git a/libs/common/src/lib/interfaces/benchmark.interface.ts b/libs/common/src/lib/interfaces/benchmark.interface.ts index ac476c427..d1a63e1f4 100644 --- a/libs/common/src/lib/interfaces/benchmark.interface.ts +++ b/libs/common/src/lib/interfaces/benchmark.interface.ts @@ -5,8 +5,8 @@ export interface Benchmark { name: EnhancedSymbolProfile['name']; performances: { allTimeHigh: { - performancePercent: number; date: Date; + performancePercent: number; }; }; }