Exemple #1
0
        private void evalCurveMap()
        {
            // eval ---------------------------------------------------------
            
            //this.EvalCurveMap_.Clear();
            this.EvalCurveManagerMap_.Clear();

            clsSET_EVALUATIONCURVE_TB clstb = new clsSET_EVALUATIONCURVE_TB();

            clstb.SETTING_ID = "MYSETTING";

            DataTable tb = clstb.Select();

            foreach (DataRow dr in tb.Select())
            {
                YieldCurve cm = new YieldCurve();

                clsSET_EVALUATIONCURVE_TB clstb_roop = clsSET_EVALUATIONCURVE_TB.Create(dr);

                cm.loadCurveData(this.CalcDate_, clstb_roop.CURVE_ID, clsHDAT_CURVEDATA_TB.RATE_TYP_Type.YTM);

                //this.EvalCurveMap_.Add(clstb_roop.INDEX_CD, cm.yieldCurve(this.CurveShift_));
                this.EvalCurveManagerMap_.Add(clstb_roop.INDEX_CD, cm);
                //this.EvalCurveMap_.Add(clstb_roop.INDEX_CD, cm);
            }

        }
Exemple #2
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Window w = new Window();
            YieldCurveLoader curveLoader = new YieldCurveLoader();
            w.Content = curveLoader;

            w.Width = 500;
            w.Height = 500;
            w.KeyUp += w_KeyUp;

            if ( w.ShowDialog() == true )
            {
                this.YieldCurve_ = curveLoader.YieldCurve_;
                this.Content = curveLoader.YieldCurve_.DAO_.CURVE_CD;
            }

        }
Exemple #3
0
        public void addEvalCurve(string index_cd) 
        {
            QLNet.YieldTermStructure ql_curve = new QLNet.YieldTermStructure();
            YieldCurve cm = new YieldCurve();

            clsSET_EVALUATIONCURVE_TB clstb = new clsSET_EVALUATIONCURVE_TB();

            clstb.INDEX_CD = index_cd;

            clstb.SelectOwn();

            string curve_cd = clstb.CURVE_ID;

            // ql _ yield curve build

            //this.EvalCurveMap_.Add(index_cd, ql_curve);
            this.EvalCurveManagerMap_.Add(index_cd, cm);

        }
Exemple #4
0
        // static

        public static YieldCurve GetYieldCurve_DB(DateTime refereceDate, string curveID, clsHDAT_CURVEDATA_TB.RATE_TYP_Type type)
        {
            YieldCurve yc = new YieldCurve();

            yc.loadCurveData(refereceDate,curveID,type);

            return yc;
        }
