public CommonVars() { type = OvernightIndexedSwap.Type.Payer; settlementDays = 2; nominal = 100.0; fixedEoniaConvention = BusinessDayConvention.ModifiedFollowing; floatingEoniaConvention = BusinessDayConvention.ModifiedFollowing; fixedEoniaPeriod = new Period(1, TimeUnit.Years); floatingEoniaPeriod = new Period(1, TimeUnit.Years); fixedEoniaDayCount = new Actual360(); eoniaIndex = new Eonia(eoniaTermStructure); fixedSwapConvention = BusinessDayConvention.ModifiedFollowing; fixedSwapFrequency = Frequency.Annual; fixedSwapDayCount = new Thirty360(); swapIndex = (IborIndex) new Euribor3M(swapTermStructure); calendar = eoniaIndex.fixingCalendar(); today = new Date(5, Month.February, 2009); //today = calendar.adjust(Date::todaysDate()); Settings.setEvaluationDate(today); settlement = calendar.advance(today, new Period(settlementDays, TimeUnit.Days), BusinessDayConvention.Following); eoniaTermStructure.linkTo(Utilities.flatRate(settlement, 0.05, new Actual365Fixed())); }
public void testBootstrap() { // Testing Eonia-swap curve building... CommonVars vars = new CommonVars(); List <RateHelper> eoniaHelpers = new List <RateHelper>(); List <RateHelper> swap3mHelpers = new List <RateHelper>(); IborIndex euribor3m = new Euribor3M(); Eonia eonia = new Eonia(); for (int i = 0; i < depositData.Length; i++) { double rate = 0.01 * depositData[i].rate; SimpleQuote simple = new SimpleQuote(rate); Handle <Quote> quote = new Handle <Quote>(simple); Period term = new Period(depositData[i].n, depositData[i].unit); RateHelper helper = new DepositRateHelper(quote, term, depositData[i].settlementDays, euribor3m.fixingCalendar(), euribor3m.businessDayConvention(), euribor3m.endOfMonth(), euribor3m.dayCounter()); if (term <= new Period(2, TimeUnit.Days)) { eoniaHelpers.Add(helper); } if (term <= new Period(3, TimeUnit.Months)) { swap3mHelpers.Add(helper); } } for (int i = 0; i < fraData.Length; i++) { double rate = 0.01 * fraData[i].rate; SimpleQuote simple = new SimpleQuote(rate); Handle <Quote> quote = new Handle <Quote>(simple); RateHelper helper = new FraRateHelper(quote, fraData[i].nExpiry, fraData[i].nMaturity, fraData[i].settlementDays, euribor3m.fixingCalendar(), euribor3m.businessDayConvention(), euribor3m.endOfMonth(), euribor3m.dayCounter()); swap3mHelpers.Add(helper); } for (int i = 0; i < eoniaSwapData.Length; i++) { double rate = 0.01 * eoniaSwapData[i].rate; SimpleQuote simple = new SimpleQuote(rate); Handle <Quote> quote = new Handle <Quote>(simple); Period term = new Period(eoniaSwapData[i].n, eoniaSwapData[i].unit); RateHelper helper = new OISRateHelper(eoniaSwapData[i].settlementDays, term, quote, eonia); eoniaHelpers.Add(helper); } for (int i = 0; i < swapData.Length; i++) { double rate = 0.01 * swapData[i].rate; SimpleQuote simple = new SimpleQuote(rate); Handle <Quote> quote = new Handle <Quote>(simple); Period tenor = new Period(swapData[i].nIndexUnits, swapData[i].indexUnit); Period term = new Period(swapData[i].nTermUnits, swapData[i].termUnit); RateHelper helper = new SwapRateHelper(quote, term, vars.calendar, vars.fixedSwapFrequency, vars.fixedSwapConvention, vars.fixedSwapDayCount, euribor3m); if (tenor == new Period(3, TimeUnit.Months)) { swap3mHelpers.Add(helper); } } PiecewiseYieldCurve <Discount, LogLinear> eoniaTS = new PiecewiseYieldCurve <Discount, LogLinear>(vars.today, eoniaHelpers, new Actual365Fixed()); PiecewiseYieldCurve <Discount, LogLinear> swapTS = new PiecewiseYieldCurve <Discount, LogLinear>(vars.today, swap3mHelpers, new Actual365Fixed()); vars.eoniaTermStructure.linkTo(eoniaTS); // test curve consistency double tolerance = 1.0e-10; for (int i = 0; i < eoniaSwapData.Length; i++) { double expected = eoniaSwapData[i].rate; Period term = new Period(eoniaSwapData[i].n, eoniaSwapData[i].unit); OvernightIndexedSwap swap = vars.makeSwap(term, 0.0, 0.0); double?calculated = 100.0 * swap.fairRate(); if (Math.Abs(expected - calculated.Value) > tolerance) { QAssert.Fail("curve inconsistency:\n" + " swap length: " + term + "\n" + " quoted rate: " + expected + "\n" + " calculated rate: " + calculated); } } }
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Eonia obj) { return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr); }
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Eonia obj) { return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; }