using Domain.Entities.Stocks; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace Infrastructure.Persistence.Configurations.Stocks; public sealed class OptionsDailyTradeConfiguration : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder builder) { builder.ToTable(nameof(OptionsDailyTrade), t => t.HasComment("옵션(일반/주식유가/주식코스닥) 일별매매 시세 (KRX OpenAPI drv)")); builder.HasKey(x => x.ID); builder.HasIndex(x => new { x.OptionsKind, x.IsuCode, x.TradeDate }).IsUnique(); builder.HasIndex(x => new { x.OptionsKind, x.TradeDate, x.TradeValue }).IsDescending(false, false, true); builder.Property(x => x.OptionsKind).HasConversion().IsRequired().HasComment("옵션 상품군 구분 (1=일반옵션, 2=주식옵션유가, 3=주식옵션코스닥)"); builder.Property(x => x.IsuCode).HasMaxLength(12).IsRequired().HasComment("종목코드 (ISU_CD) — 8자리 영숫자"); builder.Property(x => x.IsuName).HasMaxLength(100).IsRequired().HasComment("종목명"); builder.Property(x => x.RightType).HasConversion().IsRequired().HasComment("권리유형 (RGHT_TP_NM — 1=Call, 2=Put)"); builder.Property(x => x.StrikePrice).HasPrecision(18, 2).HasComment("행사가 (ISU_NM 에서 파싱)"); builder.Property(x => x.Close).HasPrecision(18, 2).HasComment("종가 (TDD_CLSPRC)"); builder.Property(x => x.Open).HasPrecision(18, 2).HasComment("시가 (TDD_OPNPRC)"); builder.Property(x => x.High).HasPrecision(18, 2).HasComment("고가 (TDD_HGPRC)"); builder.Property(x => x.Low).HasPrecision(18, 2).HasComment("저가 (TDD_LWPRC)"); builder.Property(x => x.ChangeAmount).HasPrecision(18, 2).HasComment("전일 대비 (CMPPREVDD_PRC)"); builder.Property(x => x.ImpliedVolatility).HasPrecision(9, 3).HasComment("내재변동성 % (IMP_VOLT)"); builder.Property(x => x.NextDayBasePrice).HasPrecision(18, 2).HasComment("익일정산가 (NXTDD_BAS_PRC)"); builder.Property(x => x.Volume).HasComment("거래량 (ACC_TRDVOL)"); builder.Property(x => x.TradeValue).HasComment("거래대금 (ACC_TRDVAL, 원)"); builder.Property(x => x.OpenInterest).HasComment("미결제약정 (ACC_OPNINT_QTY)"); builder.Property(x => x.ProductName).HasMaxLength(100).HasComment("상품구분 (PROD_NM)"); } }