import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'; import { MoneyDto } from '../../../../common/money.dto'; import { AccountReferenceDto } from '../../account-reference.dto'; import { InvestmentResourceMetaDto } from '../../investment-resource.dto'; export class PortfolioPositionDto { @ApiPropertyOptional({ type: String, nullable: true }) instrumentUid?: null | string; @ApiPropertyOptional({ type: AccountReferenceDto }) account?: AccountReferenceDto; @ApiProperty({ type: String, nullable: true }) declare figi: null | string; @ApiProperty() declare displayName: string; @ApiProperty({ enum: [ 'STOCK', 'BOND', 'FUND', 'CURRENCY', 'FUTURE', 'OPTION', 'STRUCTURED_NOTE', 'DIGITAL_FINANCIAL_ASSET', 'OTHER', ], }) declare type: string; @ApiProperty() declare quantity: string; @ApiProperty({ type: MoneyDto, nullable: true }) declare currentValue: MoneyDto | null; @ApiProperty({ type: MoneyDto, nullable: true }) declare averagePurchasePrice: MoneyDto | null; @ApiProperty({ type: MoneyDto, nullable: true }) declare absoluteReturn: MoneyDto | null; @ApiProperty({ type: String, nullable: true }) declare isin: null | string; @ApiProperty({ type: String, nullable: true }) declare ticker: null | string; @ApiProperty({ type: String, nullable: true }) declare logoName: null | string; } export class PortfolioStructureCategoryDto { @ApiProperty({ enum: ['STOCK', 'BOND', 'OTHER', 'CASH'] }) declare type: string; @ApiProperty({ description: 'Exact known value as a decimal string.' }) declare value: string; @ApiProperty({ type: String, nullable: true, description: 'Percentage including cash, rounded to six decimal places. Null for incomplete, negative or zero-total compositions.', }) declare sharePercent: null | string; } export class PortfolioStructureCurrencyDto { @ApiProperty() declare currency: string; @ApiProperty() declare totalValue: string; @ApiProperty({ description: 'Any negative constituent, even if netted positive.', }) declare hasNegativeValues: boolean; @ApiProperty({ type: PortfolioStructureCategoryDto, isArray: true }) declare categories: PortfolioStructureCategoryDto[]; } export class PortfolioUnvaluedCategoryDto { @ApiProperty({ enum: ['STOCK', 'BOND', 'OTHER'] }) declare type: string; @ApiProperty({ minimum: 1 }) declare count: number; } export class PortfolioStructureDto { @ApiProperty({ type: PortfolioStructureCurrencyDto, isArray: true }) declare currencies: PortfolioStructureCurrencyDto[]; @ApiProperty({ type: PortfolioUnvaluedCategoryDto, isArray: true, description: 'Positions without current value and known valuation currency. Shares are unavailable across all currencies when nonempty.', }) declare unvaluedCategories: PortfolioUnvaluedCategoryDto[]; } export class PortfolioDto { @ApiProperty({ format: 'date-time' }) declare lastSuccessfulAt: string; @ApiProperty() declare isStale: boolean; @ApiProperty({ type: MoneyDto, isArray: true }) declare totalsByCurrency: MoneyDto[]; @ApiProperty({ type: PortfolioPositionDto, isArray: true }) declare positions: PortfolioPositionDto[]; @ApiProperty({ type: MoneyDto, isArray: true }) declare cashBalances: MoneyDto[]; @ApiProperty({ type: PortfolioStructureDto }) declare structure: PortfolioStructureDto; } export class PortfolioResourceDto { @ApiProperty({ type: PortfolioDto, nullable: true }) declare data: null | PortfolioDto; @ApiProperty({ type: InvestmentResourceMetaDto }) declare meta: InvestmentResourceMetaDto; }