diff --git a/apps/api/src/app/portfolio/interfaces/portfolio-positions.interface.ts b/apps/api/src/app/portfolio/interfaces/portfolio-positions.interface.ts deleted file mode 100644 index fa6141a7a..000000000 --- a/apps/api/src/app/portfolio/interfaces/portfolio-positions.interface.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { Position } from '@ghostfolio/common/interfaces'; - -export interface PortfolioPositions { - positions: Position[]; -} diff --git a/apps/api/src/app/portfolio/portfolio.controller.ts b/apps/api/src/app/portfolio/portfolio.controller.ts index 4a07cd65b..ed3c0f174 100644 --- a/apps/api/src/app/portfolio/portfolio.controller.ts +++ b/apps/api/src/app/portfolio/portfolio.controller.ts @@ -52,7 +52,6 @@ import { Big } from 'big.js'; import { StatusCodes, getReasonPhrase } from 'http-status-codes'; import { PortfolioPositionDetail } from './interfaces/portfolio-position-detail.interface'; -import { PortfolioPositions } from './interfaces/portfolio-positions.interface'; import { PortfolioService } from './portfolio.service'; @Controller('portfolio') @@ -494,35 +493,6 @@ export class PortfolioController { return performanceInformation; } - /** - * @deprecated - */ - @Get('positions') - @UseGuards(AuthGuard('jwt'), HasPermissionGuard) - @UseInterceptors(RedactValuesInResponseInterceptor) - @UseInterceptors(TransformDataSourceInResponseInterceptor) - public async getPositions( - @Headers(HEADER_KEY_IMPERSONATION.toLowerCase()) impersonationId: string, - @Query('accounts') filterByAccounts?: string, - @Query('assetClasses') filterByAssetClasses?: string, - @Query('query') filterBySearchQuery?: string, - @Query('range') dateRange: DateRange = 'max', - @Query('tags') filterByTags?: string - ): Promise { - const filters = this.apiService.buildFiltersFromQueryParams({ - filterByAccounts, - filterByAssetClasses, - filterBySearchQuery, - filterByTags - }); - - return this.portfolioService.getPositions({ - dateRange, - filters, - impersonationId - }); - } - @Get('public/:accessId') @UseInterceptors(TransformDataSourceInResponseInterceptor) public async getPublic( diff --git a/apps/client/src/app/pages/portfolio/activities/import-activities-dialog/import-activities-dialog.component.ts b/apps/client/src/app/pages/portfolio/activities/import-activities-dialog/import-activities-dialog.component.ts index ccc861335..b59994811 100644 --- a/apps/client/src/app/pages/portfolio/activities/import-activities-dialog/import-activities-dialog.component.ts +++ b/apps/client/src/app/pages/portfolio/activities/import-activities-dialog/import-activities-dialog.component.ts @@ -2,7 +2,7 @@ import { CreateAccountDto } from '@ghostfolio/api/app/account/create-account.dto import { Activity } from '@ghostfolio/api/app/order/interfaces/activities.interface'; import { DataService } from '@ghostfolio/client/services/data.service'; import { ImportActivitiesService } from '@ghostfolio/client/services/import-activities.service'; -import { Position } from '@ghostfolio/common/interfaces'; +import { PortfolioPosition } from '@ghostfolio/common/interfaces'; import { StepperOrientation, @@ -43,7 +43,7 @@ export class ImportActivitiesDialog implements OnDestroy { public deviceType: string; public dialogTitle = $localize`Import Activities`; public errorMessages: string[] = []; - public holdings: Position[] = []; + public holdings: PortfolioPosition[] = []; public importStep: ImportStep = ImportStep.UPLOAD_FILE; public isLoading = false; public maxSafeInteger = Number.MAX_SAFE_INTEGER; @@ -88,7 +88,7 @@ export class ImportActivitiesDialog implements OnDestroy { this.uniqueAssetForm.get('uniqueAsset').disable(); this.dataService - .fetchPositions({ + .fetchPortfolioHoldings({ filters: [ { id: AssetClass.EQUITY, @@ -98,8 +98,8 @@ export class ImportActivitiesDialog implements OnDestroy { range: 'max' }) .pipe(takeUntil(this.unsubscribeSubject)) - .subscribe(({ positions }) => { - this.holdings = sortBy(positions, ({ name }) => { + .subscribe(({ holdings }) => { + this.holdings = sortBy(holdings, ({ name }) => { return name.toLowerCase(); }); this.uniqueAssetForm.get('uniqueAsset').enable(); diff --git a/apps/client/src/app/pages/portfolio/analysis/analysis-page.component.ts b/apps/client/src/app/pages/portfolio/analysis/analysis-page.component.ts index 4acf6dbb9..93dfb6517 100644 --- a/apps/client/src/app/pages/portfolio/analysis/analysis-page.component.ts +++ b/apps/client/src/app/pages/portfolio/analysis/analysis-page.component.ts @@ -8,7 +8,7 @@ import { HistoricalDataItem, PortfolioInvestments, PortfolioPerformance, - Position, + PortfolioPosition, User } from '@ghostfolio/common/interfaces'; import { InvestmentItem } from '@ghostfolio/common/interfaces/investment-item.interface'; @@ -35,7 +35,7 @@ export class AnalysisPageComponent implements OnDestroy, OnInit { public benchmark: Partial; public benchmarkDataItems: HistoricalDataItem[] = []; public benchmarks: Partial[]; - public bottom3: Position[]; + public bottom3: PortfolioPosition[]; public dateRangeOptions = ToggleComponent.DEFAULT_DATE_RANGE_OPTIONS; public daysInMarket: number; public deviceType: string; @@ -60,7 +60,7 @@ export class AnalysisPageComponent implements OnDestroy, OnInit { public performanceDataItemsInPercentage: HistoricalDataItem[]; public portfolioEvolutionDataLabel = $localize`Investment`; public streaks: PortfolioInvestments['streaks']; - public top3: Position[]; + public top3: PortfolioPosition[]; public unitCurrentStreak: string; public unitLongestStreak: string; public user: User; @@ -308,23 +308,23 @@ export class AnalysisPageComponent implements OnDestroy, OnInit { }); this.dataService - .fetchPositions({ + .fetchPortfolioHoldings({ filters: this.userService.getFilters(), range: this.user?.settings?.dateRange }) .pipe(takeUntil(this.unsubscribeSubject)) - .subscribe(({ positions }) => { - const positionsSorted = sortBy( - positions.filter(({ netPerformancePercentageWithCurrencyEffect }) => { - return isNumber(netPerformancePercentageWithCurrencyEffect); + .subscribe(({ holdings }) => { + const holdingsSorted = sortBy( + holdings.filter(({ netPerformancePercentWithCurrencyEffect }) => { + return isNumber(netPerformancePercentWithCurrencyEffect); }), - 'netPerformancePercentageWithCurrencyEffect' + 'netPerformancePercentWithCurrencyEffect' ).reverse(); - this.top3 = positionsSorted.slice(0, 3); + this.top3 = holdingsSorted.slice(0, 3); - if (positions?.length > 3) { - this.bottom3 = positionsSorted.slice(-3).reverse(); + if (holdings?.length > 3) { + this.bottom3 = holdingsSorted.slice(-3).reverse(); } else { this.bottom3 = []; } diff --git a/apps/client/src/app/pages/portfolio/analysis/analysis-page.html b/apps/client/src/app/pages/portfolio/analysis/analysis-page.html index 191dca06f..90cf8bc06 100644 --- a/apps/client/src/app/pages/portfolio/analysis/analysis-page.html +++ b/apps/client/src/app/pages/portfolio/analysis/analysis-page.html @@ -170,17 +170,17 @@
    -
  1. +
  2. -
    {{ position.name }}
    +
    {{ holding.name }}
    @@ -218,17 +216,17 @@
      -
    1. +
    2. -
      {{ position.name }}
      +
      {{ holding.name }}
      diff --git a/apps/client/src/app/services/data.service.ts b/apps/client/src/app/services/data.service.ts index d5c1bec00..4f8615e41 100644 --- a/apps/client/src/app/services/data.service.ts +++ b/apps/client/src/app/services/data.service.ts @@ -6,7 +6,6 @@ import { CreateOrderDto } from '@ghostfolio/api/app/order/create-order.dto'; import { Activities } from '@ghostfolio/api/app/order/interfaces/activities.interface'; import { UpdateOrderDto } from '@ghostfolio/api/app/order/update-order.dto'; import { PortfolioPositionDetail } from '@ghostfolio/api/app/portfolio/interfaces/portfolio-position-detail.interface'; -import { PortfolioPositions } from '@ghostfolio/api/app/portfolio/interfaces/portfolio-positions.interface'; import { LookupItem } from '@ghostfolio/api/app/symbol/interfaces/lookup-item.interface'; import { SymbolItem } from '@ghostfolio/api/app/symbol/interfaces/symbol-item.interface'; import { UserItem } from '@ghostfolio/api/app/user/interfaces/user-item.interface'; @@ -376,24 +375,6 @@ export class DataService { }); } - /** - * @deprecated - */ - public fetchPositions({ - filters, - range - }: { - filters?: Filter[]; - range: DateRange; - }): Observable { - let params = this.buildFiltersAsQueryParams({ filters }); - params = params.append('range', range); - - return this.http.get('/api/v1/portfolio/positions', { - params - }); - } - public fetchSymbols({ includeIndices = false, query diff --git a/libs/ui/src/lib/assistant/assistant.component.ts b/libs/ui/src/lib/assistant/assistant.component.ts index f932fd5c2..101872a86 100644 --- a/libs/ui/src/lib/assistant/assistant.component.ts +++ b/libs/ui/src/lib/assistant/assistant.component.ts @@ -416,7 +416,7 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit { private searchHoldings(aSearchTerm: string): Observable { return this.dataService - .fetchPositions({ + .fetchPortfolioHoldings({ filters: [ { id: aSearchTerm, @@ -429,8 +429,8 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit { catchError(() => { return EMPTY; }), - map(({ positions }) => { - return positions.map( + map(({ holdings }) => { + return holdings.map( ({ assetSubClass, currency, dataSource, name, symbol }) => { return { currency,