Posted by
KK on
URL: http://quantlib.414.s1.nabble.com/Changing-Second-Third-Fixing-on-Vanilla-Swap-tp15890.html
This code example from:
https://github.com/alexpoly/quant-snippets-python-c/blob/master/amortizing%20swap%20valuation%20quantlib.pyfrom QuantLib import *
import numpy as np
from math import *
todaysDate=Date(31,12,2013)
startDate=todaysDate
Settings.instance().evaluationDate=todaysDate;
crvToday=FlatForward(todaysDate,0.0121,Actual365Fixed())
forecastTermStructure = RelinkableYieldTermStructureHandle()
index = GBPLibor(Period("6m"),forecastTermStructure)
maturity = Date(31,12,2018);
schedule = Schedule(startDate, maturity,Period("6m"),UnitedKingdom(),ModifiedFollowing,ModifiedFollowing,DateGeneration.Forward, False)
nominals=[100.0]*10
couponRates=[0.05]*10
floatingleg=IborLeg(nominals,schedule,index,Actual365Fixed())
fixedleg=FixedRateLeg(schedule,Actual365Fixed(),nominals,couponRates)
index.addFixing(index.fixingDate(schedule[0]),0.01)
#index.addFixing(index.fixingDate(schedule[1]),0.01)
swap1=Swap(floatingleg,fixedleg)
discountTermStructure = RelinkableYieldTermStructureHandle()
swapEngine = DiscountingSwapEngine(discountTermStructure)
swap1.setPricingEngine(swapEngine)
discountTermStructure.linkTo(crvToday)
forecastTermStructure.linkTo(crvToday)
for x in floatingleg:
print x.date(), x.amount()
can show the floating cashflows on a vanilla swap. By including the line:
index.addFixing(index.fixingDate(schedule[0]),0.01)
I can change the first fixing to 1%
How can I
also change the second fixing to 1.5%?
index.addFixing(index.fixingDate(schedule[1]),0.015)
has no effect.
Thanks