示例#1
0
        public void Curve_Building(List <double> QuotedSpot, List <double> QuotedSpread, double Spread_traded, double Upfront)
        {
            OMLib.Conventions.DayCount.Actual365 dayCounter = new OMLib.Conventions.DayCount.Actual365();

            //Build interest rate curve, discount curve
            InterestRateCurve  IRC = new InterestRateCurve();
            YieldTermStructure yt  = new YieldTermStructure(this.tradedate);

            yt = IRC.calculation(tradedate, QuotedSpot); //return a discounting curve
            this.Jump_Nodes = IRC.Nodes;
            this.yieldcurve = yt;
            // Build Payment Schedule
            List <ZeroRates> zero_rates = new List <ZeroRates>(yt.jumps_.Count);

            for (int i = 0; i < yt.t.Count; i++)
            {
                ZeroRates temp = new ZeroRates();
                temp.YearFraction = yt.t[i];
                temp.Rate         = yt.getKnotZeroRates()[i];
                zero_rates.Add(temp);
            }
            this.zero_rates = zero_rates;


            // Implied hazard rates from quoted spreads.
            hazardratecurve(yt, dayCounter, QuotedSpot, QuotedSpread, this.PremiumRate, Spread_traded, Upfront, this.Maturity, this.firstpaymentdate,
                            this.evalDate, this.formerpaymentdate, this.Frequency, this.Recovery);
            double k = piecewiseHazardRate.SurvivalProb(new DateTime(2021, 06, 20));

            // Build Yield Curve / Credit Curve to be output


            curve_output(yt, this.piecewiseHazardRate);
        }
示例#2
0
        public YieldTermStructure makeUSDCurve(DateTime tradeDate, double[] rates)
        {
            DateTime           spotDate = tradeDate.AddDays(2);
            InterestRateCurve  IRC      = new InterestRateCurve();
            YieldTermStructure yt       = new YieldTermStructure(tradeDate);

            yt = IRC.calculation2(tradeDate, rates.ToList());
            return(yt);
        }
示例#3
0
        public void Build_yield_curve(DateTime TRADE_DATE)
        {
            var           reader         = new StreamReader(File.OpenRead(@"C:\Users\LeonDing\Source\Workspaces\OTC\CDSPro\Interest Rates.csv"));
            var           title          = reader.ReadLine();
            List <double> interest_rates = new List <double>();

            while (!reader.EndOfStream)
            {
                var line   = reader.ReadLine();
                var values = line.Split(',');

                interest_rates.Add(Convert.ToDouble(values[3]));
            }
            InterestRateCurve  IRC = new InterestRateCurve();
            YieldTermStructure yt  = new YieldTermStructure(TRADE_DATE);

            this.YIELD_CURVE = IRC.calculation2(TRADE_DATE, interest_rates);
        }