From 76890e63fafb7795b5bc8f8e0933dcceeccd67bb Mon Sep 17 00:00:00 2001
From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com>
Date: Sat, 29 Jun 2024 10:03:45 +0200
Subject: [PATCH] Bugfix/fix all time high in benchmarks (#3527)

* Fix all time high

* Update changelog
---
 CHANGELOG.md                                    | 6 ++++++
 apps/api/src/app/benchmark/benchmark.service.ts | 7 +++++--
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 514f89393..c52c8589c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
 The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
 and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
 
+## Unreleased
+
+### Fixed
+
+- Fixed an issue with the all time high in the benchmarks of the markets overview
+
 ## 2.91.0 - 2024-06-26
 
 ### Added
diff --git a/apps/api/src/app/benchmark/benchmark.service.ts b/apps/api/src/app/benchmark/benchmark.service.ts
index f4f2d7848..6008746d1 100644
--- a/apps/api/src/app/benchmark/benchmark.service.ts
+++ b/apps/api/src/app/benchmark/benchmark.service.ts
@@ -161,7 +161,10 @@ export class BenchmarkService {
         performances: {
           allTimeHigh: {
             date: allTimeHigh?.date,
-            performancePercent: performancePercentFromAllTimeHigh
+            performancePercent:
+              performancePercentFromAllTimeHigh >= 0
+                ? 0
+                : performancePercentFromAllTimeHigh
           }
         },
         symbol: benchmarkAssetProfiles[index].symbol,
@@ -419,7 +422,7 @@ export class BenchmarkService {
   private getMarketCondition(
     aPerformanceInPercent: number
   ): Benchmark['marketCondition'] {
-    if (aPerformanceInPercent === 0) {
+    if (aPerformanceInPercent >= 0) {
       return 'ALL_TIME_HIGH';
     } else if (aPerformanceInPercent <= -0.2) {
       return 'BEAR_MARKET';