EtpDailyTradeConfiguration.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536
  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 EtpDailyTradeConfiguration : IEntityTypeConfiguration<EtpDailyTrade>
  6. {
  7. public void Configure(EntityTypeBuilder<EtpDailyTrade> builder)
  8. {
  9. builder.ToTable(nameof(EtpDailyTrade), t => t.HasComment("증권상품(ETF/ETN/ELW) 일별매매 시세 (KRX OpenAPI etp)"));
  10. builder.HasKey(x => x.ID);
  11. builder.HasIndex(x => new { x.EtpType, x.Code, x.TradeDate }).IsUnique();
  12. builder.HasIndex(x => new { x.EtpType, x.TradeDate, x.TradeValue }).IsDescending(false, false, true);
  13. builder.Property(x => x.EtpType).HasConversion<byte>().IsRequired().HasComment("증권상품 구분 (1=ETF, 2=ETN, 3=ELW)");
  14. builder.Property(x => x.Code).HasMaxLength(6).IsFixedLength().IsRequired().HasComment("단축코드 (ISU_CD)");
  15. builder.Property(x => x.Name).HasMaxLength(100).IsRequired().HasComment("종목명");
  16. builder.Property(x => x.Close).HasPrecision(18, 2).HasComment("종가");
  17. builder.Property(x => x.Open).HasPrecision(18, 2).HasComment("시가");
  18. builder.Property(x => x.High).HasPrecision(18, 2).HasComment("고가");
  19. builder.Property(x => x.Low).HasPrecision(18, 2).HasComment("저가");
  20. builder.Property(x => x.ChangeAmount).HasPrecision(18, 2).HasComment("전일 대비");
  21. builder.Property(x => x.ChangeRate).HasPrecision(7, 2).HasComment("등락률 % (ELW 는 0)");
  22. builder.Property(x => x.Volume).HasComment("거래량");
  23. builder.Property(x => x.TradeValue).HasComment("거래대금 (원)");
  24. builder.Property(x => x.MarketCap).HasComment("시가총액 (원)");
  25. builder.Property(x => x.ListedShares).HasComment("상장증권수/상장좌수");
  26. builder.Property(x => x.Nav).HasPrecision(18, 2).HasComment("ETF NAV / ETN 지표가치(IV)");
  27. builder.Property(x => x.NetAssetTotal).HasComment("ETF 순자산총액 / ETN 지표가치총액 (원)");
  28. builder.Property(x => x.BaseIndexName).HasMaxLength(100).HasComment("기초지수명 (ETF/ETN)");
  29. builder.Property(x => x.BaseIndexClose).HasPrecision(18, 2).HasComment("기초지수 종가 (ETF/ETN)");
  30. builder.Property(x => x.Underlying).HasMaxLength(100).HasComment("ELW 기초자산명");
  31. builder.Property(x => x.UnderlyingClose).HasPrecision(18, 2).HasComment("ELW 기초자산 종가");
  32. }
  33. }