Exemplo n.º 1
0
        // #CreateInstrument_ItemAdd
        public static Financial_instrument CreateInstrument(clsMAST_FP_INSTRUMENT_TB tb)
        {
            int type = tb.FP_MASTER_TYP;

            Financial_instrument fi = new Unknown_fi_instrument();

            if (type == (int)clsMAST_FP_INSTRUMENT_TB.FP_MASTER_TYP_Type.Kospi200_IndexFutures)
            {
                fi = new Kospi200Index_futures();
            }
            else if (type == (int)clsMAST_FP_INSTRUMENT_TB.FP_MASTER_TYP_Type.Kospi200_IndexOption_Call 
                || type == (int)clsMAST_FP_INSTRUMENT_TB.FP_MASTER_TYP_Type.Kospi200_IndexOption_Put)
            {
                fi = new Kospi200Index_option();
            }
            else if (type == (int)clsMAST_FP_INSTRUMENT_TB.FP_MASTER_TYP_Type.VanillaIRS)
            {
                fi = new VanillaIRS_instrument();
            }
            else if (type == (int)clsMAST_FP_INSTRUMENT_TB.FP_MASTER_TYP_Type.VanillaSwap)
            {
                fi = new Vanilla_Swap();
            }
            else if (type == (int)clsMAST_FP_INSTRUMENT_TB.FP_MASTER_TYP_Type.Ftp_DepositLoan)
            {
                fi = new Ftp_DepositLoan();
            }
            else if (type == (int)clsMAST_FP_INSTRUMENT_TB.FP_MASTER_TYP_Type.Money_Cash)
            {
                fi = new CurrencyCash();
            }

            else
            {
                //fi = new Unknown_instrument();
            }

            fi.baseDAO_ = tb;
            fi.loadDetail(tb.INSTRUMENT_ID);

            return fi;
        }
