Browse Source

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

* Fix positive performance from all time high

* Update changelog
pull/8015/head^2
Thomas Kaul 5 days ago
committed by GitHub
parent
commit
ce68375f6f
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 1
      CHANGELOG.md
  2. 7
      apps/api/src/app/endpoints/watchlist/watchlist.service.ts
  3. 10
      apps/api/src/services/benchmark/benchmark.service.spec.ts
  4. 13
      apps/api/src/services/benchmark/benchmark.service.ts

1
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

7
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,

10
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
);
});
});

13
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,

Loading…
Cancel
Save