| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- using System;
- using Microsoft.EntityFrameworkCore.Migrations;
- #nullable disable
- namespace Infrastructure.Migrations.AppDb
- {
- /// <inheritdoc />
- public partial class AddDerivativeDailyTrade : Migration
- {
- /// <inheritdoc />
- protected override void Up(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.CreateTable(
- name: "FuturesDailyTrade",
- columns: table => new
- {
- ID = table.Column<long>(type: "bigint", nullable: false)
- .Annotation("SqlServer:Identity", "1, 1"),
- FuturesKind = table.Column<byte>(type: "tinyint", nullable: false, comment: "선물 상품군 구분 (1=일반선물, 2=주식선물유가, 3=주식선물코스닥)"),
- IsuCode = table.Column<string>(type: "nvarchar(12)", maxLength: 12, nullable: false, comment: "종목코드 (ISU_CD) — 8자리 영숫자"),
- IsuName = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false, comment: "종목명"),
- TradeDate = table.Column<DateOnly>(type: "date", nullable: false),
- Close = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, comment: "종가 (TDD_CLSPRC)"),
- Open = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, comment: "시가 (TDD_OPNPRC)"),
- High = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, comment: "고가 (TDD_HGPRC)"),
- Low = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, comment: "저가 (TDD_LWPRC)"),
- ChangeAmount = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, comment: "전일 대비 (CMPPREVDD_PRC)"),
- SpotPrice = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: true, comment: "현물가 (SPOT_PRC)"),
- SettlePrice = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: true, comment: "정산가 (SETL_PRC)"),
- Volume = table.Column<long>(type: "bigint", nullable: false, comment: "거래량 (ACC_TRDVOL)"),
- TradeValue = table.Column<long>(type: "bigint", nullable: false, comment: "거래대금 (ACC_TRDVAL, 원)"),
- OpenInterest = table.Column<long>(type: "bigint", nullable: true, comment: "미결제약정 (ACC_OPNINT_QTY)"),
- ProductName = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: true, comment: "상품구분 (PROD_NM)"),
- MarketName = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: true, comment: "시장구분 (MKT_NM 정규/야간)"),
- CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_FuturesDailyTrade", x => x.ID);
- },
- comment: "선물(일반/주식유가/주식코스닥) 일별매매 시세 (KRX OpenAPI drv)");
- migrationBuilder.CreateTable(
- name: "OptionsDailyTrade",
- columns: table => new
- {
- ID = table.Column<long>(type: "bigint", nullable: false)
- .Annotation("SqlServer:Identity", "1, 1"),
- OptionsKind = table.Column<byte>(type: "tinyint", nullable: false, comment: "옵션 상품군 구분 (1=일반옵션, 2=주식옵션유가, 3=주식옵션코스닥)"),
- IsuCode = table.Column<string>(type: "nvarchar(12)", maxLength: 12, nullable: false, comment: "종목코드 (ISU_CD) — 8자리 영숫자"),
- IsuName = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false, comment: "종목명"),
- TradeDate = table.Column<DateOnly>(type: "date", nullable: false),
- RightType = table.Column<byte>(type: "tinyint", nullable: false, comment: "권리유형 (RGHT_TP_NM — 1=Call, 2=Put)"),
- StrikePrice = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: true, comment: "행사가 (ISU_NM 에서 파싱)"),
- Close = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, comment: "종가 (TDD_CLSPRC)"),
- Open = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, comment: "시가 (TDD_OPNPRC)"),
- High = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, comment: "고가 (TDD_HGPRC)"),
- Low = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, comment: "저가 (TDD_LWPRC)"),
- ChangeAmount = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, comment: "전일 대비 (CMPPREVDD_PRC)"),
- ImpliedVolatility = table.Column<decimal>(type: "decimal(9,3)", precision: 9, scale: 3, nullable: true, comment: "내재변동성 % (IMP_VOLT)"),
- NextDayBasePrice = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: true, comment: "익일정산가 (NXTDD_BAS_PRC)"),
- Volume = table.Column<long>(type: "bigint", nullable: false, comment: "거래량 (ACC_TRDVOL)"),
- TradeValue = table.Column<long>(type: "bigint", nullable: false, comment: "거래대금 (ACC_TRDVAL, 원)"),
- OpenInterest = table.Column<long>(type: "bigint", nullable: true, comment: "미결제약정 (ACC_OPNINT_QTY)"),
- ProductName = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: true, comment: "상품구분 (PROD_NM)"),
- CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_OptionsDailyTrade", x => x.ID);
- },
- comment: "옵션(일반/주식유가/주식코스닥) 일별매매 시세 (KRX OpenAPI drv)");
- migrationBuilder.CreateIndex(
- name: "IX_FuturesDailyTrade_FuturesKind_IsuCode_TradeDate",
- table: "FuturesDailyTrade",
- columns: new[] { "FuturesKind", "IsuCode", "TradeDate" },
- unique: true);
- migrationBuilder.CreateIndex(
- name: "IX_FuturesDailyTrade_FuturesKind_TradeDate_TradeValue",
- table: "FuturesDailyTrade",
- columns: new[] { "FuturesKind", "TradeDate", "TradeValue" },
- descending: new[] { false, false, true });
- migrationBuilder.CreateIndex(
- name: "IX_OptionsDailyTrade_OptionsKind_IsuCode_TradeDate",
- table: "OptionsDailyTrade",
- columns: new[] { "OptionsKind", "IsuCode", "TradeDate" },
- unique: true);
- migrationBuilder.CreateIndex(
- name: "IX_OptionsDailyTrade_OptionsKind_TradeDate_TradeValue",
- table: "OptionsDailyTrade",
- columns: new[] { "OptionsKind", "TradeDate", "TradeValue" },
- descending: new[] { false, false, true });
- }
- /// <inheritdoc />
- protected override void Down(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.DropTable(
- name: "FuturesDailyTrade");
- migrationBuilder.DropTable(
- name: "OptionsDailyTrade");
- }
- }
- }
|