Skip to content

Open Source Wealth Management Software. Angular + NestJS + Prisma + Nx + TypeScript 🤍

20.2 KB
Raw Blame
<div class="container">
  <h1 class="d-none d-sm-block h3 mb-3 text-center" i18n>Analysis</h1>
  @if (user?.settings?.isExperimentalFeatures) {
    <div class="mb-3 row">
      <div class="col-lg">
        <div class="d-flex justify-content-end">
          <button
            #actionsMenuButton
            class="mx-1 no-min-width px-2"
            mat-stroked-button
            [matMenuTriggerFor]="actionsMenu"
            (click)="$event.stopPropagation()"
          >
            <ion-icon name="ellipsis-vertical" />
          </button>
          <mat-menu
            #actionsMenu="matMenu"
            class="no-max-width"
            xPosition="before"
          >
            <div (click)="$event.stopPropagation()">
              <button
                mat-menu-item
                [disabled]="!hasPermissionToReadAiPrompt"
                (click)="onCopyPromptToClipboard('portfolio')"
              >
                <span class="align-items-center d-flex">
                  @if (user?.subscription?.type === 'Basic') {
                    <gf-premium-indicator class="me-2" />
                  } @else {
                    @if (isLoadingPortfolioPrompt) {
                      <mat-spinner
                        class="me-2"
                        color="accent"
                        [diameter]="16"
                      />
                    } @else {
                      <ion-icon class="me-2" name="copy-outline" />
                    }
                  }
                  <ng-container i18n
                    >Copy portfolio data to clipboard for AI
                    prompt</ng-container
                  >
                </span>
              </button>
              <button
                mat-menu-item
                [disabled]="!hasPermissionToReadAiPrompt"
                (click)="onCopyPromptToClipboard('analysis')"
              >
                <span class="align-items-center d-flex">
                  @if (user?.subscription?.type === 'Basic') {
                    <gf-premium-indicator class="me-2" />
                  } @else {
                    @if (isLoadingAnalysisPrompt) {
                      <mat-spinner
                        class="me-2"
                        color="accent"
                        [diameter]="16"
                      />
                    } @else {
                      <ion-icon class="me-2" name="copy-outline" />
                    }
                  }
                  <ng-container i18n
                    >Copy AI prompt to clipboard for analysis</ng-container
                  >
                </span>
              </button>
            </div>
          </mat-menu>
        </div>
      </div>
    </div>
  }

  <div class="mb-5 row">
    <div class="col-lg-4 mb-3 mb-lg-0">
      <mat-card appearance="outlined">
        <mat-card-content>
          <gf-value
            i18n
            size="large"
            [isCurrency]="true"
            [isLoading]="isLoadingInvestmentChart"
            [locale]="user?.settings?.locale"
            [precision]="precision"
            [unit]="user?.settings?.baseCurrency"
            [value]="performance?.currentValueInBaseCurrency"
            >Total amount</gf-value
          >
        </mat-card-content>
      </mat-card>
    </div>
    <div class="col-lg-4 mb-3 mb-lg-0">
      <mat-card appearance="outlined">
        <mat-card-content>
          <gf-value
            i18n
            size="large"
            [colorizeSign]="true"
            [isCurrency]="true"
            [isLoading]="isLoadingInvestmentChart"
            [locale]="user?.settings?.locale"
            [precision]="precision"
            [unit]="user?.settings?.baseCurrency"
            [value]="performance?.netPerformanceWithCurrencyEffect"
            >Change with currency effect</gf-value
          >
        </mat-card-content>
      </mat-card>
    </div>
    <div class="col-lg-4">
      <mat-card appearance="outlined">
        <mat-card-content>
          <gf-value
            i18n
            size="large"
            [colorizeSign]="true"
            [isLoading]="isLoadingInvestmentChart"
            [isPercent]="true"
            [locale]="user?.settings?.locale"
            [value]="performance?.netPerformancePercentageWithCurrencyEffect"
            >Performance with currency effect</gf-value
          >
        </mat-card-content>
      </mat-card>
    </div>
  </div>

  <div class="mb-5 row">
    <div class="col-lg">
      <gf-benchmark-comparator
        class="h-100"
        [benchmark]="benchmark"
        [benchmarkDataItems]="benchmarkDataItems"
        [benchmarks]="benchmarks"
        [colorScheme]="user?.settings?.colorScheme"
        [isLoading]="isLoadingBenchmarkComparator || isLoadingInvestmentChart"
        [locale]="user?.settings?.locale"
        [performanceDataItems]="performanceDataItemsInPercentage"
        [user]="user"
        (benchmarkChanged)="onChangeBenchmark($event)"
      />
    </div>
  </div>

  <div class="mb-5 row">
    <div class="col">
      <mat-card appearance="outlined">
        <mat-card-content>
          <div class="d-flex py-1">
            <div
              class="align-items-center d-flex flex-grow-1 me-2 text-truncate"
            >
              <span i18n>Absolute Asset Performance</span>
              @if (user?.subscription?.type === 'Basic') {
                <gf-premium-indicator class="ms-1" />
              }
            </div>
            <div class="d-flex justify-content-end">
              <gf-value
                class="justify-content-end"
                position="end"
                [isCurrency]="true"
                [isLoading]="isLoadingInvestmentChart"
                [locale]="user?.settings?.locale"
                [unit]="user?.settings?.baseCurrency"
                [value]="performance?.netPerformance"
              />
            </div>
          </div>
          <div class="d-flex mb-3 ms-3 py-1">
            <div class="flex-grow-1 me-2 text-truncate">
              <ng-container i18n>Asset Performance</ng-container>
            </div>
            <div class="d-flex justify-content-end">
              <gf-value
                class="justify-content-end"
                position="end"
                [colorizeSign]="true"
                [isLoading]="isLoadingInvestmentChart"
                [isPercent]="true"
                [locale]="user?.settings?.locale"
                [value]="performance?.netPerformancePercentage"
              />
            </div>
          </div>
          <div class="d-flex py-1">
            <div
              class="align-items-center d-flex flex-grow-1 me-2 text-truncate"
            >
              <span i18n>Absolute Currency Performance</span>
              @if (user?.subscription?.type === 'Basic') {
                <gf-premium-indicator class="ms-1" />
              }
            </div>
            <div class="d-flex justify-content-end">
              <gf-value
                class="justify-content-end"
                position="end"
                [isCurrency]="true"
                [isLoading]="isLoadingInvestmentChart"
                [locale]="user?.settings?.locale"
                [unit]="user?.settings?.baseCurrency"
                [value]="
                  performance?.netPerformance === null
                    ? null
                    : performance?.netPerformanceWithCurrencyEffect -
                      performance?.netPerformance
                "
              />
            </div>
          </div>
          <div class="d-flex ms-3 py-1">
            <div class="flex-grow-1 me-2 text-truncate">
              <ng-container i18n>Currency Performance</ng-container>
            </div>
            <div class="d-flex justify-content-end">
              <gf-value
                class="justify-content-end"
                position="end"
                [colorizeSign]="true"
                [isLoading]="isLoadingInvestmentChart"
                [isPercent]="true"
                [locale]="user?.settings?.locale"
                [value]="
                  performance?.netPerformancePercentage === null
                    ? null
                    : performance?.netPerformancePercentageWithCurrencyEffect -
                      performance?.netPerformancePercentage
                "
              />
            </div>
          </div>
          <div><hr /></div>
          <div class="d-flex py-1">
            <div class="flex-grow-1 me-2 text-truncate">
              <ng-container i18n>Absolute Net Performance</ng-container>
            </div>
            <div class="d-flex justify-content-end">
              <gf-value
                class="justify-content-end"
                position="end"
                [isCurrency]="true"
                [isLoading]="isLoadingInvestmentChart"
                [locale]="user?.settings?.locale"
                [unit]="user?.settings?.baseCurrency"
                [value]="performance?.netPerformanceWithCurrencyEffect"
              />
            </div>
          </div>
          <div class="d-flex ms-3 py-1">
            <div class="flex-grow-1 me-2 text-truncate">
              <ng-container i18n>Net Performance</ng-container>
              @switch (user?.settings?.performanceCalculationType) {
                @case (PerformanceCalculationType.ROAI) {
                  <abbr
                    class="d-none d-sm-inline-block initialism ms-2 text-body-secondary"
                    i18n-title
                    title="Return on Average Investment (total return with dividends)"
                    >(ROAI)</abbr
                  >
                }
                @case (PerformanceCalculationType.ROI) {
                  <abbr
                    class="d-none d-sm-inline-block initialism ms-2 text-body-secondary"
                    i18n-title
                    title="Return on Investment (total return with dividends)"
                    >(ROI)</abbr
                  >
                }
              }
            </div>
            <div class="d-flex justify-content-end">
              <gf-value
                class="justify-content-end"
                position="end"
                [colorizeSign]="true"
                [isLoading]="isLoadingInvestmentChart"
                [isPercent]="true"
                [locale]="user?.settings?.locale"
                [value]="
                  performance?.netPerformancePercentageWithCurrencyEffect
                "
              />
            </div>
          </div>
          <div class="d-flex ms-3 py-1 text-body-secondary">
            <div
              class="align-items-center d-flex flex-grow-1 me-2 text-truncate"
            >
              <span i18n>thereof Dividend</span>
              @if (user?.subscription?.type === 'Basic') {
                <gf-premium-indicator class="ms-1" />
              }
            </div>
            <div class="d-flex justify-content-end">
              <gf-value
                class="justify-content-end"
                position="end"
                [isCurrency]="true"
                [isLoading]="isLoadingInvestmentChart"
                [locale]="user?.settings?.locale"
                [unit]="user?.settings?.baseCurrency"
                [value]="performance?.dividendInBaseCurrency"
              />
            </div>
          </div>
          <div class="d-flex ms-3 py-1 text-body-secondary">
            <div class="flex-grow-1 me-2 text-truncate">
              <ng-container i18n>thereof Dividend Performance</ng-container>
            </div>
            <div class="d-flex justify-content-end">
              <gf-value
                class="justify-content-end"
                position="end"
                [isLoading]="isLoadingInvestmentChart"
                [isPercent]="true"
                [locale]="user?.settings?.locale"
                [value]="performance?.dividendPercentageWithCurrencyEffect"
              />
            </div>
          </div>
        </mat-card-content>
      </mat-card>
    </div>
  </div>

  <div class="mb-5 row">
    <div class="col-md-6 mb-3">
      <mat-card appearance="outlined" class="h-100">
        <mat-card-header>
          <mat-card-title class="align-items-center d-flex" i18n
            >Top</mat-card-title
          >
        </mat-card-header>
        <mat-card-content>
          <ol class="holdings mb-0 ms-1 ps-3">
            @for (holding of top3; track holding) {
              <li class="py-1">
                <a
                  class="d-flex"
                  [queryParams]="{
                    dataSource: holding.assetProfile.dataSource,
                    holdingDetailDialog: true,
                    symbol: holding.assetProfile.symbol
                  }"
                  [routerLink]="[]"
                >
                  <div class="flex-grow-1 me-2 name">
                    <span class="align-top d-inline-block mw-100 text-truncate">
                      {{ holding.assetProfile.name }}
                    </span>
                  </div>
                  <div class="d-flex justify-content-end">
                    <gf-value
                      class="justify-content-end"
                      position="end"
                      [colorizeSign]="true"
                      [isPercent]="true"
                      [locale]="user?.settings?.locale"
                      [value]="holding.netPerformancePercentWithCurrencyEffect"
                    />
                  </div>
                </a>
              </li>
            }
          </ol>
          <div>
            @if (!top3) {
              <ngx-skeleton-loader
                animation="pulse"
                [theme]="{
                  height: '1.5rem',
                  width: '100%'
                }"
              />
            }
          </div>
        </mat-card-content>
      </mat-card>
    </div>
    <div class="col-md-6 mb-3">
      <mat-card appearance="outlined" class="h-100">
        <mat-card-header>
          <mat-card-title class="align-items-center d-flex" i18n
            >Bottom</mat-card-title
          >
        </mat-card-header>
        <mat-card-content>
          <ol class="holdings mb-0 ms-1 ps-3">
            @for (holding of bottom3; track holding) {
              <li class="py-1">
                <a
                  class="d-flex"
                  [queryParams]="{
                    dataSource: holding.assetProfile.dataSource,
                    holdingDetailDialog: true,
                    symbol: holding.assetProfile.symbol
                  }"
                  [routerLink]="[]"
                >
                  <div class="flex-grow-1 me-2 name">
                    <span class="align-top d-inline-block mw-100 text-truncate">
                      {{ holding.assetProfile.name }}
                    </span>
                  </div>
                  <div class="d-flex justify-content-end">
                    <gf-value
                      class="justify-content-end"
                      position="end"
                      [colorizeSign]="true"
                      [isPercent]="true"
                      [locale]="user?.settings?.locale"
                      [value]="holding.netPerformancePercentWithCurrencyEffect"
                    />
                  </div>
                </a>
              </li>
            }
          </ol>
          <div>
            @if (!bottom3) {
              <ngx-skeleton-loader
                animation="pulse"
                [theme]="{
                  height: '1.5rem',
                  width: '100%'
                }"
              />
            }
          </div>
        </mat-card-content>
      </mat-card>
    </div>
  </div>

  @if (user?.settings?.isExperimentalFeatures) {
    <div class="mb-5 row">
      <div class="col-lg">
        <div class="align-items-center d-flex mb-4">
          <div
            class="align-items-center d-flex flex-grow-1 h5 mb-0 text-truncate"
          >
            <span i18n>Performance Timeline</span>
            @if (user?.subscription?.type === 'Basic') {
              <gf-premium-indicator class="ms-1" />
            }
          </div>
        </div>
        <div class="chart-container">
          <gf-investment-chart
            class="h-100"
            groupBy="year"
            [benchmarkDataItems]="performancePercentagesByYear"
            [benchmarkDataLabel]="performanceTimelineDataLabel"
            [colorScheme]="user?.settings?.colorScheme"
            [highlightNegativeValues]="true"
            [isInPercentage]="true"
            [isLoading]="isLoadingPerformanceTimelineChart"
            [locale]="user?.settings?.locale"
          />
        </div>
      </div>
    </div>
  }

  <div class="mb-5 row">
    <div class="col-lg">
      <div class="align-items-center d-flex mb-4">
        <div
          class="align-items-center d-flex flex-grow-1 h5 mb-0 text-truncate"
        >
          <span i18n>Portfolio Evolution</span>
          @if (user?.subscription?.type === 'Basic') {
            <gf-premium-indicator class="ms-1" />
          }
        </div>
      </div>
      <div class="chart-container">
        <gf-investment-chart
          class="h-100"
          [benchmarkDataItems]="investments"
          [benchmarkDataLabel]="portfolioEvolutionDataLabel"
          [colorScheme]="user?.settings?.colorScheme"
          [currency]="user?.settings?.baseCurrency"
          [historicalDataItems]="performanceDataItems"
          [isInPercentage]="showValuesInPercentage()"
          [isLoading]="isLoadingInvestmentChart"
          [locale]="user?.settings?.locale"
        />
      </div>
    </div>
  </div>

  <div class="mb-5 row">
    <div class="col-lg">
      <div class="align-items-center d-flex mb-4">
        <div
          class="align-items-center d-flex flex-grow-1 h5 mb-0 text-truncate"
        >
          <span i18n>Investment Timeline</span>
          @if (user?.subscription?.type === 'Basic') {
            <gf-premium-indicator class="ms-1" />
          }
        </div>
        <gf-toggle
          class="d-none d-lg-block"
          [defaultValue]="mode()"
          [isLoading]="false"
          [options]="modeOptions"
          (valueChange)="onChangeGroupBy($event.value)"
        />
      </div>
      @if (streaks) {
        <div class="row">
          <div class="col-md-6 my-2">
            <gf-value
              i18n
              size="large"
              [unit]="unitCurrentStreak"
              [value]="streaks?.currentStreak"
              >Current Streak</gf-value
            >
          </div>
          <div class="col-md-6 my-2">
            <gf-value
              i18n
              size="large"
              [unit]="unitLongestStreak"
              [value]="streaks?.longestStreak"
              >Longest Streak</gf-value
            >
          </div>
        </div>
      }
      <div class="chart-container">
        <gf-investment-chart
          class="h-100"
          [benchmarkDataItems]="investmentsByGroup"
          [benchmarkDataLabel]="investmentTimelineDataLabel"
          [colorScheme]="user?.settings?.colorScheme"
          [currency]="user?.settings?.baseCurrency"
          [groupBy]="mode()"
          [isInPercentage]="showValuesInPercentage()"
          [isLoading]="isLoadingInvestmentTimelineChart"
          [locale]="user?.settings?.locale"
          [savingsRate]="savingsRate"
        />
      </div>
    </div>
  </div>

  <div class="row">
    <div class="col-lg">
      <div class="align-items-center d-flex mb-4">
        <div
          class="align-items-center d-flex flex-grow-1 h5 mb-0 text-truncate"
        >
          <span i18n>Dividend Timeline</span>
          @if (user?.subscription?.type === 'Basic') {
            <gf-premium-indicator class="ms-1" />
          }
        </div>
        <gf-toggle
          class="d-none d-lg-block"
          [defaultValue]="mode()"
          [isLoading]="false"
          [options]="modeOptions"
          (valueChange)="onChangeGroupBy($event.value)"
        />
      </div>
      <div class="chart-container">
        <gf-investment-chart
          class="h-100"
          [benchmarkDataItems]="dividendsByGroup"
          [benchmarkDataLabel]="dividendTimelineDataLabel"
          [colorScheme]="user?.settings?.colorScheme"
          [currency]="user?.settings?.baseCurrency"
          [groupBy]="mode()"
          [isInPercentage]="showValuesInPercentage()"
          [isLoading]="isLoadingDividendTimelineChart"
          [locale]="user?.settings?.locale"
        />
      </div>
    </div>
  </div>
</div>