20260706040215_AddEtpDailyTrade.cs 4.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. using System;
  2. using Microsoft.EntityFrameworkCore.Migrations;
  3. #nullable disable
  4. namespace Infrastructure.Migrations.AppDb
  5. {
  6. /// <inheritdoc />
  7. public partial class AddEtpDailyTrade : Migration
  8. {
  9. /// <inheritdoc />
  10. protected override void Up(MigrationBuilder migrationBuilder)
  11. {
  12. migrationBuilder.CreateTable(
  13. name: "EtpDailyTrade",
  14. columns: table => new
  15. {
  16. ID = table.Column<long>(type: "bigint", nullable: false)
  17. .Annotation("SqlServer:Identity", "1, 1"),
  18. EtpType = table.Column<byte>(type: "tinyint", nullable: false, comment: "증권상품 구분 (1=ETF, 2=ETN, 3=ELW)"),
  19. Code = table.Column<string>(type: "nchar(6)", fixedLength: true, maxLength: 6, nullable: false, comment: "단축코드 (ISU_CD)"),
  20. Name = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false, comment: "종목명"),
  21. TradeDate = table.Column<DateOnly>(type: "date", nullable: false),
  22. Close = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, comment: "종가"),
  23. Open = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, comment: "시가"),
  24. High = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, comment: "고가"),
  25. Low = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, comment: "저가"),
  26. ChangeAmount = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, comment: "전일 대비"),
  27. ChangeRate = table.Column<decimal>(type: "decimal(7,2)", precision: 7, scale: 2, nullable: false, comment: "등락률 % (ELW 는 0)"),
  28. Volume = table.Column<long>(type: "bigint", nullable: false, comment: "거래량"),
  29. TradeValue = table.Column<long>(type: "bigint", nullable: false, comment: "거래대금 (원)"),
  30. MarketCap = table.Column<long>(type: "bigint", nullable: true, comment: "시가총액 (원)"),
  31. ListedShares = table.Column<long>(type: "bigint", nullable: true, comment: "상장증권수/상장좌수"),
  32. Nav = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: true, comment: "ETF NAV / ETN 지표가치(IV)"),
  33. NetAssetTotal = table.Column<long>(type: "bigint", nullable: true, comment: "ETF 순자산총액 / ETN 지표가치총액 (원)"),
  34. BaseIndexName = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: true, comment: "기초지수명 (ETF/ETN)"),
  35. BaseIndexClose = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: true, comment: "기초지수 종가 (ETF/ETN)"),
  36. Underlying = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: true, comment: "ELW 기초자산명"),
  37. UnderlyingClose = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: true, comment: "ELW 기초자산 종가"),
  38. CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false)
  39. },
  40. constraints: table =>
  41. {
  42. table.PrimaryKey("PK_EtpDailyTrade", x => x.ID);
  43. },
  44. comment: "증권상품(ETF/ETN/ELW) 일별매매 시세 (KRX OpenAPI etp)");
  45. migrationBuilder.CreateIndex(
  46. name: "IX_EtpDailyTrade_EtpType_Code_TradeDate",
  47. table: "EtpDailyTrade",
  48. columns: new[] { "EtpType", "Code", "TradeDate" },
  49. unique: true);
  50. migrationBuilder.CreateIndex(
  51. name: "IX_EtpDailyTrade_EtpType_TradeDate_TradeValue",
  52. table: "EtpDailyTrade",
  53. columns: new[] { "EtpType", "TradeDate", "TradeValue" },
  54. descending: new[] { false, false, true });
  55. }
  56. /// <inheritdoc />
  57. protected override void Down(MigrationBuilder migrationBuilder)
  58. {
  59. migrationBuilder.DropTable(
  60. name: "EtpDailyTrade");
  61. }
  62. }
  63. }