|
|
|
@ -5,6 +5,7 @@ import { |
|
|
|
DEFAULT_DATE_RANGE, |
|
|
|
NUMERICAL_PRECISION_THRESHOLD_6_FIGURES |
|
|
|
} from '@ghostfolio/common/config'; |
|
|
|
import { SubscriptionType } from '@ghostfolio/common/enums'; |
|
|
|
import { canOpenHoldingDetail } from '@ghostfolio/common/helper'; |
|
|
|
import { |
|
|
|
InvestmentItem, |
|
|
|
@ -93,6 +94,7 @@ export class GfAnalysisPageComponent implements OnInit { |
|
|
|
protected isLoadingDividendTimelineChart: boolean; |
|
|
|
protected isLoadingInvestmentChart: boolean; |
|
|
|
protected isLoadingInvestmentTimelineChart: boolean; |
|
|
|
protected isLoadingPerformanceTimelineChart: boolean; |
|
|
|
protected isLoadingPortfolioPrompt: boolean; |
|
|
|
protected readonly mode = signal<GroupBy>('month'); |
|
|
|
protected readonly modeOptions: ToggleOption<GroupBy>[] = [ |
|
|
|
@ -103,6 +105,8 @@ export class GfAnalysisPageComponent implements OnInit { |
|
|
|
protected readonly PerformanceCalculationType = PerformanceCalculationType; |
|
|
|
protected performanceDataItems: LineChartItem[]; |
|
|
|
protected performanceDataItemsInPercentage: LineChartItem[]; |
|
|
|
protected performancePercentagesByYear: InvestmentItem[]; |
|
|
|
protected readonly performanceTimelineDataLabel = $localize`Net Performance`; |
|
|
|
protected readonly portfolioEvolutionDataLabel = $localize`Invested Capital`; |
|
|
|
protected precision = 2; |
|
|
|
protected savingsRatePerMonth: number | undefined; |
|
|
|
@ -312,6 +316,37 @@ export class GfAnalysisPageComponent implements OnInit { |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
private fetchPerformanceByYear() { |
|
|
|
this.isLoadingPerformanceTimelineChart = true; |
|
|
|
|
|
|
|
this.dataService |
|
|
|
.fetchPortfolioPerformance({ |
|
|
|
filters: this.userService.getFilters(), |
|
|
|
groupBy: 'year', |
|
|
|
range: this.user?.settings?.dateRange ?? DEFAULT_DATE_RANGE |
|
|
|
}) |
|
|
|
.pipe(takeUntilDestroyed(this.destroyRef)) |
|
|
|
.subscribe(({ chart }) => { |
|
|
|
this.performancePercentagesByYear = []; |
|
|
|
|
|
|
|
for (const { |
|
|
|
date, |
|
|
|
netPerformanceInPercentageWithCurrencyEffect |
|
|
|
} of chart ?? []) { |
|
|
|
if (isNumber(netPerformanceInPercentageWithCurrencyEffect)) { |
|
|
|
this.performancePercentagesByYear.push({ |
|
|
|
date, |
|
|
|
investment: netPerformanceInPercentageWithCurrencyEffect |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
this.isLoadingPerformanceTimelineChart = false; |
|
|
|
|
|
|
|
this.changeDetectorRef.markForCheck(); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
private update() { |
|
|
|
this.isLoadingInvestmentChart = true; |
|
|
|
|
|
|
|
@ -420,6 +455,13 @@ export class GfAnalysisPageComponent implements OnInit { |
|
|
|
|
|
|
|
this.fetchDividendsAndInvestments(); |
|
|
|
|
|
|
|
if ( |
|
|
|
this.user?.settings?.isExperimentalFeatures && |
|
|
|
this.user?.subscription?.type !== SubscriptionType.Basic |
|
|
|
) { |
|
|
|
this.fetchPerformanceByYear(); |
|
|
|
} |
|
|
|
|
|
|
|
this.changeDetectorRef.markForCheck(); |
|
|
|
} |
|
|
|
|
|
|
|
|