3
$\begingroup$

I am following the cookbook example for pricing a Vanilla Swap in QuantLib Python, given here.

Now let's assume that a week passed, and we are trying to calculate the mark to market value of the same swap. After a bit of looking around, I have found this thread, which leads me to believe that in order to re-price a swap at a later date, one needs to change the settlement date to get the updated market value of a swap. This does not seem right, since changing the settlement_date for the swap would result in shifting the cash flow schedules as well.

What I am looking for is to keep the swap definition (cash flow dates, maturity etc), load in a new yield curve at a later date, and re-price my swap using the new yield curve.

Can anybody show me how to do this?

Thanks!

$\endgroup$

1 Answer 1

2
$\begingroup$

You can keep the Swap instance you created, which contains the swap definition, and change the evaluation date and the curves you're using.

The evaluation date is simple: in Python,

Settings::instance().evaluationDate = new_date

will do the trick.

As for the curves, you'll have to change the declaration of discount_curve and libor_curve so that they use YieldTermStructureRelinkableHandle instead of YieldTermStructureHandle. This will give you the possibility to relink them to a different curve. Your modified script will be something like:

# as in the original notebook: create the swap,
# the curves for pricing on the first evaluation date, etc.

print swap.NPV()   # as of the first evaluation date

Settings::instance().evaluationDate = new_date

libor_curve.linkTo(
    # the curve for the new evaluation date
)
discount_curve.linkTo(
    # the curve for the new evaluation date
)

print swap.NPV()  # as of the new date, using the new curves.

In short: keep the swap, change everything else as required. The swap will recalculate accordingly.

One thing you might need to be aware of: if any of the non-expired floating coupon fixed before the evaluation date, you'll have to load the fixing of the underlying index. The interface to do that is, e.g.,

libor3M_index.addFixing(date, value)
$\endgroup$
3
  • $\begingroup$ Luigi, thank you for your comment. I was able to reprice a swap by doing what you say, and adding a fixing. I would like to understand why adding a fixing is necessary to calculate the NPV if the swap is to be repriced one day after it was created, but not on the day that swap was created. Thx $\endgroup$
    – bob.jonst
    Sep 11, 2017 at 23:09
  • $\begingroup$ It the coupon fixes today, you can forecast the fixing off the LIBOR curve. If it fixed yesterday, you can't, because the curve starts at today's date and is missing information on the past. $\endgroup$ Sep 12, 2017 at 7:23
  • $\begingroup$ thx, makes sense $\endgroup$
    – bob.jonst
    Sep 12, 2017 at 20:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.