import { IsString, IsNumber, IsEnum, IsOptional, IsDateString } from 'class-validator';
import { ApiProperty } from '@nestjs/swagger';

export class OptionPricingDto {
  @ApiProperty({ description: '标的资产代码' })
  @IsString()
  underlying: string;

  @ApiProperty({ description: '行权价' })
  @IsNumber()
  strike: number;

  @ApiProperty({ description: '到期日 (YYYY-MM-DD)' })
  @IsDateString()
  expiry: string;

  @ApiProperty({ description: '期权类型', enum: ['call', 'put'] })
  @IsEnum(['call', 'put'])
  type: 'call' | 'put';

  @ApiProperty({ description: '标的资产价格', required: false })
  @IsOptional()
  @IsNumber()
  underlyingPrice?: number;

  @ApiProperty({ description: '波动率 (如 0.25 表示 25%)', required: false })
  @IsOptional()
  @IsNumber()
  volatility?: number;

  @ApiProperty({ description: '无风险利率 (如 0.025 表示 2.5%)', required: false })
  @IsOptional()
  @IsNumber()
  riskFreeRate?: number;
}

export class GetOptionChainDto {
  @ApiProperty({ description: '到期日 (YYYY-MM-DD)', required: false })
  @IsOptional()
  @IsDateString()
  expiry?: string;
}

export class CalculateStrategyDto {
  @ApiProperty({ description: '策略名称', example: 'long_call_spread' })
  @IsString()
  strategy: string;

  @ApiProperty({ description: '标的资产代码' })
  @IsString()
  underlying: string;

  @ApiProperty({ description: '到期日 (YYYY-MM-DD)' })
  @IsDateString()
  expiry: string;

  @ApiProperty({ description: '行权价差', type: [Number] })
  strikes: number[];
}
