http://quantlib.414.s1.nabble.com/Second-Fixing-Different-to-Second-Rate-tp15938p15978.html
as a default, the library is using par coupons. Starting from
coupon = as_floating_rate_coupon(floatingrates[1]) # your second coupon.
"indexed coupons") and recompile both QuantLib and QuantLib-Python.
> Hi
>
> Apologies for repost, but the last comment by Pascal was extremely helpful
> and made the problem easier to explain.
>
> Is there any reason why when I cast the floating leg to coupons, I get a
> rate that is different from the second fixing. This code extracts all the
> elements of the calc - eg day count/period etc and the second fixing is
> listed as
>
> 0.0360560874576
>
> while the rate used to calculate the second cashflow is
>
> 0.0360614343399
>
> For what it is worth, the second number looks right if you bootstrap by
> hand.
>
> basically index.fixing(floatingSchedule[1]) does not equal
> as_coupon(cashflow).rate()
>
>
> from QuantLib import *
> from datetime import date
> def makeQLdatePydate(s_date):
> return date(s_date.year(),s_date.month(),s_date.dayOfMonth())
>
> calendar = UnitedKingdom()
> todaysDate = Date(7,January,2013);
> Settings.instance().evaluationDate = todaysDate
> settlementDate = Date(7,January,2013);
>
> # market quotes
> deposits = { (3,Months): 0.0363,
> (6,Months): 0.0353,
> (12,Months): 0.036,
> (18,Months): 0.036 }
>
>
>
>
> for n,unit in deposits.keys():
> deposits[(n,unit)] = SimpleQuote(deposits[(n,unit)])
>
>
> dayCounter = Actual365Fixed()
> settlementDays = 0
> depositHelpers = [ DepositRateHelper(QuoteHandle(deposits[(n,unit)]),
> Period(n,unit), settlementDays,
> calendar, ModifiedFollowing,
> False, dayCounter)
> for n, unit in deposits.keys() ]
>
>
>
> settlementDays = 0
> #fixedLegFrequency = Semiannual
> #fixedLegTenor = Period(6,Months)
> #fixedLegAdjustment = Unadjusted
> #fixedLegDayCounter = Actual365Fixed()
>
> floatingLegFrequency = Semiannual
> floatingLegTenor = Period(6,Months)
> floatingLegAdjustment = ModifiedFollowing
>
>
>
>
> discountTermStructure = RelinkableYieldTermStructureHandle()
> forecastTermStructure = RelinkableYieldTermStructureHandle()
>
>
> helpers = depositHelpers
>
> depoSwapCurve = PiecewiseFlatForward(settlementDate,
> helpers,Actual365Fixed())
>
>
> swapEngine = DiscountingSwapEngine(discountTermStructure)
>
> discountTermStructure.linkTo(depoSwapCurve)
> forecastTermStructure.linkTo(depoSwapCurve)
>
>
>
> nominal=1000000
> length = 1
> maturity = calendar.advance(settlementDate,length,Years)
>
> #
> index = GBPLibor(floatingLegTenor,forecastTermStructure)
>
> floatingLegDayCounter = index.dayCounter()
>
>
> floatingSchedule = Schedule(settlementDate, maturity,
> floatingLegTenor, calendar,
> floatingLegAdjustment, floatingLegAdjustment,
> DateGeneration.Backward, False)
>
>
> nominals =[nominal for x in floatingSchedule]
>
>
>
> floatingrates = IborLeg(nominals[:-1],floatingSchedule,index,dayCounter)
>
>
> print "Reset for calculating second cashflow"
> print index.fixing(floatingSchedule[1])
> print "Start date for calculating second cashflow"
> print floatingSchedule[1]
> print "End date for calculating second cashflow"
> print floatingSchedule[2]
> print "Days"
> print
> float((makeQLdatePydate(floatingSchedule[2])-makeQLdatePydate(floatingSchedule[1])).days)
> print "Days/365"
> print
> float((makeQLdatePydate(floatingSchedule[2])-makeQLdatePydate(floatingSchedule[1])).days)/365.0
> print "Second Cashflow from floatingSchedule = nominal * rate * Days/365"
> print nominal*index.fixing(floatingSchedule[1])*
> float((makeQLdatePydate(floatingSchedule[2])-makeQLdatePydate(floatingSchedule[1])).days)/365.0
>
> print "Second cashflow from IborLeg and from simple bootstrapping"
> print floatingrates[1].date(),floatingrates[1].amount()
>
>
> for cashflow in floatingrates:
> coupon = as_coupon(cashflow)
> print "Date: " + str(coupon.date()) +", Amount: " +
> str(coupon.amount()) + ", Accrual period: " + str(coupon.accrualPeriod())
> print "Date: " + str(coupon.date()) +", accrualStartDate: " +
> str(coupon.accrualStartDate()) + ", accrualEndDate: " +
> str(coupon.accrualEndDate())
> print "Date: " + str(coupon.date()) +", rate: " + str(coupon.rate())
> print "Date: " + str(coupon.date()) +", nominal: " +
> str(coupon.nominal())
> print "Date: " + str(coupon.date()) +", referencePeriodStart: " +
> str(coupon.referencePeriodStart()) + ", referencePeriodEnd: " +
> str(coupon.referencePeriodEnd())
> print "Date: " + str(coupon.date()) +", accrualDays: " +
> str(coupon.accrualDays())
>
>
>
> --
> View this message in context:
http://quantlib.10058.n7.nabble.com/Second-Fixing-Different-to-Second-Rate-tp15938.html> Sent from the quantlib-users mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
> Slashdot TV. Videos for Nerds. Stuff that Matters.
>
http://pubads.g.doubleclick.net/gampad/clk?id=160591471&iu=/4140/ostg.clktrk> _______________________________________________
> QuantLib-users mailing list
>
[hidden email]
>
https://lists.sourceforge.net/lists/listinfo/quantlib-usersComprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.