20260706045333_AddDerivativeDailyTrade.cs 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. using System;
  2. using Microsoft.EntityFrameworkCore.Migrations;
  3. #nullable disable
  4. namespace Infrastructure.Migrations.AppDb
  5. {
  6. /// <inheritdoc />
  7. public partial class AddDerivativeDailyTrade : Migration
  8. {
  9. /// <inheritdoc />
  10. protected override void Up(MigrationBuilder migrationBuilder)
  11. {
  12. migrationBuilder.CreateTable(
  13. name: "FuturesDailyTrade",
  14. columns: table => new
  15. {
  16. ID = table.Column<long>(type: "bigint", nullable: false)
  17. .Annotation("SqlServer:Identity", "1, 1"),
  18. FuturesKind = table.Column<byte>(type: "tinyint", nullable: false, comment: "선물 상품군 구분 (1=일반선물, 2=주식선물유가, 3=주식선물코스닥)"),
  19. IsuCode = table.Column<string>(type: "nvarchar(12)", maxLength: 12, nullable: false, comment: "종목코드 (ISU_CD) — 8자리 영숫자"),
  20. IsuName = 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: "종가 (TDD_CLSPRC)"),
  23. Open = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, comment: "시가 (TDD_OPNPRC)"),
  24. High = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, comment: "고가 (TDD_HGPRC)"),
  25. Low = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, comment: "저가 (TDD_LWPRC)"),
  26. ChangeAmount = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, comment: "전일 대비 (CMPPREVDD_PRC)"),
  27. SpotPrice = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: true, comment: "현물가 (SPOT_PRC)"),
  28. SettlePrice = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: true, comment: "정산가 (SETL_PRC)"),
  29. Volume = table.Column<long>(type: "bigint", nullable: false, comment: "거래량 (ACC_TRDVOL)"),
  30. TradeValue = table.Column<long>(type: "bigint", nullable: false, comment: "거래대금 (ACC_TRDVAL, 원)"),
  31. OpenInterest = table.Column<long>(type: "bigint", nullable: true, comment: "미결제약정 (ACC_OPNINT_QTY)"),
  32. ProductName = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: true, comment: "상품구분 (PROD_NM)"),
  33. MarketName = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: true, comment: "시장구분 (MKT_NM 정규/야간)"),
  34. CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false)
  35. },
  36. constraints: table =>
  37. {
  38. table.PrimaryKey("PK_FuturesDailyTrade", x => x.ID);
  39. },
  40. comment: "선물(일반/주식유가/주식코스닥) 일별매매 시세 (KRX OpenAPI drv)");
  41. migrationBuilder.CreateTable(
  42. name: "OptionsDailyTrade",
  43. columns: table => new
  44. {
  45. ID = table.Column<long>(type: "bigint", nullable: false)
  46. .Annotation("SqlServer:Identity", "1, 1"),
  47. OptionsKind = table.Column<byte>(type: "tinyint", nullable: false, comment: "옵션 상품군 구분 (1=일반옵션, 2=주식옵션유가, 3=주식옵션코스닥)"),
  48. IsuCode = table.Column<string>(type: "nvarchar(12)", maxLength: 12, nullable: false, comment: "종목코드 (ISU_CD) — 8자리 영숫자"),
  49. IsuName = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false, comment: "종목명"),
  50. TradeDate = table.Column<DateOnly>(type: "date", nullable: false),
  51. RightType = table.Column<byte>(type: "tinyint", nullable: false, comment: "권리유형 (RGHT_TP_NM — 1=Call, 2=Put)"),
  52. StrikePrice = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: true, comment: "행사가 (ISU_NM 에서 파싱)"),
  53. Close = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, comment: "종가 (TDD_CLSPRC)"),
  54. Open = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, comment: "시가 (TDD_OPNPRC)"),
  55. High = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, comment: "고가 (TDD_HGPRC)"),
  56. Low = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, comment: "저가 (TDD_LWPRC)"),
  57. ChangeAmount = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, comment: "전일 대비 (CMPPREVDD_PRC)"),
  58. ImpliedVolatility = table.Column<decimal>(type: "decimal(9,3)", precision: 9, scale: 3, nullable: true, comment: "내재변동성 % (IMP_VOLT)"),
  59. NextDayBasePrice = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: true, comment: "익일정산가 (NXTDD_BAS_PRC)"),
  60. Volume = table.Column<long>(type: "bigint", nullable: false, comment: "거래량 (ACC_TRDVOL)"),
  61. TradeValue = table.Column<long>(type: "bigint", nullable: false, comment: "거래대금 (ACC_TRDVAL, 원)"),
  62. OpenInterest = table.Column<long>(type: "bigint", nullable: true, comment: "미결제약정 (ACC_OPNINT_QTY)"),
  63. ProductName = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: true, comment: "상품구분 (PROD_NM)"),
  64. CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false)
  65. },
  66. constraints: table =>
  67. {
  68. table.PrimaryKey("PK_OptionsDailyTrade", x => x.ID);
  69. },
  70. comment: "옵션(일반/주식유가/주식코스닥) 일별매매 시세 (KRX OpenAPI drv)");
  71. migrationBuilder.CreateIndex(
  72. name: "IX_FuturesDailyTrade_FuturesKind_IsuCode_TradeDate",
  73. table: "FuturesDailyTrade",
  74. columns: new[] { "FuturesKind", "IsuCode", "TradeDate" },
  75. unique: true);
  76. migrationBuilder.CreateIndex(
  77. name: "IX_FuturesDailyTrade_FuturesKind_TradeDate_TradeValue",
  78. table: "FuturesDailyTrade",
  79. columns: new[] { "FuturesKind", "TradeDate", "TradeValue" },
  80. descending: new[] { false, false, true });
  81. migrationBuilder.CreateIndex(
  82. name: "IX_OptionsDailyTrade_OptionsKind_IsuCode_TradeDate",
  83. table: "OptionsDailyTrade",
  84. columns: new[] { "OptionsKind", "IsuCode", "TradeDate" },
  85. unique: true);
  86. migrationBuilder.CreateIndex(
  87. name: "IX_OptionsDailyTrade_OptionsKind_TradeDate_TradeValue",
  88. table: "OptionsDailyTrade",
  89. columns: new[] { "OptionsKind", "TradeDate", "TradeValue" },
  90. descending: new[] { false, false, true });
  91. }
  92. /// <inheritdoc />
  93. protected override void Down(MigrationBuilder migrationBuilder)
  94. {
  95. migrationBuilder.DropTable(
  96. name: "FuturesDailyTrade");
  97. migrationBuilder.DropTable(
  98. name: "OptionsDailyTrade");
  99. }
  100. }
  101. }