Pricing Interest Rate swap at future dates

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Pricing Interest Rate swap at future dates

Mariano Zeron
I’m trying to compute a price distribution at different points in time in the future for an interest rate swap. The idea is to then use the price distributions to compute CVA, Initial Margin, etc. However, the tricky part so far has been pricing the interest rate swap (which has been fixed in the past, of course) at different points in time in the future.

Say the interest rate swap started on 1, March, 2016 (as seen in the code below). The interest rate swap is evaluated on the 10, November, 2016, (but of course the idea is to vary this date depending on the dates we want price distributions for). The problem I’ve been getting is that when the valuation date is after the settle date, I get the following exception:

2nd leg: Missing Euribor1Y Actual/360 fixing for February 26th, 2016


Code:

        Calendar calendar = TARGET();
         
        // -- Swap parameters
        Real nominal = 1000000.0;
        Date SettleDate(1, March, 2016);
        Date maturity(1, March, 2026);
        double spread = 0.02;
        double fixedRate = 0.04;

        Frequency fixedLegFrequency = Annual;
        Frequency floatingLegFrequency = Annual;

        VanillaSwap::Type swapType = VanillaSwap::Payer;


        // -- Valuation date
        Date valuationDate(10, November, 2016);
        valuationDate = calendar.adjust(valuationDate);
        Settings::instance().evaluationDate() = valuationDate;


        // -- Specifying discount curve (simple example. Normally it would have 12 tenors)
        vector<Date> dates;
        vector<DiscountFactor> discountFactor;

        dates.push_back(valuationDate); discountFactor.push_back(1.0);
        dates.push_back(valuationDate + 1 * Years);  discountFactor.push_back(0.99);
        dates.push_back(valuationDate + 15 * Years);  discountFactor.push_back(0.80);


        boost::shared_ptr<YieldTermStructure> forwardCurve(new InterpolatedDiscountCurve<LogLinear>(dates, discountFactor, ActualActual()));
        boost::shared_ptr<YieldTermStructure> discountCurve(new InterpolatedDiscountCurve<LogLinear>(dates, discountFactor, ActualActual()));

        Handle<YieldTermStructure> discountingTermStructure(discountCurve);
        Handle<YieldTermStructure> forwardingTermStructure(forwardCurve);


        Schedule fixedSchedule(SettleDate, maturity, Period(fixedLegFrequency),
                TARGET(), ModifiedFollowing, ModifiedFollowing,
                DateGeneration::Forward, false);

        Schedule floatSchedule(SettleDate, maturity, Period(floatingLegFrequency),
                TARGET(), ModifiedFollowing, ModifiedFollowing,
                DateGeneration::Forward, false);

        boost::shared_ptr<IborIndex> euribor(new Euribor(Period(floatingLegFrequency), forwardingTermStructure));
        //euribor->addFixing(euribor->fixingDate(SettleDate), 0.01, true);


        VanillaSwap swap(swapType, nominal, fixedSchedule, fixedRate, ActualActual(),
                floatSchedule, euribor, spread, ActualActual());

       
        boost::shared_ptr<PricingEngine> swapEngine(new DiscountingSwapEngine(discountingTermStructure));
        swap.setPricingEngine(swapEngine);

        double res = swap.NPV();



It seems that boost::shared_ptr<IborIndex> euribor needs the rate from the previous payment date in order to specify the rate which is applied to the notional. From what I’ve read in other threads, one can use euribor->addFixing.

First problem/inconvenience, is that for each time point in the future, one has to keep track of which is the previous payment date. The second is that one needs to come up with a value for the rate which must be specified for this payment date. Is there a method (or methods) for euribor that help in this case? euribor already contains the curve to used to compute rates on the floating leg (boost::shared_ptr<YieldTermStructure> forwardCurve), can it not be extrapolated to the previous payment date and use that rate?

Any suggestions on how to deal with this issue will be highly appreciated

Reply | Threaded
Open this post in threaded view
|

Re: Pricing Interest Rate swap at future dates

Luigi Ballabio
Hello,
    sorry for the delay---vacations tend to get in the way.
If you're ok with using the current forecast of the Euribor fixings as "past" fixings on future dates, you might just use a simple loop to calculate Euribor rates from the curve for each day in the future range of dates and save them using euribor->addFixing.  The code will use those fixings when they are in the past relative to the current evaluation date, and ignore them when they are in the future.

Hope this helps,
    Luigi



