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
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with
25 additions and
6 deletions
-
CHANGELOG.md
-
apps/api/src/app/endpoints/watchlist/watchlist.service.ts
-
apps/api/src/services/benchmark/benchmark.service.spec.ts
-
apps/api/src/services/benchmark/benchmark.service.ts
|
|
|
@ -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 |
|
|
|
|
|
|
|
@ -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, |
|
|
|
|
|
|
|
@ -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 |
|
|
|
); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
@ -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, |
|
|
|
|