Skip to content

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

Bugfix/positive performance from all time high in watchlist (#8012)

Thomas Kaulce68375f6fef
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d64f3d12f3..7149a52583 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
+- Fixed the positive performance from the all time high in the watchlist
- Fixed the portfolio calculation for holdings with historical market prices between the chart dates
## 3.77.0 - 2026-10-02
diff --git a/apps/api/src/app/endpoints/watchlist/watchlist.service.ts b/apps/api/src/app/endpoints/watchlist/watchlist.service.ts
index c69a31df82..925f49cd6b 100644
--- a/apps/api/src/app/endpoints/watchlist/watchlist.service.ts
+++ b/apps/api/src/app/endpoints/watchlist/watchlist.service.ts
@@ -140,8 +140,11 @@ export class WatchlistService {
name: assetProfile?.name,
performances: {
allTimeHigh: {
- performancePercent,
- date: allTimeHigh?.date
+ date: allTimeHigh?.date,
+ performancePercent:
+ this.benchmarkService.getPerformancePercentFromAllTimeHigh(
+ performancePercent
+ )
}
},
trend50d: trends.trend50d,
diff --git a/apps/api/src/services/benchmark/benchmark.service.spec.ts b/apps/api/src/services/benchmark/benchmark.service.spec.ts
index 0e7119b045..27124e89e4 100644
--- a/apps/api/src/services/benchmark/benchmark.service.spec.ts
+++ b/apps/api/src/services/benchmark/benchmark.service.spec.ts
@@ -24,4 +24,14 @@ describe('BenchmarkService', () => {
);
expect(benchmarkService.getMarketCondition(-0.2)).toEqual('BEAR_MARKET');
});
+
+ it('getPerformancePercentFromAllTimeHigh', async () => {
+ expect(benchmarkService.getPerformancePercentFromAllTimeHigh(0.1)).toEqual(
+ 0
+ );
+ expect(benchmarkService.getPerformancePercentFromAllTimeHigh(0)).toEqual(0);
+ expect(benchmarkService.getPerformancePercentFromAllTimeHigh(-0.1)).toEqual(
+ -0.1
+ );
+ });
});
diff --git a/apps/api/src/services/benchmark/benchmark.service.ts b/apps/api/src/services/benchmark/benchmark.service.ts
index 4ea27b2f2e..3c39848401 100644
--- a/apps/api/src/services/benchmark/benchmark.service.ts
+++ b/apps/api/src/services/benchmark/benchmark.service.ts
@@ -216,6 +216,12 @@ export class BenchmarkService {
}
}
+ public getPerformancePercentFromAllTimeHigh(performancePercent: number) {
+ const isAtAllTimeHigh = performancePercent >= 0;
+
+ return isAtAllTimeHigh ? 0 : performancePercent;
+ }
+
public async isBenchmark(symbolProfileId: string): Promise<boolean> {
const benchmarks = await this.getBenchmarksProperty();
@@ -288,10 +294,9 @@ export class BenchmarkService {
performances: {
allTimeHigh: {
date: allTimeHigh?.date,
- performancePercent:
- performancePercentFromAllTimeHigh >= 0
- ? 0
- : performancePercentFromAllTimeHigh
+ performancePercent: this.getPerformancePercentFromAllTimeHigh(
+ performancePercentFromAllTimeHigh
+ )
}
},
symbol: benchmarkAssetProfiles[index].symbol,