On Wed, Aug 10, 2016 at 8:05 AM Mariano Zeron <[hidden email]> wrote:
I’m trying to compute a price distribution at different points in time in the
future for an interest rate swap. The idea is to then use the price
distributions to compute CVA, Initial Margin, etc. However, the tricky part
so far has been pricing the interest rate swap (which has been fixed in the
past, of course) at different points in time in the future.

Say the interest rate swap started on 1, March, 2016 (as seen in the code
below). The interest rate swap is evaluated on the 10, November, 2016, (but
of course the idea is to vary this date depending on the dates we want price
distributions for). The problem I’ve been getting is that when the valuation
date is after the settle date, I get the following exception:

2nd leg: Missing Euribor1Y Actual/360 fixing for February 26th, 2016


Code:

        Calendar calendar = TARGET();

        // -- Swap parameters
        Real nominal = 1000000.0;
        Date SettleDate(1, March, 2016);
        Date maturity(1, March, 2026);
        double spread = 0.02;
        double fixedRate = 0.04;

        Frequency fixedLegFrequency = Annual;
        Frequency floatingLegFrequency = Annual;

        VanillaSwap::Type swapType = VanillaSwap::Payer;


        // -- Valuation date
        Date valuationDate(10, November, 2016);
        valuationDate = calendar.adjust(valuationDate);
        Settings::instance().evaluationDate() = valuationDate;


        // -- Specifying discount curve (simple example. Normally it would have 12
tenors)
        vector<Date> dates;
        vector<DiscountFactor> discountFactor;

        dates.push_back(valuationDate); discountFactor.push_back(1.0);
        dates.push_back(valuationDate + 1 * Years);
discountFactor.push_back(0.99);
        dates.push_back(valuationDate + 15 * Years);
discountFactor.push_back(0.80);


        boost::shared_ptr<YieldTermStructure> forwardCurve(new
InterpolatedDiscountCurve<LogLinear>(dates, discountFactor,
ActualActual()));
        boost::shared_ptr<YieldTermStructure> discountCurve(new
InterpolatedDiscountCurve<LogLinear>(dates, discountFactor,
ActualActual()));

        Handle<YieldTermStructure> discountingTermStructure(discountCurve);
        Handle<YieldTermStructure> forwardingTermStructure(forwardCurve);


        Schedule fixedSchedule(SettleDate, maturity, Period(fixedLegFrequency),
                TARGET(), ModifiedFollowing, ModifiedFollowing,
                DateGeneration::Forward, false);

        Schedule floatSchedule(SettleDate, maturity, Period(floatingLegFrequency),
                TARGET(), ModifiedFollowing, ModifiedFollowing,
                DateGeneration::Forward, false);

        boost::shared_ptr<IborIndex> euribor(new
Euribor(Period(floatingLegFrequency), forwardingTermStructure));
        //euribor->addFixing(euribor->fixingDate(SettleDate), 0.01, true);


        VanillaSwap swap(swapType, nominal, fixedSchedule, fixedRate,
ActualActual(),
                floatSchedule, euribor, spread, ActualActual());


        boost::shared_ptr<PricingEngine> swapEngine(new
DiscountingSwapEngine(discountingTermStructure));
        swap.setPricingEngine(swapEngine);

        double res = swap.NPV();



It seems that boost::shared_ptr<IborIndex> euribor needs the rate from the
previous payment date in order to specify the rate which is applied to the
notional. From what I’ve read in other threads, one can use
euribor->addFixing.

First problem/inconvenience, is that for each time point in the future, one
has to keep track of which is the previous payment date. The second is that
one needs to come up with a value for the rate which must be specified for
this payment date. Is there a method (or methods) for euribor that help in
this case? euribor already contains the curve to used to compute rates on
the floating leg (boost::shared_ptr<YieldTermStructure> forwardCurve), can
it not be extrapolated to the previous payment date and use that rate?

Any suggestions on how to deal with this issue will be highly appreciated





--
View this message in context: http://quantlib.10058.n7.nabble.com/Pricing-Interest-Rate-swap-at-future-dates-tp17639.html
Sent from the quantlib-users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are
consuming the most bandwidth. Provides multi-vendor support for NetFlow,
J-Flow, sFlow and other flows. Make informed decisions using capacity
planning reports. http://sdm.link/zohodev2dev
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users

------------------------------------------------------------------------------

_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Pricing Interest Rate swap at future dates

Mariano Zeron
Hi,

Sorry for the delay in replying. Yes, thanks, this will do for the time being. I guess if I want to make it more precise Ill have to include time slices in the future on the dates when the fixing must be done and use the yield curve of that day to come of with a fixing for that date.

All the best

Mariano