Browse Source

feat(api): fetch benchmark trends

pull/5405/head
KenTandrian 2 months ago
parent
commit
65bbcdfa80
  1. 15
      apps/api/src/app/endpoints/watchlist/watchlist.service.ts
  2. 13
      apps/client/src/app/components/home-watchlist/home-watchlist.component.ts

15
apps/api/src/app/endpoints/watchlist/watchlist.service.ts

@ -116,10 +116,13 @@ export class WatchlistService {
return profile.dataSource === dataSource && profile.symbol === symbol; return profile.dataSource === dataSource && profile.symbol === symbol;
}); });
const allTimeHigh = await this.marketDataService.getMax({ const [allTimeHigh, trends] = await Promise.all([
dataSource, this.marketDataService.getMax({
symbol dataSource,
}); symbol
}),
this.benchmarkService.getBenchmarkTrends({ dataSource, symbol })
]);
const performancePercent = const performancePercent =
this.benchmarkService.calculateChangeInPercentage( this.benchmarkService.calculateChangeInPercentage(
@ -138,7 +141,9 @@ export class WatchlistService {
performancePercent, performancePercent,
date: allTimeHigh?.date date: allTimeHigh?.date
} }
} },
trend200d: trends.trend200d,
trend50d: trends.trend50d
}; };
}) })
); );

13
apps/client/src/app/components/home-watchlist/home-watchlist.component.ts

@ -7,7 +7,6 @@ import {
User User
} from '@ghostfolio/common/interfaces'; } from '@ghostfolio/common/interfaces';
import { hasPermission, permissions } from '@ghostfolio/common/permissions'; import { hasPermission, permissions } from '@ghostfolio/common/permissions';
import { BenchmarkTrend } from '@ghostfolio/common/types';
import { GfBenchmarkComponent } from '@ghostfolio/ui/benchmark'; import { GfBenchmarkComponent } from '@ghostfolio/ui/benchmark';
import { GfPremiumIndicatorComponent } from '@ghostfolio/ui/premium-indicator'; import { GfPremiumIndicatorComponent } from '@ghostfolio/ui/premium-indicator';
@ -137,17 +136,7 @@ export class HomeWatchlistComponent implements OnDestroy, OnInit {
.fetchWatchlist() .fetchWatchlist()
.pipe(takeUntil(this.unsubscribeSubject)) .pipe(takeUntil(this.unsubscribeSubject))
.subscribe(({ watchlist }) => { .subscribe(({ watchlist }) => {
this.watchlist = watchlist.map( this.watchlist = watchlist;
({ dataSource, marketCondition, name, performances, symbol }) => ({
dataSource,
marketCondition,
name,
performances,
symbol,
trend50d: 'UNKNOWN' as BenchmarkTrend,
trend200d: 'UNKNOWN' as BenchmarkTrend
})
);
this.changeDetectorRef.markForCheck(); this.changeDetectorRef.markForCheck();
}); });

Loading…
Cancel
Save