Ejemplo n.º 1
0
        // code parsing or 어쩌구.
        public static Kospi200Index_option CreateKOSPI200_Option(DateTime tradeDate,
                                                            string krxCode,
                                                            int quantity,
                                                            double tradeIndex)
        {
            // 장내 이므로 불러옴.
            clsTRADABLE_KRX_INDEXOPTION_TB clstb = new clsTRADABLE_KRX_INDEXOPTION_TB();

            clstb.INST_KRX_CD = krxCode;
            clstb.SelectOwn();

            Kospi200Index_option inst = new Kospi200Index_option();

            string inst_ID = IDGenerator.getNewInstrumentID(inst.InstrumentType_, tradeDate, inst);

            inst.baseDAO_.INSTRUMENT_ID = inst_ID;
            inst.baseDAO_.INSTRUMENT_NM = clstb.INST_NM;
            //inst.baseDAO_.FP_MASTER_TYP = Convert.ToInt32(inst.InstrumentType_); // 아직 구분 못했음. 우선 그냥 instType으로 넣음.

            inst.baseDAO_.FP_MASTER_TYP = IDGenerator.KRXCodetoFP_MASTER_TYP(krxCode);
            inst.baseDAO_.NOTIONAL = clstb.INDEX_MULTIPLIER;
            inst.baseDAO_.PRICE = tradeIndex;
            inst.baseDAO_.QUANTITY = quantity;
            inst.baseDAO_.CURR = "KRW";
            inst.baseDAO_.FX_RATE = 1.0;

            //inst.baseDAO_.NOTIONAL = Math.Abs(quantity * clstb.STRIKE * clstb.INDEX_MULTIPLIER);
            //inst.baseDAO_.CURR = "KRW";

            //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_.QUANTITY = Math.Abs(quantity);

            inst.baseDAO_.EFFECTIVE_DT = tradeDate.ToString("yyyyMMdd");
            inst.baseDAO_.MATURITY_DT = clstb.MATURITY_DT;
            inst.baseDAO_.BOOKED_DT = tradeDate.ToString("yyyyMMdd");
            inst.baseDAO_.CLOSED_DT = "20991231";

            clsTRADABLE_KRX_INDEXOPTION_TB clstb_tradable = new clsTRADABLE_KRX_INDEXOPTION_TB();
            clstb_tradable.INST_KRX_CD = krxCode;
            clstb_tradable.SelectOwn();

            inst.indexOptionDAO_.INSTRUMENT_ID = inst_ID;
            inst.indexOptionDAO_.INSTRUMENT_TYP = Convert.ToInt32(inst.InstrumentType_); // 내부 타입인데..
            
            inst.indexOptionDAO_.NOTIONAL = Math.Abs(quantity * clstb.STRIKE * clstb.INDEX_MULTIPLIER);
            inst.indexOptionDAO_.QUANTITY = quantity;
            inst.indexOptionDAO_.INDEX_MULTIPLIER = clstb_tradable.INDEX_MULTIPLIER;
            inst.indexOptionDAO_.UNDERLYING_INDEX_CD = clstb.UNDERLYING_CD;
            inst.indexOptionDAO_.OPTION_TYP = 0;
            inst.indexOptionDAO_.STRIKE = clstb_tradable.STRIKE;
            inst.indexOptionDAO_.CURR = "KRW";
            inst.indexOptionDAO_.EFFECTIVE_DT = tradeDate.ToString("yyyyMMdd");
            inst.indexOptionDAO_.MATURITY_DT = clstb.MATURITY_DT;

            return inst;


        }
