using Domain.Entities.Stocks; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace Infrastructure.Persistence.Configurations.Stocks; public sealed class BondDailyTradeConfiguration : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder builder) { builder.ToTable(nameof(BondDailyTrade), t => t.HasComment("채권(국채전문유통/일반채권/소액채권) 일별매매 시세 (KRX OpenAPI bon)")); builder.HasKey(x => x.ID); builder.HasIndex(x => new { x.BondMarket, x.Code, x.TradeDate }).IsUnique(); builder.HasIndex(x => new { x.BondMarket, x.TradeDate, x.TradeValue }).IsDescending(false, false, true); builder.Property(x => x.BondMarket).HasConversion().IsRequired().HasComment("채권 시장 구분 (1=국채전문유통, 2=일반채권, 3=소액채권)"); builder.Property(x => x.Code).HasMaxLength(12).IsRequired().HasComment("단축코드 (ISU_CD) — 12자리 ISIN"); builder.Property(x => x.Name).HasMaxLength(100).IsRequired().HasComment("종목명"); builder.Property(x => x.Close).HasPrecision(18, 2).HasComment("종가 가격 (CLSPRC)"); builder.Property(x => x.Open).HasPrecision(18, 2).HasComment("시가 가격 (OPNPRC)"); builder.Property(x => x.High).HasPrecision(18, 2).HasComment("고가 가격 (HGPRC)"); builder.Property(x => x.Low).HasPrecision(18, 2).HasComment("저가 가격 (LWPRC)"); builder.Property(x => x.ChangeAmount).HasPrecision(18, 2).HasComment("전일 대비 (CMPPREVDD_PRC)"); builder.Property(x => x.YieldToMaturity).HasPrecision(9, 3).HasComment("만기수익률 % (CLSPRC_YD)"); builder.Property(x => x.OpenYield).HasPrecision(9, 3).HasComment("시가 수익률 % (OPNPRC_YD)"); builder.Property(x => x.HighYield).HasPrecision(9, 3).HasComment("고가 수익률 % (HGPRC_YD)"); builder.Property(x => x.LowYield).HasPrecision(9, 3).HasComment("저가 수익률 % (LWPRC_YD)"); builder.Property(x => x.Volume).HasComment("거래량 (ACC_TRDVOL)"); builder.Property(x => x.TradeValue).HasComment("거래대금 (ACC_TRDVAL, 원)"); builder.Property(x => x.MaturityYears).HasMaxLength(20).HasComment("만기년수 (국채전문, BND_EXP_TP_NM)"); builder.Property(x => x.IssueType).HasMaxLength(20).HasComment("종목구분 (국채전문, GOVBND_ISU_TP_NM)"); } }