using Domain.Entities.Stocks; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace Infrastructure.Persistence.Configurations.Stocks; public sealed class WarrantDailyTradeConfiguration : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder builder) { builder.ToTable(nameof(WarrantDailyTrade), t => t.HasComment("신주인수권증권/증서 일별매매 시세 (KRX OpenAPI sto sw/sr)")); builder.HasKey(x => x.ID); builder.HasIndex(x => new { x.WarrantType, x.Code, x.TradeDate }).IsUnique(); builder.HasIndex(x => new { x.WarrantType, x.TradeDate, x.TradeValue }).IsDescending(false, false, true); builder.Property(x => x.WarrantType).HasConversion().IsRequired().HasComment("신주인수권 구분 (1=증권, 2=증서)"); builder.Property(x => x.Code).HasMaxLength(12).IsRequired().HasComment("단축코드 (ISU_CD) — 8자리 영숫자"); builder.Property(x => x.Name).HasMaxLength(100).IsRequired().HasComment("종목명"); builder.Property(x => x.Market).HasConversion().IsRequired().HasComment("시장 구분 (1=KOSPI, 2=KOSDAQ, 3=KONEX)"); builder.Property(x => x.Close).HasPrecision(18, 2).HasComment("종가"); builder.Property(x => x.Open).HasPrecision(18, 2).HasComment("시가"); builder.Property(x => x.High).HasPrecision(18, 2).HasComment("고가"); builder.Property(x => x.Low).HasPrecision(18, 2).HasComment("저가"); builder.Property(x => x.ChangeAmount).HasPrecision(18, 2).HasComment("전일 대비"); builder.Property(x => x.ChangeRate).HasPrecision(7, 2).HasComment("등락률 %"); builder.Property(x => x.Volume).HasComment("거래량"); builder.Property(x => x.TradeValue).HasComment("거래대금 (원)"); builder.Property(x => x.MarketCap).HasComment("시가총액 (원)"); builder.Property(x => x.ListedShares).HasComment("상장증권수"); builder.Property(x => x.TargetStockCode).HasMaxLength(6).HasComment("대상주식 단축코드 (TARSTK_ISU_SRT_CD)"); builder.Property(x => x.TargetStockName).HasMaxLength(100).HasComment("대상주식명 (TARSTK_ISU_NM)"); builder.Property(x => x.TargetStockPrice).HasPrecision(18, 2).HasComment("대상주식 현재가 (TARSTK_ISU_PRSNT_PRC)"); builder.Property(x => x.ExercisePrice).HasPrecision(18, 2).HasComment("행사가 (증권, EXER_PRC)"); builder.Property(x => x.ExerciseStartDate).HasComment("행사 시작일 (증권, EXST_STRT_DD)"); builder.Property(x => x.ExerciseEndDate).HasComment("행사 종료일 (증권, EXST_END_DD)"); builder.Property(x => x.IssuePrice).HasPrecision(18, 2).HasComment("발행가 (증서, ISU_PRC)"); builder.Property(x => x.DelistDate).HasComment("상장폐지일 (증서, DELIST_DD)"); } }