Files
a-share-analysis/server/apps/api/src/market-overview/market-overview.dto.ts
T

148 lines
3.4 KiB
TypeScript

import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
export type MarketOverviewStatus = 'fresh' | 'delayed' | 'partial' | 'unavailable';
export type QuoteDirection = 'up' | 'down' | 'flat';
export class MarketOverviewMetaDto {
@ApiProperty({ type: String })
snapshotId!: string;
@ApiProperty({ type: String, format: 'date-time' })
asOf!: string;
@ApiProperty({ type: String, enum: ['tdx'] })
source!: 'tdx';
@ApiProperty({ enum: ['fresh', 'delayed', 'partial', 'unavailable'] })
status!: MarketOverviewStatus;
@ApiProperty({ type: [String] })
warnings!: string[];
}
export class IndexQuoteDto {
@ApiProperty({ type: String })
code!: string;
@ApiProperty({ type: String })
name!: string;
@ApiProperty({ type: Number })
price!: number;
@ApiPropertyOptional({ type: Number, nullable: true })
changePercent!: number | null;
@ApiProperty({ enum: ['up', 'down', 'flat'] })
direction!: QuoteDirection;
@ApiProperty({ type: String })
tradeDate!: string;
}
export class IndicesDataDto {
@ApiProperty({ type: [IndexQuoteDto] })
items!: IndexQuoteDto[];
}
export class SummaryDataDto {
@ApiProperty({ type: String })
verdict!: string;
@ApiProperty({ type: String })
marketStatus!: string;
@ApiProperty({ type: String })
volumeStatus!: string;
@ApiProperty({ type: String })
sentimentStatus!: string;
@ApiProperty({ type: [String] })
drivers!: string[];
@ApiProperty({ type: [String] })
risks!: string[];
}
export class BreadthDataDto {
@ApiProperty({ type: Number })
advancing!: number;
@ApiProperty({ type: Number })
declining!: number;
@ApiProperty({ type: Number, nullable: true })
unchanged!: number | null;
}
export class SectorQuoteDto {
@ApiProperty({ type: String })
code!: string;
@ApiProperty({ type: String })
name!: string;
@ApiProperty({ type: Number })
changePercent!: number;
@ApiProperty({ enum: ['up', 'down', 'flat'] })
direction!: QuoteDirection;
@ApiProperty({ type: String })
tradeDate!: string;
}
export class SectorDataDto {
@ApiProperty({ type: [SectorQuoteDto] })
items!: SectorQuoteDto[];
}
export class FundDataDto {
@ApiProperty({ type: Number })
currentAmount!: number;
@ApiProperty({ type: Number })
previousAmount!: number;
@ApiProperty({ type: Number })
changePercent!: number;
@ApiProperty({ type: String, example: '亿元' })
unit!: '亿元';
@ApiProperty({ type: Number, minimum: 1, maximum: 3 })
marketCount!: number;
@ApiProperty({ type: String, example: '20260818' })
tradeDate!: string;
@ApiProperty({ type: String, example: '20260817' })
previousTradeDate!: string;
}
export class SummaryResponseDto extends MarketOverviewMetaDto {
@ApiProperty({ type: () => SummaryDataDto, nullable: true })
data!: SummaryDataDto | null;
}
export class IndicesResponseDto extends MarketOverviewMetaDto {
@ApiProperty({ type: () => IndicesDataDto, nullable: true })
data!: IndicesDataDto | null;
}
export class BreadthResponseDto extends MarketOverviewMetaDto {
@ApiProperty({ type: () => BreadthDataDto, nullable: true })
data!: BreadthDataDto | null;
}
export class SectorsResponseDto extends MarketOverviewMetaDto {
@ApiProperty({ type: () => SectorDataDto, nullable: true })
data!: SectorDataDto | null;
}
export class FundsResponseDto extends MarketOverviewMetaDto {
@ApiProperty({ type: () => FundDataDto, nullable: true })
data!: FundDataDto | null;
}