CommodityDailyTradeConfiguration.cs 2.2 KB

1234567891011121314151617181920212223242526272829
  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 CommodityDailyTradeConfiguration : IEntityTypeConfiguration<CommodityDailyTrade>
  6. {
  7. public void Configure(EntityTypeBuilder<CommodityDailyTrade> builder)
  8. {
  9. builder.ToTable(nameof(CommodityDailyTrade), t => t.HasComment("일반상품(석유/금/배출권) 일별매매 시세 (KRX OpenAPI gen)"));
  10. builder.HasKey(x => x.ID);
  11. builder.HasIndex(x => new { x.CommodityMarket, x.Code, x.TradeDate }).IsUnique();
  12. builder.HasIndex(x => new { x.CommodityMarket, x.TradeDate, x.TradeValue }).IsDescending(false, false, true);
  13. builder.Property(x => x.CommodityMarket).HasConversion<byte>().IsRequired().HasComment("일반상품 시장 구분 (1=석유, 2=금, 3=배출권)");
  14. builder.Property(x => x.Code).HasMaxLength(40).IsRequired().HasComment("단축코드 (ISU_CD) — 석유는 OIL_NM(유종구분)");
  15. builder.Property(x => x.Name).HasMaxLength(100).IsRequired().HasComment("종목명 (ISU_NM) — 석유는 유종구분");
  16. builder.Property(x => x.Close).HasPrecision(18, 2).HasComment("종가 (TDD_CLSPRC) — 석유는 가중평균가격_경쟁");
  17. builder.Property(x => x.Open).HasPrecision(18, 2).HasComment("시가 (TDD_OPNPRC) — 석유 0");
  18. builder.Property(x => x.High).HasPrecision(18, 2).HasComment("고가 (TDD_HGPRC) — 석유 0");
  19. builder.Property(x => x.Low).HasPrecision(18, 2).HasComment("저가 (TDD_LWPRC) — 석유 0");
  20. builder.Property(x => x.ChangeAmount).HasPrecision(18, 2).HasComment("전일 대비 (CMPPREVDD_PRC) — 금/배출권만");
  21. builder.Property(x => x.ChangeRate).HasPrecision(9, 2).HasComment("등락률 % (FLUC_RT) — 금/배출권만");
  22. builder.Property(x => x.WeightedDiscussionPrice).HasPrecision(18, 2).HasComment("가중평균가격_협의 (WT_DIS_AVG_PRC) — 석유만");
  23. builder.Property(x => x.Volume).HasComment("거래량 (ACC_TRDVOL)");
  24. builder.Property(x => x.TradeValue).HasComment("거래대금 (ACC_TRDVAL, 원)");
  25. }
  26. }