import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'; import { MarketOverviewMetaDto, type QuoteDirection } from '../market-overview.dto'; export type DetailInstrumentType = 'index' | 'sector'; export type DetailPeriod = '1d'; export class DetailInstrumentDto { @ApiProperty({ type: String }) code!: string; @ApiProperty({ type: String }) name!: string; @ApiProperty({ enum: ['index', 'sector'] }) type!: DetailInstrumentType; } export class DetailQuoteDto { @ApiProperty({ type: Number }) price!: number; @ApiPropertyOptional({ type: Number, nullable: true }) changePercent!: number | null; @ApiProperty({ enum: ['up', 'down', 'flat'] }) direction!: QuoteDirection; @ApiProperty({ type: String, example: '20260818' }) tradeDate!: string; } export class DetailSeriesPointDto { @ApiProperty({ type: String, example: '20260818' }) time!: string; @ApiProperty({ type: Number }) open!: number; @ApiProperty({ type: Number }) high!: number; @ApiProperty({ type: Number }) low!: number; @ApiProperty({ type: Number }) close!: number; @ApiPropertyOptional({ type: Number, nullable: true }) amount!: number | null; @ApiPropertyOptional({ type: Number, nullable: true }) volume!: number | null; } export class DetailAvailableViewsDto { @ApiProperty({ type: Boolean }) kline!: boolean; @ApiProperty({ type: Boolean }) intraday!: boolean; } export class IndexDetailDataDto { @ApiProperty({ type: () => DetailInstrumentDto }) instrument!: DetailInstrumentDto; @ApiProperty({ type: () => DetailQuoteDto }) quote!: DetailQuoteDto; @ApiProperty({ type: [DetailSeriesPointDto] }) series!: DetailSeriesPointDto[]; @ApiProperty({ type: () => DetailAvailableViewsDto }) availableViews!: DetailAvailableViewsDto; } export class SectorDetailDataDto { @ApiProperty({ type: () => DetailInstrumentDto }) instrument!: DetailInstrumentDto; @ApiProperty({ type: () => DetailQuoteDto }) quote!: DetailQuoteDto; @ApiProperty({ type: [DetailSeriesPointDto] }) series!: DetailSeriesPointDto[]; @ApiProperty({ type: () => DetailAvailableViewsDto }) availableViews!: DetailAvailableViewsDto; } export class IndexDetailResponseDto extends MarketOverviewMetaDto { @ApiProperty({ type: () => IndexDetailDataDto, nullable: true }) data!: IndexDetailDataDto | null; } export class SectorDetailResponseDto extends MarketOverviewMetaDto { @ApiProperty({ type: () => SectorDetailDataDto, nullable: true }) data!: SectorDetailDataDto | null; }