Browse Source
Feature/extend watchlist endpoint by trend50d and trend200d (#5405)
* Extend watchlist endpoint by trend50d and trend200d
* Update changelog
pull/5408/head^2
Kenrick Tandrian
3 days ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with
17 additions and
17 deletions
-
CHANGELOG.md
-
apps/api/src/app/endpoints/watchlist/watchlist.service.ts
-
apps/client/src/app/components/home-watchlist/home-watchlist.component.ts
-
libs/common/src/lib/interfaces/responses/watchlist-response.interface.ts
|
|
@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 |
|
|
|
|
|
|
|
## Unreleased |
|
|
|
|
|
|
|
### Added |
|
|
|
|
|
|
|
- Extended the watchlist endpoint by 50-Day and 200-Day trends (experimental) |
|
|
|
|
|
|
|
### Changed |
|
|
|
|
|
|
|
- Randomized the minutes of the hourly data gathering cron job |
|
|
|
|
|
@ -116,10 +116,13 @@ export class WatchlistService { |
|
|
|
return profile.dataSource === dataSource && profile.symbol === symbol; |
|
|
|
}); |
|
|
|
|
|
|
|
const allTimeHigh = await this.marketDataService.getMax({ |
|
|
|
const [allTimeHigh, trends] = await Promise.all([ |
|
|
|
this.marketDataService.getMax({ |
|
|
|
dataSource, |
|
|
|
symbol |
|
|
|
}); |
|
|
|
}), |
|
|
|
this.benchmarkService.getBenchmarkTrends({ dataSource, symbol }) |
|
|
|
]); |
|
|
|
|
|
|
|
const performancePercent = |
|
|
|
this.benchmarkService.calculateChangeInPercentage( |
|
|
@ -138,7 +141,9 @@ export class WatchlistService { |
|
|
|
performancePercent, |
|
|
|
date: allTimeHigh?.date |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
trend50d: trends.trend50d, |
|
|
|
trend200d: trends.trend200d |
|
|
|
}; |
|
|
|
}) |
|
|
|
); |
|
|
|
|
|
@ -7,7 +7,6 @@ import { |
|
|
|
User |
|
|
|
} from '@ghostfolio/common/interfaces'; |
|
|
|
import { hasPermission, permissions } from '@ghostfolio/common/permissions'; |
|
|
|
import { BenchmarkTrend } from '@ghostfolio/common/types'; |
|
|
|
import { GfBenchmarkComponent } from '@ghostfolio/ui/benchmark'; |
|
|
|
import { GfPremiumIndicatorComponent } from '@ghostfolio/ui/premium-indicator'; |
|
|
|
|
|
|
@ -137,17 +136,7 @@ export class HomeWatchlistComponent implements OnDestroy, OnInit { |
|
|
|
.fetchWatchlist() |
|
|
|
.pipe(takeUntil(this.unsubscribeSubject)) |
|
|
|
.subscribe(({ watchlist }) => { |
|
|
|
this.watchlist = watchlist.map( |
|
|
|
({ dataSource, marketCondition, name, performances, symbol }) => ({ |
|
|
|
dataSource, |
|
|
|
marketCondition, |
|
|
|
name, |
|
|
|
performances, |
|
|
|
symbol, |
|
|
|
trend50d: 'UNKNOWN' as BenchmarkTrend, |
|
|
|
trend200d: 'UNKNOWN' as BenchmarkTrend |
|
|
|
}) |
|
|
|
); |
|
|
|
this.watchlist = watchlist; |
|
|
|
|
|
|
|
this.changeDetectorRef.markForCheck(); |
|
|
|
}); |
|
|
|
|
|
@ -8,5 +8,7 @@ export interface WatchlistResponse { |
|
|
|
marketCondition: Benchmark['marketCondition']; |
|
|
|
name: string; |
|
|
|
performances: Benchmark['performances']; |
|
|
|
trend50d: Benchmark['trend50d']; |
|
|
|
trend200d: Benchmark['trend200d']; |
|
|
|
})[]; |
|
|
|
} |
|
|
|