MarketQuoteSnapshotConfiguration.cs 1.9 KB

123456789101112131415161718192021222324252627282930
  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 MarketQuoteSnapshotConfiguration : IEntityTypeConfiguration<MarketQuoteSnapshot>
  6. {
  7. public void Configure(EntityTypeBuilder<MarketQuoteSnapshot> builder)
  8. {
  9. builder.ToTable(nameof(MarketQuoteSnapshot), t => t.HasComment("주요 종목·상품 시세 최신 스냅샷 (Stooq 일1회 upsert, 카테고리/그룹별)"));
  10. builder.HasKey(x => x.ID);
  11. builder.HasIndex(x => x.Symbol).IsUnique();
  12. builder.HasIndex(x => new { x.Category, x.GroupCode });
  13. builder.Property(x => x.Symbol).HasMaxLength(30).IsRequired().HasComment("외부 소스(Stooq) 심볼");
  14. builder.Property(x => x.Name).HasMaxLength(100).IsRequired().HasComment("표시명");
  15. builder.Property(x => x.Category).HasConversion<int>().HasComment("0 Stock,1 Commodity,2 Futures,3 Fx,4 BondYield");
  16. builder.Property(x => x.GroupCode).HasMaxLength(40).IsRequired().HasComment("프론트 그룹 키");
  17. builder.Property(x => x.CountryCode).HasMaxLength(2).IsRequired().HasComment("국가 코드 (ISO2, 상품은 빈값)");
  18. builder.Property(x => x.Close).HasPrecision(18, 2).HasComment("종가");
  19. builder.Property(x => x.PrevClose).HasPrecision(18, 2).HasComment("직전 거래일 종가");
  20. builder.Property(x => x.ChangeVal).HasPrecision(18, 2).HasComment("전일 대비");
  21. builder.Property(x => x.FlucRateBp).HasComment("등락률 basis point (%×100)");
  22. builder.Property(x => x.Open).HasPrecision(18, 2).HasComment("시가");
  23. builder.Property(x => x.High).HasPrecision(18, 2).HasComment("고가");
  24. builder.Property(x => x.Low).HasPrecision(18, 2).HasComment("저가");
  25. builder.Property(x => x.Volume).HasComment("거래량");
  26. }
  27. }