Hi, I need to estimate the value of a portfolio of existing swaps in future dates. For example the value in 1 YR, 2YR, .....20YR time. At this moment I don't care about the implied curve for 1YR, 2YR, etc... I am happy to use existing curve and just change the evaluation date. I though that If I setup the current portfolio of Swaps I would only need to change Settings::instance().evaluationDate() and get the new PV for each swap. But I findout that I still get the PV of cash flows that have already matured. (¿?). I paste an example in Python (just a prove of concept) that setups a vanilla swap and gets NPV at inception and move 1YR and 2YR the evaluation date. It creates and excel file with the NPV and cashflows for both legs for each valuation date. (attached the excel file).
Thanks in advance for your helps and sorry if they are quite basic questions. Lluís. *************************************************** The initial valuation date is 13 - October - 2010 I've previously created a deposwapcurve with depoSwapCurve = PiecewiseLogLinearDiscount( ValueDate, helpers, ActualActual()) swapEngine = DiscountingSwapEngine(discountTermStructure) nominal = 10000000 fixedLegFrequency = Annual floatingLegFrequency = Semiannual fixedSchedule = Schedule(ValueDate, maturity, spot = VanillaSwap(VanillaSwap.Payer, nominal, # price on the bootstrapped curves (......) def report(swap, name): discountTermStructure.linkTo(depoSwapCurve) report(spot,'depo-fut-swap')
styleNum = xlwt.easyxf(num_format_str='#,##0.00') NewDate = date(Settings.instance().evaluationDate.year(),Settings.instance().evaluationDate.month(),Settings.instance().evaluationDate.dayOfMonth()) ws.write(0 , 0, 'Date',styleHeader) fixedleg = spot.fixedLeg() for i in range(len(fixedleg)): for i in range(len(floatingleg)): ws.write(1, 4, spot.NPV(),styleNum) # move forward 1 year Settings.instance().evaluationDate = calendar.advance(ValueDate,1,Years) discountTermStructure.linkTo(depoSwapCurve) NewDate = date(Settings.instance().evaluationDate.year(),Settings.instance().evaluationDate.month(),Settings.instance().evaluationDate.dayOfMonth()) ws = w.add_sheet('CashFlows1') ws.write(0 , 0, 'Date',styleHeader) fixedleg = spot.fixedLeg() for i in range(len(fixedleg)): for i in range(len(floatingleg)): # move 2 year the time Settings.instance().evaluationDate = calendar.advance(Settings.instance().evaluationDate,1,Years) discountTermStructure.linkTo(depoSwapCurve) NewDate = date(Settings.instance().evaluationDate.year(),Settings.instance().evaluationDate.month(),Settings.instance().evaluationDate.dayOfMonth()) ws = w.add_sheet('CashFlows2') ws.write(0 , 0, 'Date',styleHeader)
for i in range(len(fixedleg)): for i in range(len(floatingleg)): ws.write(1, 4, spot.NPV(),styleNum) w.save(Foutput) *************************************************
------------------------------------------------------------------------------ Increase Visibility of Your 3D Game App & Earn a Chance To Win $500! Tap into the largest installed PC base & get more eyes on your game by optimizing for Intel(R) Graphics Technology. Get started today with the Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs. http://p.sf.net/sfu/intelisp-dev2dev _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users SwapOutput.xls (18K) Download Attachment |
On Wed, 2010-11-24 at 14:35 +0100, Lluis Pujol Bajador wrote:
> I need to estimate the value of a portfolio of existing swaps > in future dates. For example the value in 1 YR, 2YR, .....20YR time. > At this moment I don't care about the implied curve for 1YR, 2YR, > etc... I am happy to use existing curve and just change the evaluation > date. > > I though that If I setup the current portfolio of Swaps I would only > need to change Settings::instance().evaluationDate() and get the new > PV for each swap. But I findout that I still get the PV of cash flows > that have already matured. (¿?). Your problem is the creation of the discount curve: > I've previously created a deposwapcurve with depoSwapCurve = > PiecewiseLogLinearDiscount( ValueDate, helpers, ActualActual()) If you create it with an explicit ValueDate, that date will remain the date to which the cash flows are discounted. If you create the curve with a number of business days (probably 0) and a calendar instead, the reference date of the discount curve will move with the evaluation date and the cashflows will be filtered accordingly. See chapter 3 at <http://sites.google.com/site/luigiballabio/qlbook> for more details. Luigi -- An ideal world is left as an exercise to the reader. -- Paul Graham ------------------------------------------------------------------------------ Increase Visibility of Your 3D Game App & Earn a Chance To Win $500! Tap into the largest installed PC base & get more eyes on your game by optimizing for Intel(R) Graphics Technology. Get started today with the Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs. http://p.sf.net/sfu/intelisp-dev2dev _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Hello, i want to make sure that i understood the mentioned behavior of the curve correctly. When creating it with "number of business days" and changing the evaluation date to a future future date, will the curve's shape remain the same (Behavior A), or will the curve be "forwarded" 2 years (Behavior B)? Example for "evaluationDate_New = evaluationDate_Old +2Years": Behavior A: The discount factors d4_Old and d4_New for a cash flow 4 years after the evaluation date are the same before and after the date change. Behavior B: The discount factor d4_New for a cash flow 4 years after the evaluation date fulfills the following equation: d4_New == d6_Old / d2_Old If it is one of these behaviors, which one? And if it is not B, how can i achieve behavior B? (Should i open a new thread for this question?) Best Regards, Henner Heck Am 24.11.2010, 15:58 Uhr, schrieb Luigi Ballabio <[hidden email]>: > On Wed, 2010-11-24 at 14:35 +0100, Lluis Pujol Bajador wrote: >> I need to estimate the value of a portfolio of existing swaps >> in future dates. For example the value in 1 YR, 2YR, .....20YR time. >> At this moment I don't care about the implied curve for 1YR, 2YR, >> etc... I am happy to use existing curve and just change the evaluation >> date. >> >> I though that If I setup the current portfolio of Swaps I would only >> need to change Settings::instance().evaluationDate() and get the new >> PV for each swap. But I findout that I still get the PV of cash flows >> that have already matured. (¿?). > > Your problem is the creation of the discount curve: > >> I've previously created a deposwapcurve with depoSwapCurve = >> PiecewiseLogLinearDiscount( ValueDate, helpers, ActualActual()) > > If you create it with an explicit ValueDate, that date will remain the > date to which the cash flows are discounted. If you create the curve > with a number of business days (probably 0) and a calendar instead, the > reference date of the discount curve will move with the evaluation date > and the cashflows will be filtered accordingly. > > See chapter 3 at <http://sites.google.com/site/luigiballabio/qlbook> for > more details. > > Luigi > > > -- Erstellt mit Operas revolutionärem E-Mail-Modul: http://www.opera.com/mail/ ------------------------------------------------------------------------------ What happens now with your Lotus Notes apps - do you make another costly upgrade, or settle for being marooned without product support? Time to move off Lotus Notes and onto the cloud with Force.com, apps are easier to build, use, and manage than apps on traditional platforms. Sign up for the Lotus Notes Migration Kit to learn more. http://p.sf.net/sfu/salesforce-d2d _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
On Mon, 2010-12-06 at 15:53 +0100, Henner Heck wrote:
> i want to make sure that i understood the mentioned behavior of the > curve correctly. When creating it with "number of business days" and > changing the evaluation date to a future future date, will the curve's > shape remain the same (Behavior A), or will the curve be "forwarded" 2 > years (Behavior B)? > > Example for "evaluationDate_New = evaluationDate_Old +2Years": > > Behavior A: > The discount factors d4_Old and d4_New for a cash flow 4 years after the > evaluation date are the same before and after the date change. > > Behavior B: > The discount factor d4_New for a cash flow 4 years after the evaluation > date fulfills the following equation: > d4_New == d6_Old / d2_Old > > If it is one of these behaviors, which one? > And if it is not B, how can i achieve behavior B? It's A (more or less; the curve shape might change slightly due to holidays.) discount(evaluationDate + 4*Years) should stay the same when evaluationDate moves. The curve will assume the deposit and swap rates used for bootstrapping apply from the new evaluation date, and will rebuild itself accordingly. Behavior B can be achieved by means of the ImpliedTermStructure class (<ql/termstructures/yield/impliedtermstructure.hpp>.) Luigi -- The surest way to make a monkey of a man is to quote him. -- Robert Benchley ------------------------------------------------------------------------------ This SF Dev2Dev email is sponsored by: WikiLeaks The End of the Free Internet http://p.sf.net/sfu/therealnews-com _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Free forum by Nabble | Edit this page |