OptionsDailyTradeConfiguration.cs 2.7 KB

12345678910111213141516171819202122232425262728293031323334
  1. using Domain.Entities.Stocks;
  2. using Microsoft.EntityFrameworkCore;
  3. using Microsoft.EntityFrameworkCore.Metadata.Builders;
  4. namespace Infrastructure.Persistence.Configurations.Stocks;
  5. public sealed class OptionsDailyTradeConfiguration : IEntityTypeConfiguration<OptionsDailyTrade>
  6. {
  7. public void Configure(EntityTypeBuilder<OptionsDailyTrade> builder)
  8. {
  9. builder.ToTable(nameof(OptionsDailyTrade), t => t.HasComment("옵션(일반/주식유가/주식코스닥) 일별매매 시세 (KRX OpenAPI drv)"));
  10. builder.HasKey(x => x.ID);
  11. builder.HasIndex(x => new { x.OptionsKind, x.IsuCode, x.TradeDate, x.Session }).IsUnique();
  12. builder.HasIndex(x => new { x.OptionsKind, x.TradeDate, x.Session, x.TradeValue }).IsDescending(false, false, false, true);
  13. builder.Property(x => x.OptionsKind).HasConversion<byte>().IsRequired().HasComment("옵션 상품군 구분 (1=일반옵션, 2=주식옵션유가, 3=주식옵션코스닥)");
  14. builder.Property(x => x.Session).HasConversion<byte>().IsRequired().HasComment("매매 세션 (1=정규, 2=야간) — 수집기가 항상 명시 세팅(0-sentinel 회피 위해 DB 기본값 미설정)");
  15. builder.Property(x => x.IsuCode).HasMaxLength(12).IsRequired().HasComment("종목코드 (ISU_CD) — 8자리 영숫자");
  16. builder.Property(x => x.IsuName).HasMaxLength(100).IsRequired().HasComment("종목명");
  17. builder.Property(x => x.RightType).HasConversion<byte>().IsRequired().HasComment("권리유형 (RGHT_TP_NM — 1=Call, 2=Put)");
  18. builder.Property(x => x.StrikePrice).HasPrecision(18, 2).HasComment("행사가 (ISU_NM 에서 파싱)");
  19. builder.Property(x => x.Close).HasPrecision(18, 2).HasComment("종가 (TDD_CLSPRC)");
  20. builder.Property(x => x.Open).HasPrecision(18, 2).HasComment("시가 (TDD_OPNPRC)");
  21. builder.Property(x => x.High).HasPrecision(18, 2).HasComment("고가 (TDD_HGPRC)");
  22. builder.Property(x => x.Low).HasPrecision(18, 2).HasComment("저가 (TDD_LWPRC)");
  23. builder.Property(x => x.ChangeAmount).HasPrecision(18, 2).HasComment("전일 대비 (CMPPREVDD_PRC)");
  24. builder.Property(x => x.ImpliedVolatility).HasPrecision(9, 3).HasComment("내재변동성 % (IMP_VOLT)");
  25. builder.Property(x => x.NextDayBasePrice).HasPrecision(18, 2).HasComment("익일정산가 (NXTDD_BAS_PRC)");
  26. builder.Property(x => x.Volume).HasComment("거래량 (ACC_TRDVOL)");
  27. builder.Property(x => x.TradeValue).HasComment("거래대금 (ACC_TRDVAL, 원)");
  28. builder.Property(x => x.OpenInterest).HasComment("미결제약정 (ACC_OPNINT_QTY)");
  29. builder.Property(x => x.ProductName).HasMaxLength(100).HasComment("상품구분 (PROD_NM)");
  30. }
  31. }