diff --git a/CHANGELOG.md b/CHANGELOG.md index dcecac253..7cdca7fc4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +### Added + +- Extended the benchmarks of the markets overview by the current market condition (all time high) + ### Changed - Upgraded `prisma` from version `5.6.0` to `5.7.0` diff --git a/apps/api/src/app/benchmark/benchmark.service.ts b/apps/api/src/app/benchmark/benchmark.service.ts index 93f4ecc9b..cbd5e7e1f 100644 --- a/apps/api/src/app/benchmark/benchmark.service.ts +++ b/apps/api/src/app/benchmark/benchmark.service.ts @@ -14,6 +14,7 @@ import { calculateBenchmarkTrend } from '@ghostfolio/common/helper'; import { + Benchmark, BenchmarkMarketDataDetails, BenchmarkProperty, BenchmarkResponse, @@ -339,7 +340,15 @@ export class BenchmarkService { }; } - private getMarketCondition(aPerformanceInPercent: number) { - return aPerformanceInPercent <= -0.2 ? 'BEAR_MARKET' : 'NEUTRAL_MARKET'; + private getMarketCondition( + aPerformanceInPercent: number + ): Benchmark['marketCondition'] { + if (aPerformanceInPercent === 0) { + return 'ALL_TIME_HIGH'; + } else if (aPerformanceInPercent <= -0.2) { + return 'BEAR_MARKET'; + } else { + return 'NEUTRAL_MARKET'; + } } } diff --git a/libs/common/src/lib/helper.ts b/libs/common/src/lib/helper.ts index 0ca83e3ba..16d5d041b 100644 --- a/libs/common/src/lib/helper.ts +++ b/libs/common/src/lib/helper.ts @@ -381,10 +381,10 @@ export function resolveFearAndGreedIndex(aValue: number) { export function resolveMarketCondition( aMarketCondition: Benchmark['marketCondition'] ) { - if (aMarketCondition === 'BEAR_MARKET') { + if (aMarketCondition === 'ALL_TIME_HIGH') { + return { emoji: '🎉' }; + } else if (aMarketCondition === 'BEAR_MARKET') { return { emoji: '🐻' }; - } else if (aMarketCondition === 'BULL_MARKET') { - return { emoji: '🐮' }; } else { return { emoji: '⚪' }; } diff --git a/libs/common/src/lib/interfaces/benchmark.interface.ts b/libs/common/src/lib/interfaces/benchmark.interface.ts index 2124173fd..2d63b677c 100644 --- a/libs/common/src/lib/interfaces/benchmark.interface.ts +++ b/libs/common/src/lib/interfaces/benchmark.interface.ts @@ -3,7 +3,7 @@ import { BenchmarkTrend } from '@ghostfolio/common/types/'; import { EnhancedSymbolProfile } from './enhanced-symbol-profile.interface'; export interface Benchmark { - marketCondition: 'BEAR_MARKET' | 'BULL_MARKET' | 'NEUTRAL_MARKET'; + marketCondition: 'ALL_TIME_HIGH' | 'BEAR_MARKET' | 'NEUTRAL_MARKET'; name: EnhancedSymbolProfile['name']; performances: { allTimeHigh: { diff --git a/libs/ui/src/lib/benchmark/benchmark.component.html b/libs/ui/src/lib/benchmark/benchmark.component.html index 39e1db7c1..c0fdbf956 100644 --- a/libs/ui/src/lib/benchmark/benchmark.component.html +++ b/libs/ui/src/lib/benchmark/benchmark.component.html @@ -89,7 +89,7 @@ 'text-danger': element?.performances?.allTimeHigh?.performancePercent < 0, 'text-success': - element?.performances?.allTimeHigh?.performancePercent > 0 + element?.performances?.allTimeHigh?.performancePercent === 0 }" [value]="element?.performances?.allTimeHigh?.performancePercent" />