makeVanillaIRS_tradeInfo(DateTime tradeDate, string avavailableTradeCD, bool fixedPayFlag, int quantity, double tradeIndex, double spread) { VanillaIRSTradeInfo ifti = new VanillaIRSTradeInfo(); clsTRADABLE_OTC_VANILLA_IRS_TB clstb = new clsTRADABLE_OTC_VANILLA_IRS_TB(); clstb.INST_CD = avavailableTradeCD; clstb.SelectOwn(); int maturityYear = ConvertingTool.TenorMuliplier(clstb.MATURITY_TENOR); double notioal = Math.Abs(quantity * 10000000000); //VanillaIRS_instrument irs = VanillaIRS_instrument.CreateFixedFloating(fixedPayFlag, // notioal, // tradeDate, // maturityYear, // tradeIndex, // true); VanillaIRS_instrument irs = VanillaIRS_instrument.CreateTradableCode(avavailableTradeCD, fixedPayFlag, notioal, quantity,tradeDate, tradeIndex,spread); ifti.Financial_instrument_ = irs; double indexMultiplier = VanillaIRSTradeInfo.IndexMultiplier_; double tradeFeeRate = VanillaIRSTradeInfo.TradeFeeRate_; ifti.DAO_ = new DatabaseLayer.clsHITM_TRADEINFO_TB(); ifti.DAO_.TRADE_ID = IDGenerator.getNewTradeID(TradeInfo.TradeType.OTC,irs.InstrumentType_, tradeDate); ifti.DAO_.INSTRUMENT_ID = irs.SwapDAO_.INSTRUMENT_ID; ifti.DAO_.TRADE_DT = tradeDate.ToString("yyyyMMdd"); ifti.DAO_.TRADE_TM = DateTime.Now.ToString("HHmmss"); ifti.DAO_.TRADE_SEQ = IDGenerator.getTradeSeq(tradeDate); ifti.DAO_.TRADE_TYP = Convert.ToInt32(TradeInfo.TradeType.OTC); ifti.DAO_.FP_MASTER_TYP = irs.baseDAO_.FP_MASTER_TYP; ifti.DAO_.TRADE_UNIT = 10000000000; ifti.DAO_.TRADE_MULTIPLIER = indexMultiplier; ifti.DAO_.TRADE_CURR = "KRW"; ifti.DAO_.CURR_RATE = 1.0; ifti.DAO_.TRADE_INDEX = tradeIndex; ifti.DAO_.TRADE_INDEXUNIT = 1.0; ifti.DAO_.TRADE_QNT = quantity; ifti.DAO_.TRADE_NOTIONAL_AMT = Math.Round(Math.Abs(Convert.ToDouble(quantity * ifti.DAO_.TRADE_UNIT))); ifti.DAO_.ACCOUNT_AMT = 0.0; ifti.DAO_.TRADE_FEE = Math.Round(Math.Abs(ifti.DAO_.TRADE_NOTIONAL_AMT * tradeFeeRate)); ifti.DAO_.TRADE_PL = 0.0; ifti.DAO_.TRADE_FEE_PAYMENT_DT = tradeDate.ToString("yyyyMMdd"); ifti.DAO_.COUNTER_ID = "OTC"; ifti.DAO_.BOOKED_FLAG = 0; return ifti; }
public static Vanilla_SwapTradeInfo makeVanilla_Swap_tradeInfo(DateTime tradeDate, string avavailableTradeCD, long notional, bool fixedPayFlag, double tradeIndex) { Vanilla_SwapTradeInfo v_sti = new Vanilla_SwapTradeInfo(); clsTRADABLE_OTC_VANILLA_IRS_TB clstb = new clsTRADABLE_OTC_VANILLA_IRS_TB(); clstb.INST_CD = avavailableTradeCD; clstb.SelectOwn(); int maturityYear = ConvertingTool.TenorMuliplier(clstb.MATURITY_TENOR); Vanilla_Swap vanilla_swap = Vanilla_Swap.CreateTradableCode(avavailableTradeCD, fixedPayFlag, notional, tradeDate, tradeIndex); v_sti.Financial_instrument_ = vanilla_swap; double indexMultiplier = Vanilla_SwapTradeInfo.IndexMultiplier_; double tradeFeeRate = Vanilla_SwapTradeInfo.TradeFeeRate_; v_sti.DAO_ = new DatabaseLayer.clsHITM_TRADEINFO_TB(); v_sti.DAO_.TRADE_ID = IDGenerator.getNewTradeID(TradeInfo.TradeType.OTC, vanilla_swap.InstrumentType_, tradeDate); v_sti.DAO_.INSTRUMENT_ID = vanilla_swap.SwapDAO_.INSTRUMENT_ID; v_sti.DAO_.TRADE_DT = tradeDate.ToString("yyyyMMdd"); v_sti.DAO_.TRADE_TM = DateTime.Now.ToString("HHmmss"); v_sti.DAO_.TRADE_SEQ = IDGenerator.getTradeSeq(tradeDate); v_sti.DAO_.TRADE_TYP = Convert.ToInt32(TradeInfo.TradeType.OTC); v_sti.DAO_.FP_MASTER_TYP = vanilla_swap.baseDAO_.FP_MASTER_TYP; v_sti.DAO_.TRADE_UNIT = 1; v_sti.DAO_.TRADE_MULTIPLIER = indexMultiplier; v_sti.DAO_.TRADE_CURR = "KRW"; v_sti.DAO_.CURR_RATE = 1.0; v_sti.DAO_.TRADE_INDEX = tradeIndex; v_sti.DAO_.TRADE_INDEXUNIT = 1.0; v_sti.DAO_.TRADE_QNT = notional; v_sti.DAO_.TRADE_NOTIONAL_AMT = notional; v_sti.DAO_.ACCOUNT_AMT = 0.0; v_sti.DAO_.TRADE_FEE = Math.Round(Math.Abs(v_sti.DAO_.TRADE_NOTIONAL_AMT * tradeFeeRate)); v_sti.DAO_.TRADE_PL = 0.0; v_sti.DAO_.TRADE_FEE_PAYMENT_DT = tradeDate.ToString("yyyyMMdd"); v_sti.DAO_.COUNTER_ID = "OTC"; v_sti.DAO_.BOOKED_FLAG = 0; return v_sti; }
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; }
public static VanillaIRS_instrument CreateTradableCode(string availableTradeCD, bool fixedPayFlag, double notional, int quantity, DateTime effective, double fixedRate, double spread) { 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); VanillaIRS_instrument inst = new VanillaIRS_instrument(); 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.VanillaIRS; inst.baseDAO_.NOTIONAL = Math.Abs(notional); inst.baseDAO_.PRICE = fixedRate; inst.baseDAO_.QUANTITY = Math.Abs(quantity); inst.baseDAO_.CURR = "KRW"; inst.baseDAO_.FX_RATE = 1.0; //inst.baseDAO_.BUY_SELL = (quantity > 0) ? (int)clsMAST_FP_INSTRUMENT_TB.BUY_SELL_Type.Buy : // (int)clsMAST_FP_INSTRUMENT_TB.BUY_SELL_Type.Sell; 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"; inst.SwapDAO_.INSTRUMENT_ID = inst_ID; inst.SwapDAO_.INSTRUMENT_TYP = Convert.ToInt32(inst.InstrumentType_); inst.SwapDAO_.NOTIONAL_PAY = Math.Abs(notional); inst.SwapDAO_.PAY_CURR = "KRW"; inst.SwapDAO_.NOTIONAL_REC = Math.Abs(notional); inst.SwapDAO_.REC_CURR = "KRW"; inst.SwapDAO_.EFFECTIVE_DT = effective.ToString("yyyyMMdd"); inst.SwapDAO_.MATURITY_DT = effective.AddYears(maturityYear).ToString("yyyyMMdd"); inst.SwapDAO_.PAY_LEG_TYP = 0; inst.SwapDAO_.PAY_LEG_TENOR = "3M"; inst.SwapDAO_.PAY_LEG_BDC = 0; inst.SwapDAO_.PAY_LEG_DC = 0; inst.SwapDAO_.REC_LEG_TYP = 1; inst.SwapDAO_.REC_LEG_TENOR = "3M"; inst.SwapDAO_.REC_LEG_BDC = 1; inst.SwapDAO_.REC_LEG_DC = 1; CalendarManager cm = new CalendarManager(effective, CalendarManager.CountryType.SOUTH_KOREA); // CF_FixedDAO_ 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; if (fixedPayFlag) { inst.FP_PayCashFlowList_.Add(fp_cashFlow); } else { inst.FP_RecCashFlowList_.Add(fp_cashFlow); } } 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 = spread; 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; if (fixedPayFlag) { inst.FP_RecCashFlowList_.Add(fp_floating_cashFlow); } else { inst.FP_PayCashFlowList_.Add(fp_floating_cashFlow); } } return inst; }