|
From: Brian S. <bri...@gm...> - 2020-10-02 18:49:11
|
Hi,
I was performing european and american valuation of the same Swaption
contract as follows. I found that both NPV values are quite big, and
they are surprisingly equal. Below is my implementation -
from QuantLib import *
import datetime
import numpy as np
import pandas as pd
calc_date = Date(23, 12, 2013)
Settings.instance().evaluationDate = calc_date
spot_dates = [calc_date + Period("1d"), calc_date + Period("2w"),
calc_date + Period("1m"), calc_date + Period("2m"), calc_date +
Period("3m"), calc_date + Period("6m"), calc_date + Period("1y"),
calc_date + Period("2y"), calc_date + Period("3y"), calc_date +
Period("4y"), calc_date + Period("5y"), calc_date + Period("8y"),
calc_date + Period("10y"), calc_date + Period("30y")]
spot_rates = [0.1, 0.13, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.7, 1.4, 1.6, 2, 2, 4]
us_calendar = UnitedStates()
zero_curve = ZeroCurve(spot_dates, spot_rates, Actual365Fixed(),
us_calendar, Linear(), Compounded, Annual)
termStructure = YieldTermStructureHandle(zero_curve)
swap = VanillaSwap(VanillaSwap.Payer,
100,
Schedule(Date(1, 12, 2014) + Period("6m"),
Date(1, 12, 2019), Period(6, Months), us_calendar, Unadjusted,
Unadjusted, DateGeneration.Forward, False),
3/100,
Thirty360(Thirty360.BondBasis),
Schedule(Date(1, 12, 2014) + Period("6m"),
Date(1, 12, 2019), Period(6, Months), us_calendar, Unadjusted,
Unadjusted, DateGeneration.Forward, False),
USDLibor(Period(6, Months), termStructure),
0.0,
USDLibor(Period(6, Months), termStructure).dayCounter()
)
exercised = EuropeanExercise(Date(1, 12, 2014))
atmswaption = Swaption(swap, exercised)
atmswaption.setPricingEngine(TreeSwaptionEngine(BlackKarasinski(termStructure),
3000)); print(atmswaption.NPV())
exercised = AmericanExercise(Date(1, 3, 2014), Date(1, 12, 2014))
atmswaption = Swaption(swap, exercised)
atmswaption.setPricingEngine(TreeSwaptionEngine(BlackKarasinski(termStructure),
3000)); print(atmswaption.NPV())
Is there any reason why they are so close? Your pointer will be very helpful.
Many thanks,
|