Ejemplo n.º 2
0
        public static void inserKRX_kospi200Option(string inst_name,string krx_krCode)
        { 
            // kr 코드 파싱함.

            clsTRADABLE_KRX_INDEXOPTION_TB clstb = new clsTRADABLE_KRX_INDEXOPTION_TB();

            clstb.INST_KRX_CD = krx_krCode;

            if ( clstb.SelectOwn() == 0 )
            { 
            
                clstb.INST_NM = inst_name;
                clstb.INST_BROKER_CD = "";

                // 둘째 주 목요일 구하는 거.
                int year = Convert.ToInt32(inst_name.Substring(9, 4));
                int month = Convert.ToInt32(inst_name.Substring(13, 2));

                DateTime maturity = CalendarManager.monthlyOptionMaturiry(year, month, DayOfWeek.Thursday, 2);

                clstb.MATURITY_DT = maturity.ToString("yyyyMMdd");

                clstb.UNDERLYING_CD = "KOSPI200";

                int type = Convert.ToInt32(krx_krCode.Substring(2, 3));

                clstb.OPTION_TYP = type;

                double strike = Convert.ToDouble(inst_name.Substring(inst_name.Length - 5, 5));

                clstb.STRIKE = strike;

                clstb.INDEX_MULTIPLIER = 500000;
                clstb.BROKER_CD = "";

                clstb.Insert();
            }
            // 
        }
Ejemplo n.º 3
0
        public static Kospi200OptionTradeInfo makeKospi200f_tradeInfo(DateTime tradeDate,
                                                               string availableTradeCD,
                                                               int quantity,
                                                               double tradeIndex)
        {
            Kospi200OptionTradeInfo ifti = new Kospi200OptionTradeInfo();

            Kospi200Index_option index_option = Kospi200Index_option.CreateKOSPI200_Option(tradeDate,
                                                                                availableTradeCD,
                                                                                quantity,
                                                                                tradeIndex);

            index_option.Index_ = tradeIndex;

            ifti.Financial_instrument_ = index_option;
            
            // index multiplier
            clsTRADABLE_KRX_INDEXOPTION_TB clstb = new clsTRADABLE_KRX_INDEXOPTION_TB();
            clstb.INST_KRX_CD = availableTradeCD;
            clstb.SelectOwn();

            double indexMultiplier = clstb.INDEX_MULTIPLIER;

            // trade fee

            //clsITEM_FP_TRADE_FEE_TB clstb_tradeFee = new clsITEM_FP_TRADE_FEE_TB();
            //clstb_tradeFee.TRADE_CD = availableTradeCD;
            //clstb_tradeFee.SelectOwn();

            //double tradeFeeRate = clstb_tradeFee.TRADE_FEE;

            double tradeFeeRate = 0.0015; // 키움꺼임.
            
            double strike = index_option.indexOptionDAO_.STRIKE;

            ifti.DAO_ = new clsHITM_TRADEINFO_TB();

            ifti.DAO_.TRADE_ID = IDGenerator.getNewTradeID(TradeInfo.TradeType.Dynamic_Hedge, 
                                                            index_option.InstrumentType_, 
                                                            tradeDate);

            ifti.DAO_.INSTRUMENT_ID = index_option.indexOptionDAO_.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.Dynamic_Hedge);
            ifti.DAO_.FP_MASTER_TYP = index_option.baseDAO_.FP_MASTER_TYP;
            ifti.DAO_.TRADE_UNIT = Convert.ToInt32(tradeIndex * indexMultiplier);
            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 * strike * indexMultiplier)));
            //ifti.DAO_.ACCOUNT_AMT = tradeIndex * quantity * indexMultiplier;
            ifti.DAO_.ACCOUNT_AMT = 0.0;
            ifti.DAO_.TRADE_FEE = Math.Round(Math.Abs(ifti.DAO_.ACCOUNT_AMT * tradeFeeRate));
            ifti.DAO_.TRADE_PL = 0.0;
            ifti.DAO_.TRADE_FEE_PAYMENT_DT = tradeDate.ToString("yyyyMMdd");
            ifti.DAO_.COUNTER_ID = "KRX";
            ifti.DAO_.BOOKED_FLAG = 0;

            return ifti;

        }