Files
backend/src/modules/investments/portfolio/presentation/portfolio.dto.ts
T
ksv741 5680f2655c
Backend verify / commits (pull_request) Successful in 1m33s
Backend verify / security (pull_request) Successful in 1m3s
Backend verify / verify (pull_request) Successful in 6m6s
feat(portfolio): store and publish instrument sector and issuer (WealthLedger/main#48)
2026-11-01 12:24:28 +03:00

150 lines
3.9 KiB
TypeScript

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 PortfolioIssuerDto {
@ApiProperty()
declare id: string;
@ApiProperty()
declare name: string;
}
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;
@ApiProperty({ type: String, nullable: true })
declare sector: null | string;
@ApiProperty({ type: PortfolioIssuerDto, nullable: true })
declare issuer: null | PortfolioIssuerDto;
}
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;
}