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