From: Peter C. <pca...@gm...> - 2014-09-20 17:08:59
|
I think someone else should jump in here, I am not really a Python expert. Peter On 20 September 2014 18:37, KK <the...@gm...> wrote: > Thanks for replying so fast Peter. I am a little embarrassed to admit my c++ > knowledge is very weak. Do you happen to know the equivalent method for > retrieving the schedule of implied fixings using python? > Sent from my BlackBerry device on the Rogers Wireless Network > ________________________________ > From: "Peter Caspers-4 [via QuantLib]" <[hidden email]> > Date: Sat, 20 Sep 2014 09:07:22 -0700 (MST) > To: KK<[hidden email]> > Subject: Re: Changing Second/Third Fixing on Vanilla Swap > > I'd take the underlying swap from the swap rate helper with maximum > maturity ( by calling swap() on this helper ), then get the floating > leg ( by calling floatingLeg() ), iterate over it to get the coupons ( > you have to cast them with something like > boost::dynamic_pointer_cast<FloatingRateCoupon>( leg[i] ) ) and ask > each coupon for the fixing date ( by calling fixingDate() ). > Peter > > On 20 September 2014 17:31, Khalid <[hidden email]> wrote: > >> Hi Peter >> >> Many thanks for the quick and detailed reply. I suspect a simpler solution >> will be to use the cash flow date schedule specified by the curve and create >> cashflows myself from my own list of fixings that I want to use. >> >> >> As an aside, is there a way of creating the schedule of 6mth fixings >> implied by the swap curve? I am able to back out the number using the >> nominal amount, the cash flow amount and the days accrued period, but wonder >> if there is a way of directly calling all the fixings on the floating leg. >> >> >> Many thanks again >> >> >> >> On Sep 20, 2014, at 6:10 AM, Peter Caspers <[hidden email]> wrote: >> >>> Hi Khalid, >>> >>> the InterestRateIndex class never takes fixings for future dates (i.e. >>> dates bigger than the evaluation date set in the settings) into >>> account. In derived classes like IborIndex or SwapIndex they are >>> estimated on a curve you can attach to the index, so if you want to >>> compute scenarios where future fixings are shifted, you probably have >>> to do appropriate shifts on the curve. >>> >>> The evaluation date itself plays a special role (since fixings are >>> usually available only after a certain time of the day). With the >>> setting enforceTodaysHistoricFixing you can require that on the >>> evaluation date a fixing must be used, and if this is not available, >>> an exception is thrown. This is for example useful if you have an end >>> of day processing where you know that the fixing should be available. >>> The default value is false though, allowing to take a fixing into >>> account if available and otherwise estimate it on a curve. >>> >>> Finally the forecastFixing method in InterestRateIndex has a flag >>> forecastTodaysFixing (defaulted to false) which if true enforces >>> estimation on a curve even if the fixing is available. This is for >>> example useful if you don't want to nail today's fixing during >>> sensitivities calculation. >>> >>> Peter >>> >>> >>> On 20 September 2014 05:52, KK <[hidden email]> wrote: >>>> This code example from: >>>> >>>> >>>> https://github.com/alexpoly/quant-snippets-python-c/blob/master/amortizing%20swap%20valuation%20quantlib.py >>>> >>>> >>>> from 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 >>>> >>>> >>>> >>>> >>>> -- >>>> View this message in context: >>>> http://quantlib.10058.n7.nabble.com/Changing-Second-Third-Fixing-on-Vanilla-Swap-tp15890.html >>>> Sent from the quantlib-users mailing list archive at Nabble.com. >>>> >>>> >>>> ------------------------------------------------------------------------------ >>>> Slashdot TV. Video 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-users > ------------------------------------------------------------------------------ > Slashdot TV. Video 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-users > > > ________________________________ > If you reply to this email, your message will be added to the discussion > below: > http://quantlib.10058.n7.nabble.com/Changing-Second-Third-Fixing-on-Vanilla-Swap-tp15890p15893.html > To unsubscribe from Changing Second/Third Fixing on Vanilla Swap, click > here. > NAML > > ________________________________ > View this message in context: Re: Changing Second/Third Fixing on Vanilla > Swap > > Sent from the quantlib-users mailing list archive at Nabble.com. > > ------------------------------------------------------------------------------ > Slashdot TV. Video for Nerds. Stuff that Matters. > http://pubads.g.doubleclick.net/gampad/clk?id=160591471&iu=/4140/ostg.clktrk > _______________________________________________ > QuantLib-users mailing list > Qua...@li... > https://lists.sourceforge.net/lists/listinfo/quantlib-users > |