20260707123951_AddSeibroDeriv.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. using System;
  2. using Microsoft.EntityFrameworkCore.Migrations;
  3. #nullable disable
  4. namespace Infrastructure.Migrations.AppDb
  5. {
  6. /// <inheritdoc />
  7. public partial class AddSeibroDeriv : Migration
  8. {
  9. /// <inheritdoc />
  10. protected override void Up(MigrationBuilder migrationBuilder)
  11. {
  12. migrationBuilder.CreateTable(
  13. name: "DerivAsset",
  14. columns: table => new
  15. {
  16. ID = table.Column<int>(type: "int", nullable: false)
  17. .Annotation("SqlServer:Identity", "1, 1"),
  18. Isin = table.Column<string>(type: "nvarchar(12)", maxLength: 12, nullable: false, comment: "종목코드 (ISIN, 스탬핑)"),
  19. AssetSeq = table.Column<int>(type: "int", nullable: false, comment: "자산일련번호 (ASSET_SEQ)"),
  20. StndBassetCd = table.Column<string>(type: "nvarchar(12)", maxLength: 12, nullable: true, comment: "표준기초자산코드 (STND_BASSET_CD) — 원문(KSD31*·KR7* 등)"),
  21. StndBassetNm = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true, comment: "표준기초자산명 (STND_BASSET_NM)"),
  22. XrcStdprc = table.Column<decimal>(type: "decimal(28,10)", nullable: true, comment: "행사기준가 (XRC_STDPRC)"),
  23. XrcStopLolmtRatio = table.Column<decimal>(type: "decimal(8,3)", nullable: true, comment: "행사정지하한비율 (XRC_STOP_LOLMT_RATIO)"),
  24. XrcStopLolmtPrice = table.Column<decimal>(type: "decimal(28,10)", nullable: true, comment: "행사정지하한가격 (XRC_STOP_LOLMT_PRICE)"),
  25. XrcStopUplmtRatio = table.Column<decimal>(type: "decimal(8,3)", nullable: true, comment: "행사정지상한비율 (XRC_STOP_UPLMT_RATIO)"),
  26. XrcStopUplmtPrice = table.Column<decimal>(type: "decimal(28,10)", nullable: true, comment: "행사정지상한가격 (XRC_STOP_UPLMT_PRICE)"),
  27. BassetFirstValatTpcd = table.Column<string>(type: "nvarchar(1)", maxLength: 1, nullable: true, comment: "기초자산최초평가구분코드 (BASSET_FIRST_VALAT_TPCD)"),
  28. BassetLastValatTpcd = table.Column<string>(type: "nvarchar(1)", maxLength: 1, nullable: true, comment: "기초자산최종평가구분코드 (BASSET_LAST_VALAT_TPCD)"),
  29. FirstStdprcDecsnBeginDt = table.Column<DateOnly>(type: "date", nullable: true, comment: "최초기준가결정시작일자 (FIRST_STDPRC_DECSN_BEGIN_DT)"),
  30. FirstStdprcDecsnExpryDt = table.Column<DateOnly>(type: "date", nullable: true, comment: "최초기준가결정종료일자 (FIRST_STDPRC_DECSN_EXPRY_DT)"),
  31. LastStdprcDecsnBeginDt = table.Column<DateOnly>(type: "date", nullable: true, comment: "최종기준가결정시작일자 (LAST_STDPRC_DECSN_BEGIN_DT)"),
  32. LastStdprcDecsnExpryDt = table.Column<DateOnly>(type: "date", nullable: true, comment: "최종기준가결정종료일자 (LAST_STDPRC_DECSN_EXPRY_DT)"),
  33. RvltSeverTpcd = table.Column<string>(type: "nvarchar(1)", maxLength: 1, nullable: true, comment: "절상절사구분코드 (RVLT_SEVER_TPCD)"),
  34. UpdatedAt = table.Column<DateTime>(type: "datetime2", nullable: false)
  35. },
  36. constraints: table =>
  37. {
  38. table.PrimaryKey("PK_DerivAsset", x => x.ID);
  39. },
  40. comment: "SEIBro 파생결합증권 기초자산 정보 (getAssetInfo) — 기초자산명·행사기준가·평가일. StndBassetCd 는 반환 원문(KSD31* 체계 가능)");
  41. migrationBuilder.CreateTable(
  42. name: "DerivAssetExercise",
  43. columns: table => new
  44. {
  45. ID = table.Column<int>(type: "int", nullable: false)
  46. .Annotation("SqlServer:Identity", "1, 1"),
  47. Isin = table.Column<string>(type: "nvarchar(12)", maxLength: 12, nullable: false, comment: "종목코드 (ISIN, 스탬핑)"),
  48. AssetSeq = table.Column<int>(type: "int", nullable: false, comment: "자산일련번호 (ASSET_SEQ)"),
  49. XrcStdSeq = table.Column<int>(type: "int", nullable: false, comment: "행사기준일련번호 (XRC_STD_SEQ)"),
  50. XrcStdRatio = table.Column<decimal>(type: "decimal(8,3)", nullable: true, comment: "행사기준비율 % (XRC_STD_RATIO)"),
  51. XrcPrice = table.Column<decimal>(type: "decimal(28,10)", nullable: true, comment: "행사가격 (XRC_PRICE)"),
  52. UpdatedAt = table.Column<DateTime>(type: "datetime2", nullable: false)
  53. },
  54. constraints: table =>
  55. {
  56. table.PrimaryKey("PK_DerivAssetExercise", x => x.ID);
  57. },
  58. comment: "SEIBro 파생결합증권 기초자산 행사정보 (getAssetXrcInfo) — 행사기준비율·행사가격. AssetSeq 로 DerivAsset 연계");
  59. migrationBuilder.CreateTable(
  60. name: "DerivIssuance",
  61. columns: table => new
  62. {
  63. ID = table.Column<int>(type: "int", nullable: false)
  64. .Annotation("SqlServer:Identity", "1, 1"),
  65. Isin = table.Column<string>(type: "nvarchar(12)", maxLength: 12, nullable: false, comment: "종목코드 (ISIN)"),
  66. KorSecnNm = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: true, comment: "한글종목명 (KOR_SECN_NM)"),
  67. IssucoCustno = table.Column<int>(type: "int", nullable: true, comment: "발행회사고객번호 (ISSUCO_CUSTNO)"),
  68. SecnKacd = table.Column<string>(type: "nvarchar(4)", maxLength: 4, nullable: false, comment: "종목종류코드 (SECN_KACD, 스탬핑) — 4101ELS 4102ELB 4301DLS 4302DLB"),
  69. IssuDt = table.Column<DateOnly>(type: "date", nullable: false, comment: "발행일자 (ISSU_DT, 스탬핑)"),
  70. UpdatedAt = table.Column<DateTime>(type: "datetime2", nullable: false)
  71. },
  72. constraints: table =>
  73. {
  74. table.PrimaryKey("PK_DerivIssuance", x => x.ID);
  75. },
  76. comment: "SEIBro 파생결합증권 발행내역 (getDerivCombiIssuInfo) — ELS/ELB/DLS/DLB. DerivMaster rolling 발견 소스");
  77. migrationBuilder.CreateTable(
  78. name: "DerivMaster",
  79. columns: table => new
  80. {
  81. Isin = table.Column<string>(type: "nvarchar(12)", maxLength: 12, nullable: false, comment: "종목코드 (ISIN)"),
  82. KorSecnNm = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: true, comment: "한글종목명 (KOR_SECN_NM)"),
  83. IssucoCustno = table.Column<int>(type: "int", nullable: true, comment: "발행회사고객번호 (ISSUCO_CUSTNO)"),
  84. SecnKanm = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: true, comment: "종목구분명 (SECN_KANM) — ELS/ELB/ELW/DLS/DLB/ETN"),
  85. IssuCurCd = table.Column<string>(type: "nvarchar(3)", maxLength: 3, nullable: true, comment: "발행통화코드 (ISSU_CUR_CD)"),
  86. RecuWhcd = table.Column<string>(type: "nvarchar(2)", maxLength: 2, nullable: true, comment: "모집방법코드 (RECU_WHCD) — 11공모 21사모"),
  87. FirstIssuQty = table.Column<decimal>(type: "decimal(20,2)", nullable: true, comment: "최초발행수량 (FIRST_ISSU_QTY)"),
  88. IssuRemq = table.Column<decimal>(type: "decimal(20,2)", nullable: true, comment: "발행잔량 (ISSU_REMQ)"),
  89. PayinAmtRatio = table.Column<decimal>(type: "decimal(15,10)", nullable: true, comment: "납입금액비율 (PAYIN_AMT_RATIO)"),
  90. PayinAmt = table.Column<decimal>(type: "decimal(20,2)", nullable: true, comment: "납입금액 (PAYIN_AMT)"),
  91. IssuDt = table.Column<DateOnly>(type: "date", nullable: true, comment: "발행일자 (ISSU_DT)"),
  92. ContDt = table.Column<DateOnly>(type: "date", nullable: true, comment: "계약일자 (CONT_DT)"),
  93. XpirDt = table.Column<DateOnly>(type: "date", nullable: true, comment: "만기일자 (XPIR_DT)"),
  94. MidredPossYn = table.Column<bool>(type: "bit", nullable: true, comment: "중도상환가능여부 (MIDRED_POSS_YN)"),
  95. RedDt = table.Column<DateOnly>(type: "date", nullable: true, comment: "상환일자 (RED_DT)"),
  96. DerisecExerTpcd = table.Column<string>(type: "nvarchar(1)", maxLength: 1, nullable: true, comment: "파생증권권리행사구분코드 (DERISEC_EXER_TPCD) — 2만기 3조기"),
  97. PrcpPrsvTpcd = table.Column<string>(type: "nvarchar(1)", maxLength: 1, nullable: true, comment: "원금보전구분코드 (PRCP_PRSV_TPCD) — 1보장 2부분 3비보장"),
  98. PrcpPrsvRate = table.Column<decimal>(type: "decimal(8,3)", nullable: true, comment: "원금보전율 (PRCP_PRSV_RATE)"),
  99. ColatSetupTpcd = table.Column<string>(type: "nvarchar(1)", maxLength: 1, nullable: true, comment: "담보설정구분코드 (COLAT_SETUP_TPCD) — 1설정 2미설정"),
  100. BassetCnt = table.Column<int>(type: "int", nullable: true, comment: "기초자산 개수 (BASSET_CNT)"),
  101. MmPayYn = table.Column<bool>(type: "bit", nullable: true, comment: "월지급여부 (MM_PAY_YN)"),
  102. UpdatedAt = table.Column<DateTime>(type: "datetime2", nullable: false)
  103. },
  104. constraints: table =>
  105. {
  106. table.PrimaryKey("PK_DerivMaster", x => x.Isin);
  107. },
  108. comment: "SEIBro 파생결합증권 종목 정보 (getDerivCombiIsinInfo) — 원금보전·만기·발행잔량·기초자산수. ELS/DLS 상세 마스터");
  109. migrationBuilder.CreateTable(
  110. name: "DerivRedemption",
  111. columns: table => new
  112. {
  113. ID = table.Column<int>(type: "int", nullable: false)
  114. .Annotation("SqlServer:Identity", "1, 1"),
  115. Isin = table.Column<string>(type: "nvarchar(12)", maxLength: 12, nullable: false, comment: "종목코드 (ISIN)"),
  116. DerisecExerTpcd = table.Column<string>(type: "nvarchar(1)", maxLength: 1, nullable: false, comment: "파생증권권리행사구분코드 (DERISEC_EXER_TPCD) — 2만기 3조기"),
  117. RedQty = table.Column<decimal>(type: "decimal(20,2)", nullable: true, comment: "상환수량 (RED_QTY)"),
  118. RedDt = table.Column<DateOnly>(type: "date", nullable: false, comment: "상환일자 (RED_DT, 스탬핑)"),
  119. SecnKacd = table.Column<string>(type: "nvarchar(4)", maxLength: 4, nullable: false, comment: "종목종류코드 (SECN_KACD, 스탬핑) — 4101ELS 4102ELB 4301DLS 4302DLB"),
  120. UpdatedAt = table.Column<DateTime>(type: "datetime2", nullable: false)
  121. },
  122. constraints: table =>
  123. {
  124. table.PrimaryKey("PK_DerivRedemption", x => x.ID);
  125. },
  126. comment: "SEIBro 파생결합증권 상환종목 (getRedIsinInfo) — 상환일별 상환종목·수량. RedDt×종류 날짜 스윕");
  127. migrationBuilder.CreateTable(
  128. name: "DerivRedemptionCondition",
  129. columns: table => new
  130. {
  131. ID = table.Column<int>(type: "int", nullable: false)
  132. .Annotation("SqlServer:Identity", "1, 1"),
  133. Isin = table.Column<string>(type: "nvarchar(12)", maxLength: 12, nullable: false, comment: "종목코드 (ISIN, 스탬핑)"),
  134. RedCondiTpcd = table.Column<string>(type: "nvarchar(1)", maxLength: 1, nullable: false, comment: "상환조건구분코드 (RED_CONDI_TPCD) — 1중간평가 2만기"),
  135. ValatNtimesSeq = table.Column<int>(type: "int", nullable: false, comment: "평가횟수일련번호 (VALAT_NTIMES_SEQ)"),
  136. MidValatPayDt = table.Column<DateOnly>(type: "date", nullable: true, comment: "중간평가지급일자 (MID_VALAT_PAY_DT)"),
  137. MidValatBeginDt = table.Column<DateOnly>(type: "date", nullable: true, comment: "중간평가시작일자 (MID_VALAT_BEGIN_DT)"),
  138. MidValatExpryDt = table.Column<DateOnly>(type: "date", nullable: true, comment: "중간평가종료일자 (MID_VALAT_EXPRY_DT)"),
  139. RedCondiContent = table.Column<string>(type: "nvarchar(1000)", maxLength: 1000, nullable: true, comment: "상환조건내용 (RED_CONDI_CONTENT)"),
  140. RedFormulaContent = table.Column<string>(type: "nvarchar(1000)", maxLength: 1000, nullable: true, comment: "상환계산식내용 (RED_FORMULA_CONTENT)"),
  141. UpdatedAt = table.Column<DateTime>(type: "datetime2", nullable: false)
  142. },
  143. constraints: table =>
  144. {
  145. table.PrimaryKey("PK_DerivRedemptionCondition", x => x.ID);
  146. },
  147. comment: "SEIBro 파생결합증권 상환조건 (getRedCondiInfo) — 중간평가일·상환조건문·계산식(최대 1000자)");
  148. migrationBuilder.CreateTable(
  149. name: "ElsUnredeemedScale",
  150. columns: table => new
  151. {
  152. ID = table.Column<int>(type: "int", nullable: false)
  153. .Annotation("SqlServer:Identity", "1, 1"),
  154. StdDt = table.Column<DateOnly>(type: "date", nullable: false, comment: "기준일자 (STD_DT, 스탬핑)"),
  155. StndBassetCd = table.Column<string>(type: "nvarchar(12)", maxLength: 12, nullable: false, comment: "표준기초자산코드 (STND_BASSET_CD, 스탬핑) — 입력 13종 KSD02* 원문"),
  156. SecnTpcd = table.Column<string>(type: "nvarchar(2)", maxLength: 2, nullable: false, comment: "종목구분코드 (SECN_TPCD, 스탬핑) — 41ELS 43DLS"),
  157. BassetContent = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true, comment: "기초자산내용 (BASSET_CONTENT)"),
  158. UnredSecncnt = table.Column<int>(type: "int", nullable: true, comment: "미상환종목수 (UNRED_SECNCNT)"),
  159. UnredRema = table.Column<decimal>(type: "decimal(20,2)", nullable: true, comment: "미상환잔액 (UNRED_REMA) — 원화 환산 합계"),
  160. UpdatedAt = table.Column<DateTime>(type: "datetime2", nullable: false)
  161. },
  162. constraints: table =>
  163. {
  164. table.PrimaryKey("PK_ElsUnredeemedScale", x => x.ID);
  165. },
  166. comment: "SEIBro 기초자산별 미상환규모 (getBassetUnredScale) — ELS 지수 하락 리스크 지표. 일별 13기초자산×{41,43}");
  167. migrationBuilder.CreateIndex(
  168. name: "IX_DerivAsset_Isin_AssetSeq",
  169. table: "DerivAsset",
  170. columns: new[] { "Isin", "AssetSeq" },
  171. unique: true);
  172. migrationBuilder.CreateIndex(
  173. name: "IX_DerivAsset_StndBassetCd",
  174. table: "DerivAsset",
  175. column: "StndBassetCd");
  176. migrationBuilder.CreateIndex(
  177. name: "IX_DerivAssetExercise_Isin_AssetSeq_XrcStdSeq",
  178. table: "DerivAssetExercise",
  179. columns: new[] { "Isin", "AssetSeq", "XrcStdSeq" },
  180. unique: true);
  181. migrationBuilder.CreateIndex(
  182. name: "IX_DerivIssuance_Isin",
  183. table: "DerivIssuance",
  184. column: "Isin",
  185. unique: true);
  186. migrationBuilder.CreateIndex(
  187. name: "IX_DerivIssuance_IssuDt",
  188. table: "DerivIssuance",
  189. column: "IssuDt");
  190. migrationBuilder.CreateIndex(
  191. name: "IX_DerivIssuance_SecnKacd",
  192. table: "DerivIssuance",
  193. column: "SecnKacd");
  194. migrationBuilder.CreateIndex(
  195. name: "IX_DerivMaster_IssucoCustno",
  196. table: "DerivMaster",
  197. column: "IssucoCustno");
  198. migrationBuilder.CreateIndex(
  199. name: "IX_DerivMaster_XpirDt",
  200. table: "DerivMaster",
  201. column: "XpirDt");
  202. migrationBuilder.CreateIndex(
  203. name: "IX_DerivRedemption_Isin_RedDt_DerisecExerTpcd",
  204. table: "DerivRedemption",
  205. columns: new[] { "Isin", "RedDt", "DerisecExerTpcd" },
  206. unique: true);
  207. migrationBuilder.CreateIndex(
  208. name: "IX_DerivRedemption_RedDt",
  209. table: "DerivRedemption",
  210. column: "RedDt");
  211. migrationBuilder.CreateIndex(
  212. name: "IX_DerivRedemptionCondition_Isin_RedCondiTpcd_ValatNtimesSeq",
  213. table: "DerivRedemptionCondition",
  214. columns: new[] { "Isin", "RedCondiTpcd", "ValatNtimesSeq" },
  215. unique: true);
  216. migrationBuilder.CreateIndex(
  217. name: "IX_ElsUnredeemedScale_StdDt_StndBassetCd_SecnTpcd",
  218. table: "ElsUnredeemedScale",
  219. columns: new[] { "StdDt", "StndBassetCd", "SecnTpcd" },
  220. unique: true);
  221. migrationBuilder.CreateIndex(
  222. name: "IX_ElsUnredeemedScale_StndBassetCd_StdDt",
  223. table: "ElsUnredeemedScale",
  224. columns: new[] { "StndBassetCd", "StdDt" });
  225. }
  226. /// <inheritdoc />
  227. protected override void Down(MigrationBuilder migrationBuilder)
  228. {
  229. migrationBuilder.DropTable(
  230. name: "DerivAsset");
  231. migrationBuilder.DropTable(
  232. name: "DerivAssetExercise");
  233. migrationBuilder.DropTable(
  234. name: "DerivIssuance");
  235. migrationBuilder.DropTable(
  236. name: "DerivMaster");
  237. migrationBuilder.DropTable(
  238. name: "DerivRedemption");
  239. migrationBuilder.DropTable(
  240. name: "DerivRedemptionCondition");
  241. migrationBuilder.DropTable(
  242. name: "ElsUnredeemedScale");
  243. }
  244. }
  245. }