示例#1
0
        public static ScenarioInfo BaseParallelShift()
        {
            ScenarioInfo scenarioInfo = new ScenarioInfo();
            
            scenarioInfo.DAO_ = new clsSET_SCENARIO_TB();
            scenarioInfo.DAO_.FP_MASTER_TYP = 9999;
                if (scenarioInfo.DAO_.SelectOwn() == 0) { throw new Exception("default curve shift scenario load fail"); };

                return scenarioInfo;

        }
示例#2
0
        public static ScenarioInfo NullScenario() 
        {
            ScenarioInfo scenarioInfo = new ScenarioInfo();

            scenarioInfo.DAO_ = new clsSET_SCENARIO_TB();
            
            scenarioInfo.DAO_.FP_MASTER_TYP = 9999;
            scenarioInfo.DAO_.SCENARIO_CD = "NOSHIFT";
            scenarioInfo.DAO_.CURVE_CD = "NULL";
            scenarioInfo.DAO_.PARALLEL_SHIFT_UNIT = 0.0;
            scenarioInfo.DAO_.HUMP_SHIFT_UNIT = 0.0;
            scenarioInfo.DAO_.HUMP_CENTER_T = 0.0;
            scenarioInfo.DAO_.STEEPEN_SHIFT_UNIT = 0.0;
            scenarioInfo.DAO_.STEEPEN_CENTER_T = 0.0;

            return scenarioInfo;
        }
示例#3
0
        //public QuantLib.YieldTermStructure yieldCurve()
        //{
        //    List<string> depositePeriodStr = new List<string>();
        //    List<double> depositeRate = new List<double>();

        //    List<string> swapPeriodStr = new List<string>();
        //    List<double> swapRate = new List<double>();

        //    foreach (clsHDAT_CURVEDATA_TB data in this.ResultCuveData_)
        //    {
        //        if ( data.RATE_TYP == 1)
        //        {
        //            depositePeriodStr.Add(data.TENOR);
        //            depositeRate.Add(data.RATE);
        //        }
        //        else if (data.RATE_TYP == 2)
        //        {
        //            swapPeriodStr.Add(data.TENOR);
        //            swapRate.Add(data.RATE);
        //        }
        //        else
        //        {
                
        //        }
                
        //    }

        //    //string[] depositePeriodStr = {"3M","6M","9M","12M"};
        //    //string[] swapPeriodStr = {"2Y","3Y","4Y","5Y","7Y","10Y","15Y","20Y"};

        //    Date refDate = new Date(this.ReferenceDate_.ToString("yyyyMMdd"),"yyyyMMdd");

        //    Period floating_tenor = new Period("3M");
        //    Period swap_tenor = new Period("10Y");
        //    Period fixedRate_tenor = new Period("10Y");

        //    Currency currency = new KRWCurrency();
        //    Calendar calendar = new SouthKorea();
        //    BusinessDayConvention bdconv = BusinessDayConvention.ModifiedFollowing;
        //    DayCounter dayCounter = new Actual365Fixed();

        //    IborIndex iborIndex = new IborIndex("CD91", floating_tenor, 0, currency, calendar, bdconv, false, dayCounter);

        //    RateHelperVector rhv = new RateHelperVector();

        //    for (int i = 0; i < depositePeriodStr.Count; i++)
        //    {
        //        Period period = new Period(depositePeriodStr[i]);
        //        DepositRateHelper depositHelper = new DepositRateHelper(depositeRate[i], period ,0,calendar,bdconv,false,dayCounter);
        //        rhv.Add(depositHelper);
        //    }

        //    Frequency swapFrequency = Frequency.Semiannual;

        //    for (int i = 0; i < swapPeriodStr.Count ; i++)
        //    {
        //        //SwapIndex swapIndex = new SwapIndex("KRWIRS", swap_tenor, 0, currency, calendar, fixedRate_tenor, bdconv, dayCounter, iborIndex);
        //        Period swap_inst_tenor = new Period( swapPeriodStr[i] );
        //        SwapRateHelper swapHelper = new SwapRateHelper(swapRate[i], swap_inst_tenor, calendar, swapFrequency, bdconv, dayCounter, iborIndex);
        //        rhv.Add(swapHelper);
        //    }

        //    QuantLib.YieldTermStructure yts = new QuantLib.PiecewiseLinearZero(refDate,rhv,dayCounter);

        //    return yts;
            
        //}


        public YieldTermStructure yieldCurve(ScenarioInfo scenarioInfo)
        {
            if (scenarioInfo == null)
                scenarioInfo = new ScenarioInfo();

            QLNet.DayCounter dc = new QLNet.Actual365Fixed();

            List<Handle<Quote>> quotes = new List<Handle<Quote>>();
            List<double> datas = new List<double>();
            List<Date> dates = new List<Date>();

            CalendarManager cm = new CalendarManager(this.ReferenceDate_, CalendarManager.CountryType.SOUTH_KOREA);

            foreach (clsHDAT_CURVEDATA_TB tb in this.ResultCuveData_)
            {
                DateTime dt = cm.adjust(this.ReferenceDate_, tb.TENOR);
                double t = dc.yearFraction(this.ReferenceDate_, dt);
                double? rate = tb.RATE + scenarioInfo.shift(t);

                dates.Add(dt);
                SimpleQuote quote = new SimpleQuote(rate);
                Handle<Quote> handleQuote = new Handle<Quote>(quote);

                quotes.Add(handleQuote);
                datas.Add(rate.Value);

            }

            InterpolatedZeroCurve<ConvexMonotone>
                        yiels_ts = new InterpolatedZeroCurve<ConvexMonotone>(
                                                this.ReferenceDate_,
                                                dates,
                                                datas,
                                                dc,
                                                new ConvexMonotone(),
                                                Compounding.Compounded,
                                                Frequency.Annual);

            return yiels_ts;

        }