Exemplo n.º 2
0
        public static Vanilla_Swap CreateTradableCode(string availableTradeCD,
                                                        bool fixedPayFlag,
                                                        long notional,
                                                        DateTime effective,
                                                        double fixedRate)
        {
            clsTRADABLE_OTC_VANILLA_IRS_TB clstb = new clsTRADABLE_OTC_VANILLA_IRS_TB();

            clstb.INST_CD = availableTradeCD;
            int checkNum = clstb.SelectOwn();

            if (checkNum == 0) { throw new Exception(availableTradeCD + " : is not tradable."); }

            int maturityYear = ConvertingTool.TenorMuliplier(clstb.MATURITY_TENOR);
            int legTenorMonth = ConvertingTool.TenorMuliplier(clstb.LEG_TENOR);

            Vanilla_Swap inst = new Vanilla_Swap();

            int cashflowCount = maturityYear * (12 / legTenorMonth);

            // Master
            string inst_ID = IDGenerator.getNewInstrumentID(inst.InstrumentType_, effective, inst);

            inst.baseDAO_.INSTRUMENT_ID = inst_ID;
            inst.baseDAO_.INSTRUMENT_NM = (fixedPayFlag) ? fixedRate + " Pay " + clstb.MATURITY_TENOR : fixedRate + " Receive " + clstb.MATURITY_TENOR;
            inst.baseDAO_.FP_MASTER_TYP = (int)clsMAST_FP_INSTRUMENT_TB.FP_MASTER_TYP_Type.VanillaSwap;
            inst.baseDAO_.NOTIONAL = notional;
            inst.baseDAO_.PRICE = fixedRate;
            inst.baseDAO_.QUANTITY = 1.0;
            inst.baseDAO_.CURR = "KRW";
            inst.baseDAO_.FX_RATE = 1.0;
            inst.baseDAO_.EFFECTIVE_DT = effective.ToString("yyyyMMdd");
            inst.baseDAO_.MATURITY_DT = effective.AddYears(maturityYear).ToString("yyyyMMdd");
            inst.baseDAO_.BOOKED_DT = "";
            inst.baseDAO_.CLOSED_DT = "20991231";

            // swap part

            inst.SwapDAO_.INSTRUMENT_ID = inst_ID;
            inst.SwapDAO_.INSTRUMENT_TYP = inst.baseDAO_.FP_MASTER_TYP;

            inst.SwapDAO_.NOTIONAL = notional;
            inst.SwapDAO_.CURR = "KRW";
            inst.SwapDAO_.EFFECTIVE_DT = effective.ToString("yyyyMMdd");
            inst.SwapDAO_.MATURITY_DT = effective.AddYears(maturityYear).ToString("yyyyMMdd");
            inst.SwapDAO_.COUPON_TENOR = "3M";
            inst.SwapDAO_.MATURITY_TENOR = maturityYear.ToString() + "Y";
            inst.SwapDAO_.PAY_REC = (fixedPayFlag) ? (int)clsMAST_VANILLA_SWAP_INFO_TB.PAY_REC_Type.Pay :
                                                     (int)clsMAST_VANILLA_SWAP_INFO_TB.PAY_REC_Type.Rec;
            inst.SwapDAO_.FLOATING_LEG_BDC = 0;
            inst.SwapDAO_.FLOATING_LEG_DC = 0;
            inst.SwapDAO_.FIXED_LEG_BDC = 0;
            inst.SwapDAO_.FIXED_LEG_DC = 0;

            //CalendarManager cm = new CalendarManager(effective, CalendarManager.CountryType.SOUTH_KOREA);

            // CF_FixedDAO_

            inst.FixedLegInfo_.LegDAO_.INSTRUMENT_ID = inst_ID;
            inst.FixedLegInfo_.LegDAO_.LEG_TYP = 0;
            inst.FixedLegInfo_.LegDAO_.NOTIONAL = notional;
            inst.FixedLegInfo_.LegDAO_.CURR = "KRW";
            inst.FixedLegInfo_.LegDAO_.EFFECTIVE_DT = effective.ToString("yyyyMMdd");
            inst.FixedLegInfo_.LegDAO_.MATURITY_DT = effective.AddYears(maturityYear).ToString("yyyyMMdd");
            inst.FixedLegInfo_.LegDAO_.LEG_TENOR = "3M";
            inst.FixedLegInfo_.LegDAO_.FIXED_RATE = fixedRate;

            inst.FixedLegInfo_.buildFromLegInfo(effective, inst.SwapDAO_.PAY_REC);

            #region Comment

            //--------------------------------- leg info 를 만들어야함.

            //for (int i = 0; i < cashflowCount; i++)
            //{
            //    FP_FixedRateCoupon fp_cashFlow = new FP_FixedRateCoupon();

            //    fp_cashFlow.DAO_ = new clsMAST_CF_FIXED_TB();

            //    fp_cashFlow.DAO_.CASHFLOW_DT = effective.AddMonths(3 * (i + 1)).ToString("yyyyMMdd");
            //    fp_cashFlow.DAO_.LEG_ID = inst_ID;
            //    fp_cashFlow.DAO_.LEG_TYP = 0;
            //    fp_cashFlow.DAO_.NOTIONAL = Math.Abs(notional);
            //    fp_cashFlow.DAO_.CALC_START_DT = effective.AddMonths(3 * i).ToString("yyyyMMdd"); ;
            //    fp_cashFlow.DAO_.CALC_END_DT = effective.AddMonths(3 * (i + 1)).ToString("yyyyMMdd");
            //    fp_cashFlow.DAO_.PAYMENT_DT = cm.adjust(effective.AddMonths(3 * (i + 1))).ToString("yyyyMMdd");
            //    fp_cashFlow.DAO_.FIXED_RATE = fixedRate;

            //    inst.FixedLegInfo_.FP_CashFlowList_.Add(fp_cashFlow);
            //}

            #endregion

            inst.FloatingLegInfo_.LegDAO_.INSTRUMENT_ID = inst_ID;
            inst.FloatingLegInfo_.LegDAO_.LEG_TYP = 0;
            inst.FloatingLegInfo_.LegDAO_.NOTIONAL = notional;
            inst.FloatingLegInfo_.LegDAO_.CURR = "KRW";
            inst.FloatingLegInfo_.LegDAO_.EFFECTIVE_DT = effective.ToString("yyyyMMdd");
            inst.FloatingLegInfo_.LegDAO_.MATURITY_DT = effective.AddYears(maturityYear).ToString("yyyyMMdd");
            inst.FloatingLegInfo_.LegDAO_.LEG_TENOR = "3M";
            inst.FloatingLegInfo_.LegDAO_.FIXING_INDEX_CD = clstb.FLOATING_INDEX_CD;
            inst.FloatingLegInfo_.LegDAO_.GREARING = 1.0;
            inst.FloatingLegInfo_.LegDAO_.SPREAD = 0.0;
            inst.FloatingLegInfo_.LegDAO_.CAP = 10.0;
            inst.FloatingLegInfo_.LegDAO_.FLOOR = -10.0;
            inst.FloatingLegInfo_.LegDAO_.INARREAR = 0;

            inst.FloatingLegInfo_.buildFromLegInfo(effective, inst.SwapDAO_.PAY_REC*(-1));

            #region Comment

            //for (int i = 0; i < cashflowCount; i++)
            //{
            //    FP_FloatingRateCoupon fp_floating_cashFlow = new FP_FloatingRateCoupon();

            //    fp_floating_cashFlow.DAO_ = new clsMAST_CF_VANILLA_FLOATING_TB();

            //    fp_floating_cashFlow.DAO_.CASHFLOW_DT = effective.AddMonths(3 * (i + 1)).ToString("yyyyMMdd");
            //    fp_floating_cashFlow.DAO_.LEG_ID = inst_ID;
            //    fp_floating_cashFlow.DAO_.LEG_TYP = 0;
            //    fp_floating_cashFlow.DAO_.NOTIONAL = Math.Abs(notional);
            //    fp_floating_cashFlow.DAO_.CALC_START_DT = effective.AddMonths(3 * i).ToString("yyyyMMdd");
            //    fp_floating_cashFlow.DAO_.CALC_END_DT = effective.AddMonths(3 * (i + 1)).ToString("yyyyMMdd");
            //    fp_floating_cashFlow.DAO_.PAYMENT_DT = cm.adjust(effective.AddMonths(3 * (i + 1))).ToString("yyyyMMdd");

            //    fp_floating_cashFlow.DAO_.FIXING_DT = cm.adjust(effective.AddMonths(3 * i)).ToString("yyyyMMdd");

            //    // 우선 DEFAULT로 박고, FIXING은 차후 데일리로 계산함.

            //    fp_floating_cashFlow.DAO_.FIXING_INDEX_CD = clstb.FLOATING_INDEX_CD;
            //    fp_floating_cashFlow.DAO_.GREARING = 1.0;
            //    fp_floating_cashFlow.DAO_.SPREAD = 0.0;
            //    fp_floating_cashFlow.DAO_.FIXED_FIXING = 0.0;
            //    fp_floating_cashFlow.DAO_.FIXED_FIXING_CALCLATED
            //        = (int)clsMAST_CF_VANILLA_FLOATING_TB.FIXED_FIXING_CALCLATED_Type.NOT_FIXED;

            //    inst.FloatingLegInfo_.FP_CashFlowList_.Add(fp_floating_cashFlow);

            //}

            #endregion

            return inst;
        }