|
From: Luigi B. <lui...@gm...> - 2020-10-19 08:11:23
|
Hello Brian,
by 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] do you mean 0.1%, 0.13% and so on?
If so, that should be spot_rates = [0.001, 0.0013, 0.001, 0.001, 0.001,
0.001, 0.001, 0.001, 0.007, 0.014, 0.016, 0.02, 0.02, 0.04].
As it is, you're passing 10%, 13% etc., which throws the computation off.
Hope this helps,
Luigi
On Fri, Oct 2, 2020 at 8:51 PM Brian Smith <bri...@gm...>
wrote:
> 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,
>
>
> _______________________________________________
> QuantLib-users mailing list
> Qua...@li...
> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>
|