Exemple #5
0
        public override void calculate(DateTime calcDate, FP_Parameter fp_parameter)
        {
            // master data load

            this.indexOptionDAO_.SelectOwn();

            // market data load
            
            // index data
            clsHDAT_MARKETDATA_TB clstb = new clsHDAT_MARKETDATA_TB();

            string calcDateStr = calcDate.ToString("yyyyMMdd");
            QLNet.Settings.setEvaluationDate(calcDate);

            clstb.REF_DT = calcDateStr;
            clstb.INDEX_CD = this.indexOptionDAO_.UNDERLYING_INDEX_CD;

            int checkNum = clstb.SelectOwn();

            if (checkNum == 0) { throw new Exception("market data does not exist : " + calcDateStr + " " + clstb.INDEX_CD); }

            double indexData = clstb.LAST;

            // curveData --------------------------------------------------

            string curve_cd = "IRSKRW";
            
            YieldCurve curveManager = new YieldCurve();

            curveManager.loadCurveData(calcDate,curve_cd,clsHDAT_CURVEDATA_TB.RATE_TYP_Type.YTM);
            QLNet.YieldTermStructure yield_ts = curveManager.yieldCurve();

            // calculate

            string maturityDateStr = this.indexOptionDAO_.MATURITY_DT;

            System.Globalization.CultureInfo us
                = new System.Globalization.CultureInfo("en-US");

            DateTime maturityDate = DateTime.ParseExact(maturityDateStr, "yyyyMMdd", us);

            DayCounter dc = new Actual365Fixed();
            Calendar cal = new NullCalendar();

            double vol = 0.3;

            double strike = this.indexOptionDAO_.STRIKE;
            PlainVanillaPayoff strikePayoff = new PlainVanillaPayoff(Option.Type.
                Call, strike);

            Exercise exercise = new EuropeanExercise(maturityDate);

            VanillaOption q_option = new VanillaOption(strikePayoff,exercise);

            Handle<Quote> x0 = new Handle<Quote>(new SimpleQuote(indexData));
            FlatForward flatForward = new FlatForward(calcDate,0.01,dc);
            Handle<YieldTermStructure> dividendTS = new Handle<YieldTermStructure>(flatForward);
            Handle<YieldTermStructure> riskFreeTS = new Handle<YieldTermStructure>(yield_ts);
            BlackConstantVol blackConstVol = new BlackConstantVol(calcDate,cal,vol,dc);
            Handle<BlackVolTermStructure> blackVolTS = new Handle<BlackVolTermStructure>(blackConstVol);

            GeneralizedBlackScholesProcess process =new GeneralizedBlackScholesProcess(x0 ,dividendTS,riskFreeTS,blackVolTS);
            
            AnalyticEuropeanEngine europeanEngine = new AnalyticEuropeanEngine(process);

            q_option.setPricingEngine(europeanEngine);

            double value = q_option.NPV(); 
            double indexMultiplier = this.indexOptionDAO_.INDEX_MULTIPLIER;
            int quantity = this.indexOptionDAO_.QUANTITY;

            clsHITM_FP_GREEKRESULT_TB result_tb = new clsHITM_FP_GREEKRESULT_TB();

            result_tb.FP_GREEKRESULT_ID = IDGenerator.getNewGreekResultID(this.indexOptionDAO_.INSTRUMENT_ID,calcDateStr);
            result_tb.CALC_DT = calcDateStr;
            result_tb.INSTRUMENT_ID = this.indexOptionDAO_.INSTRUMENT_ID;
            result_tb.INSTRUMENT_TYP = this.indexOptionDAO_.INSTRUMENT_TYP;
            result_tb.UNDERLYING_ID = "KOSPI200";
            result_tb.UNDERLYING_VALUE = indexData;
            //result_tb.SEQ = 1;
            result_tb.DELTA = (q_option.delta() * indexData / 100) * indexMultiplier * quantity; // 1% Delta
            result_tb.GAMMA = 0.5 * (q_option.gamma() * indexData / 100) * indexMultiplier * quantity; // 1% Gamma
            result_tb.VEGA = q_option.vega() / 100 * indexMultiplier * quantity; // 1% point Vega
            result_tb.CALC_PRICE = value * indexMultiplier * quantity;
            result_tb.CALCULATED_FLAG = (int)clsHITM_FP_GREEKRESULT_TB.CALCULATED_FLAG_Type.CALCULATED;
            result_tb.CALCULATED_TIME = DateTime.Now.ToString("HHmmss"); ;
            result_tb.CALCULATE_TYP = (int)clsHITM_FP_GREEKRESULT_TB.CALCULATE_TYP_Type.ANALYTICS;

            // price

            if (result_tb.UpdateDateResult() == 0)
            { throw new Exception("update result fail. no exist , calcDate : " + calcDate.ToString("yyyyMMdd") + " , inst_id : " + result_tb.INSTRUMENT_ID); }

            // delta

            // gamma and others : no exist ?


        }
Exemple #6
0
        //private void evalCurveMap()
        //{ 
        //    // eval ---------------------------------------------------------
        //    this.EvalCurveMap_.Clear();

        //    clsSET_EVALUATIONCURVE_TB clstb = new clsSET_EVALUATIONCURVE_TB();
            
        //    clstb.SETTING_ID = "MYSETTING";
            
        //    DataTable tb = clstb.Select();

        //    foreach (DataRow dr in tb.Select())
        //    {
        //        CurveManager cm = new CurveManager();

        //        clsSET_EVALUATIONCURVE_TB clstb_roop = clsSET_EVALUATIONCURVE_TB.Create(dr);

        //        cm.loadCurveData(this.CalcDate_, clstb_roop.CURVE_ID, clsHDAT_CURVEDATA_TB.RATE_TYP_Type.YTM);

        //        this.EvalCurveMap_.Add(clstb_roop.INDEX_CD, cm.yieldCurve(this.CurveShift_));
        //        this.EvalCurveManagerMap_.Add(clstb_roop.INDEX_CD, cm);
        //        //this.EvalCurveMap_.Add(clstb_roop.INDEX_CD, cm);
        //    }
        
        //}

        private void discountCurveMap()
        { 
            // discount ---------------------------------------------------------
            //this.DiscountCurveMap_.Clear();
            this.DiscountCurveManagerMap_.Clear();

            clsSET_DISCOUNTCURVE_TB clstb = new clsSET_DISCOUNTCURVE_TB();

            clstb.SETTING_ID = "MYSETTING";

            DataTable tb = clstb.Select();

            foreach (DataRow dr in tb.Select())
            {
                YieldCurve cm = new YieldCurve();
                clsSET_DISCOUNTCURVE_TB clstb_roop = clsSET_DISCOUNTCURVE_TB.Create(dr);

                cm.loadCurveData(this.CalcDate_, clstb_roop.CURVE_ID,clsHDAT_CURVEDATA_TB.RATE_TYP_Type.SPOT);

                //this.DiscountCurveMap_.Add(clstb_roop.CURR, cm.yieldCurve());
                this.DiscountCurveManagerMap_.Add(clstb_roop.CURR, cm);
                //this.DiscountCurveMap_.Add(clstb_roop.CURR, cm);
            }
        
        }