OptionsDailyTradeConfiguration.cs 2.7 KB

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