moex-vibe/apps/backend/src/modules/portfolio/dto/add-position.dto.ts

60 lines
1.0 KiB
TypeScript

import {
IsString,
IsOptional,
IsInt,
IsNumber,
Min,
IsArray,
IsIn,
MaxLength,
MinLength,
} from 'class-validator';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
const TAGS = [
'DIVIDEND',
'GROWTH',
'DEFENSIVE',
'SPECULATIVE',
'BOND',
'ETF',
'GOVERNMENT',
'CASH',
] as const;
export class AddPositionDto {
@ApiProperty({ example: 'SBER' })
@IsString()
@MinLength(1)
@MaxLength(50)
secid!: string;
@ApiProperty({ example: 10 })
@IsInt()
@Min(0)
quantity!: number;
@ApiPropertyOptional({ example: 250.5 })
@IsNumber()
@Min(0)
@IsOptional()
buyPrice?: number;
@ApiPropertyOptional({ example: '2026-06-01' })
@IsString()
@IsOptional()
buyDate?: string;
@ApiPropertyOptional({ example: 'Покупка на дип' })
@IsString()
@IsOptional()
@MaxLength(500)
notes?: string;
@ApiPropertyOptional({ example: ['DIVIDEND', 'GROWTH'], enum: TAGS, isArray: true })
@IsArray()
@IsIn(TAGS, { each: true })
@IsOptional()
tags?: string[];
}