VanillaSwap evaluation between effective and termination date

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

VanillaSwap evaluation between effective and termination date

Jicun Zhong

Hi,

I am trying to calculate NPV of a vanilla swap based in the swapvaluation.cpp code.

I have setup the swap the following way :

Effective time : 2010-10-01

Termination time : 2020-10-01

Evaluation date is June 20, 2011 which will have a settlement date on June 22, 2011. The rates used are :

USDLibor BBA depo rates from ON to 12 months and several swap rates from 2 years to 30 years. The fixed payment frequency is annual and floating is semiannual. The calendar used is TARGET. As shown here the difference is the evaluation date is between the swap’s effective and termination dates. So when I came to construct the VanillaSwap, what should I pass for the effective date parameter for the fixed and floating schedules if the date generation rule is Forward?  If I pass June 22, then the payment dates thus generated will be different from the original schedule. So I pass the original effective date 2010-10-01 as effective date. But with this setting, I got an exception in DiscountingSwapEngine::calculate() when it discounts on each cash flow’s startDate like startDiscounts[i] = discountCurve_->discount(d) because timeFromReference  (referernce date is June 22, 2011) will be negative. So what is this startDiscounts are used for in the first place and what should one setup to evaluate a VanillaSwap on a date between its effective and termonation time. Should one pass as effective date of the schedule the immediate cach flow date that is later than the settlement date (June 22, 2011, this is case)?

 

Jicun


------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: VanillaSwap evaluation between effective andtermination date

YuHong-4
 
Would you have a sample with relevant data?  For many issues with QuantLib, guess can work out the math first, and then check the code.
 
Regards,
 
Hong Yu
 
 
 
Sent: Monday, June 20, 2011 6:42 PM
Subject: [Quantlib-users] VanillaSwap evaluation between effective andtermination date
 

Hi,

I am trying to calculate NPV of a vanilla swap based in the swapvaluation.cpp code.

I have setup the swap the following way :

Effective time : 2010-10-01

Termination time : 2020-10-01

Evaluation date is June 20, 2011 which will have a settlement date on June 22, 2011. The rates used are :

USDLibor BBA depo rates from ON to 12 months and several swap rates from 2 years to 30 years. The fixed payment frequency is annual and floating is semiannual. The calendar used is TARGET. As shown here the difference is the evaluation date is between the swap’s effective and termination dates. So when I came to construct the VanillaSwap, what should I pass for the effective date parameter for the fixed and floating schedules if the date generation rule is Forward?  If I pass June 22, then the payment dates thus generated will be different from the original schedule. So I pass the original effective date 2010-10-01 as effective date. But with this setting, I got an exception in DiscountingSwapEngine::calculate() when it discounts on each cash flow’s startDate like startDiscounts[i] = discountCurve_->discount(d) because timeFromReference  (referernce date is June 22, 2011) will be negative. So what is this startDiscounts are used for in the first place and what should one setup to evaluate a VanillaSwap on a date between its effective and termonation time. Should one pass as effective date of the schedule the immediate cach flow date that is later than the settlement date (June 22, 2011, this is case)?

 

Jicun


------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev


_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users

------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: VanillaSwap evaluation between effective andtermination date

Jicun Zhong

This is so easy to repro. Just add

Date effectiveDate = calendar.advance(settlementDate, -1, Years);

after settlementDate assignment and use it instead of settlementDate in the two Schedule constructors. The modified swapvaluation.cpp attached.

 

jicun

 

 

From: Hong Yu [mailto:[hidden email]]
Sent: den 20 juni 2011 14:39
To: Jicun Zhong
Cc: [hidden email]; Yu Hong
Subject: Re: [Quantlib-users] VanillaSwap evaluation between effective andtermination date

 

 

Would you have a sample with relevant data?  For many issues with QuantLib, guess can work out the math first, and then check the code.

 

Regards,

 

Hong Yu

 

 

 

Sent: Monday, June 20, 2011 6:42 PM

Subject: [Quantlib-users] VanillaSwap evaluation between effective andtermination date

 

Hi,

I am trying to calculate NPV of a vanilla swap based in the swapvaluation.cpp code.

I have setup the swap the following way :

Effective time : 2010-10-01

Termination time : 2020-10-01

Evaluation date is June 20, 2011 which will have a settlement date on June 22, 2011. The rates used are :

USDLibor BBA depo rates from ON to 12 months and several swap rates from 2 years to 30 years. The fixed payment frequency is annual and floating is semiannual. The calendar used is TARGET. As shown here the difference is the evaluation date is between the swap’s effective and termination dates. So when I came to construct the VanillaSwap, what should I pass for the effective date parameter for the fixed and floating schedules if the date generation rule is Forward?  If I pass June 22, then the payment dates thus generated will be different from the original schedule. So I pass the original effective date 2010-10-01 as effective date. But with this setting, I got an exception in DiscountingSwapEngine::calculate() when it discounts on each cash flow’s startDate like startDiscounts[i] = discountCurve_->discount(d) because timeFromReference  (referernce date is June 22, 2011) will be negative. So what is this startDiscounts are used for in the first place and what should one setup to evaluate a VanillaSwap on a date between its effective and termonation time. Should one pass as effective date of the schedule the immediate cach flow date that is later than the settlement date (June 22, 2011, this is case)?

 

Jicun


------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev


_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users


------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users

swapvaluation.cpp (43K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: VanillaSwap evaluation between effective andtermination date

Jicun Zhong
In reply to this post by YuHong-4

Oh, yes, you need to capture C++ exceptions to see the problem. My environment is VS2008 x64 debug. QuantLib is 1.1 and compiled via VS2008.

If you do not capture the C++ exceptions in the VS, then all QL_REQUIRE will just slip away quitely without detection. The reason you see 4 tables normally calculated is because C++ exceptions are not caught and the result of startDiscount calculation in the DiscountingSwapEngine::calculate()  is not used any where. So everything seems to be normal. So this leads to my original question, why do we need to calculate startDiscount in the first place. This startDiscount calcualtion will kill the valuation situation I mentioned at least theoretically. I guess QuantLib have a few such gray/black areas whose reason to exist is faded through history.

 

Jicun

 

 

From: Hong Yu [mailto:[hidden email]]
Sent: den 21 juni 2011 14:43
To: Jicun Zhong
Cc: Yu Hong
Subject: Re: [Quantlib-users] VanillaSwap evaluation between effective andtermination date

 

 

Hello, I have downloaded your attached source, and still I can compile and run with the same 4-table output, including NPV values’ display.  I did such on Ubuntu-Linux-10.04-LTS with the newest QuantLib trunk source.

 

So may I ask about your computing environment?  Linux or Unix or Windows or other operating system?  Which version of QuantLib library you use?  Did you compile QuantLib or install using installer program?  We may again refer to other people in the mailing list for suggestions, if helpful.  Thanks!

 

Regards,

 

Hong Yu

 


------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: VanillaSwap evaluation between effective andtermination date

YuHong-4
 
If it be platform-independent, I am still interested in tracing it on Linux with trunk source.  Also, would you think your example can be further simplified, e.g. from 4 tables to 2 tables or 1 table, and still can reproduce?  Thanks.
 
Regards,
 
Hong Yu
 
 
 
Sent: Tuesday, June 21, 2011 9:21 PM
Subject: RE: [Quantlib-users] VanillaSwap evaluation between effective andtermination date
 

Oh, yes, you need to capture C++ exceptions to see the problem. My environment is VS2008 x64 debug. QuantLib is 1.1 and compiled via VS2008.

If you do not capture the C++ exceptions in the VS, then all QL_REQUIRE will just slip away quitely without detection. The reason you see 4 tables normally calculated is because C++ exceptions are not caught and the result of startDiscount calculation in the DiscountingSwapEngine::calculate()  is not used any where. So everything seems to be normal. So this leads to my original question, why do we need to calculate startDiscount in the first place. This startDiscount calcualtion will kill the valuation situation I mentioned at least theoretically. I guess QuantLib have a few such gray/black areas whose reason to exist is faded through history.

 

Jicun

 

 

From: Hong Yu [mailto:[hidden email]]
Sent: den 21 juni 2011 14:43
To: Jicun Zhong
Cc: Yu Hong
Subject: Re: [Quantlib-users] VanillaSwap evaluation between effective andtermination date

 

 

Hello, I have downloaded your attached source, and still I can compile and run with the same 4-table output, including NPV values’ display.  I did such on Ubuntu-Linux-10.04-LTS with the newest QuantLib trunk source.

 

So may I ask about your computing environment?  Linux or Unix or Windows or other operating system?  Which version of QuantLib library you use?  Did you compile QuantLib or install using installer program?  We may again refer to other people in the mailing list for suggestions, if helpful.  Thanks!

 

Regards,

 

Hong Yu

 


------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: VanillaSwap evaluation between effective andtermination date

Jicun Zhong

It should behave the same. To further simplify, just take out those forward schedules and swaps based on them.

 

jicun

 

From: Hong Yu [mailto:[hidden email]]
Sent: den 21 juni 2011 16:10
To: Jicun Zhong
Cc: [hidden email]; Yu Hong
Subject: Re: [Quantlib-users] VanillaSwap evaluation between effective andtermination date

 

 

If it be platform-independent, I am still interested in tracing it on Linux with trunk source.  Also, would you think your example can be further simplified, e.g. from 4 tables to 2 tables or 1 table, and still can reproduce?  Thanks.

 

Regards,

 

Hong Yu

 

 

 

Sent: Tuesday, June 21, 2011 9:21 PM

Subject: RE: [Quantlib-users] VanillaSwap evaluation between effective andtermination date

 

Oh, yes, you need to capture C++ exceptions to see the problem. My environment is VS2008 x64 debug. QuantLib is 1.1 and compiled via VS2008.

If you do not capture the C++ exceptions in the VS, then all QL_REQUIRE will just slip away quitely without detection. The reason you see 4 tables normally calculated is because C++ exceptions are not caught and the result of startDiscount calculation in the DiscountingSwapEngine::calculate()  is not used any where. So everything seems to be normal. So this leads to my original question, why do we need to calculate startDiscount in the first place. This startDiscount calcualtion will kill the valuation situation I mentioned at least theoretically. I guess QuantLib have a few such gray/black areas whose reason to exist is faded through history.

 

Jicun

 

 

From: Hong Yu [mailto:[hidden email]]
Sent: den 21 juni 2011 14:43
To: Jicun Zhong
Cc: Yu Hong
Subject: Re: [Quantlib-users] VanillaSwap evaluation between effective andtermination date

 

 

Hello, I have downloaded your attached source, and still I can compile and run with the same 4-table output, including NPV values’ display.  I did such on Ubuntu-Linux-10.04-LTS with the newest QuantLib trunk source.

 

So may I ask about your computing environment?  Linux or Unix or Windows or other operating system?  Which version of QuantLib library you use?  Did you compile QuantLib or install using installer program?  We may again refer to other people in the mailing list for suggestions, if helpful.  Thanks!

 

Regards,

 

Hong Yu

 


------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: VanillaSwap evaluation between effective andtermination date

YuHong-4

I further modify your test program to only first table first line "depo-swap", and one QL_REQUIRE() after the line.  And I find that "fairRate" and "s5yQuote" are both of value 4.43%, so their absolute difference is almost 0 and thus less than 1e-8, hence nothing thrown.  Is such no mispricing result what you expected?  

Output of modified test program:
Today: Monday, September 20th, 2004
Settlement date: Wednesday, September 22nd, 2004
====================================================================
5-year market swap-rate = 4.43 %
====================================================================
        5-years swap paying 4.00 %
term structure | net present value | fair spread | fair fixed rate |
--------------------------------------------------------------------
     depo-swap |          19065.88 |     -0.42 % |          4.43 % |
fairRate : 0.0443000000
s5yQuote : 0.0443000000
|fairRate-s5yQuote| : 0.0000000000

Regards,

Hong Yu




From: [hidden email]
To: [hidden email]
CC: [hidden email]
Date: Tue, 21 Jun 2011 16:14:26 +0200
Subject: RE: [Quantlib-users] VanillaSwap evaluation between effective andtermination date

It should behave the same. To further simplify, just take out those forward schedules and swaps based on them.

 

jicun

 

From: Hong Yu [mailto:[hidden email]]
Sent: den 21 juni 2011 16:10
To: Jicun Zhong
Cc: [hidden email]; Yu Hong
Subject: Re: [Quantlib-users] VanillaSwap evaluation between effective andtermination date

 

 

If it be platform-independent, I am still interested in tracing it on Linux with trunk source.  Also, would you think your example can be further simplified, e.g. from 4 tables to 2 tables or 1 table, and still can reproduce?  Thanks.

 

Regards,

 

Hong Yu

 

 

 

Sent: Tuesday, June 21, 2011 9:21 PM

Subject: RE: [Quantlib-users] VanillaSwap evaluation between effective andtermination date

 

Oh, yes, you need to capture C++ exceptions to see the problem. My environment is VS2008 x64 debug. QuantLib is 1.1 and compiled via VS2008.

If you do not capture the C++ exceptions in the VS, then all QL_REQUIRE will just slip away quitely without detection. The reason you see 4 tables normally calculated is because C++ exceptions are not caught and the result of startDiscount calculation in the DiscountingSwapEngine::calculate()  is not used any where. So everything seems to be normal. So this leads to my original question, why do we need to calculate startDiscount in the first place. This startDiscount calcualtion will kill the valuation situation I mentioned at least theoretically. I guess QuantLib have a few such gray/black areas whose reason to exist is faded through history.

 

Jicun

 

 

From: Hong Yu [mailto:[hidden email]]
Sent: den 21 juni 2011 14:43
To: Jicun Zhong
Cc: Yu Hong
Subject: Re: [Quantlib-users] VanillaSwap evaluation between effective andtermination date

 

 

Hello, I have downloaded your attached source, and still I can compile and run with the same 4-table output, including NPV values’ display.  I did such on Ubuntu-Linux-10.04-LTS with the newest QuantLib trunk source.

 

So may I ask about your computing environment?  Linux or Unix or Windows or other operating system?  Which version of QuantLib library you use?  Did you compile QuantLib or install using installer program?  We may again refer to other people in the mailing list for suggestions, if helpful.  Thanks!

 

Regards,

 

Hong Yu

 


------------------------------------------------------------------------------
Simplify data backup and recovery for your virtual environment with vRanger.
Installation's a snap, and flexible recovery options mean your data is safe,
secure and there when you need it. Data protection magic?
Nope - It's vRanger. Get your free trial download today.
http://p.sf.net/sfu/quest-sfdev2dev
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: VanillaSwap evaluation between effective and termination date

Luigi Ballabio
In reply to this post by Jicun Zhong
On Mon, 2011-06-20 at 12:42 +0200, Jicun Zhong wrote:

> Hi,
>
> I am trying to calculate NPV of a vanilla swap based in the
> swapvaluation.cpp code.
>
> I have setup the swap the following way :
>
> Effective time : 2010-10-01
>
> Termination time : 2020-10-01
>
> Evaluation date is June 20, 2011 which will have a settlement date on
> June 22, 2011. The rates used are :
>
> USDLibor BBA depo rates from ON to 12 months and several swap rates
> from 2 years to 30 years. The fixed payment frequency is annual and
> floating is semiannual. The calendar used is TARGET. As shown here the
> difference is the evaluation date is between the swap’s effective and
> termination dates. So when I came to construct the VanillaSwap, what
> should I pass for the effective date parameter for the fixed and
> floating schedules if the date generation rule is Forward?  If I pass
> June 22, then the payment dates thus generated will be different from
> the original schedule. So I pass the original effective date
> 2010-10-01 as effective date. But with this setting, I got an
> exception in DiscountingSwapEngine::calculate() when it discounts on
> each cash flow’s startDate like startDiscounts[i] =
> discountCurve_->discount(d) because timeFromReference  (referernce
> date is June 22, 2011) will be negative. So what is this
> startDiscounts are used for in the first place and what should one
> setup to evaluate a VanillaSwap on a date between its effective and
> termonation time. Should one pass as effective date of the schedule
> the immediate cach flow date that is later than the settlement date
> (June 22, 2011, this is case)?

Jicun,
        your code works correctly on my Ubuntu machine (and yes, I'm catching
exceptions.)   It is to be expected that for some of the
startDiscounts[i] an exception is thrown, but it should be caught and
discarded a few lines later (in the catch (...) clause at line 95 of
discountingswapengine.cpp) and the execution of the code should continue
normally after this.  Are you saying that the exception escapes from the
engine?

Luigi


--

Skinner's Constant (or Flannagan's Finagling Factor):
That quantity which, when multiplied by, divided by, added to,
or subtracted from the answer you got, gives you the answer you
should have gotten.



------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security
threats, fraudulent activity, and more. Splunk takes this data and makes
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2d-c2
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: VanillaSwap evaluation between effective and termination date

Jicun Zhong
No. It only caught my attention when I turned on capture all C++ exceptions. My question is really about why the startDiscounts are implemented there and what is its usage. If it is designed in the way you described, then the effectiveDate parameter for the schedule constructor should be the original effective date of the vanilla IRS not something dependent on the evaluation date right?

Thanks for the reply!

jicun    

-----Original Message-----
From: Luigi Ballabio [mailto:[hidden email]]
Sent: den 29 juni 2011 16:36
To: Jicun Zhong
Cc: [hidden email]
Subject: Re: [Quantlib-users] VanillaSwap evaluation between effective and termination date

On Mon, 2011-06-20 at 12:42 +0200, Jicun Zhong wrote:

> Hi,
>
> I am trying to calculate NPV of a vanilla swap based in the
> swapvaluation.cpp code.
>
> I have setup the swap the following way :
>
> Effective time : 2010-10-01
>
> Termination time : 2020-10-01
>
> Evaluation date is June 20, 2011 which will have a settlement date on
> June 22, 2011. The rates used are :
>
> USDLibor BBA depo rates from ON to 12 months and several swap rates
> from 2 years to 30 years. The fixed payment frequency is annual and
> floating is semiannual. The calendar used is TARGET. As shown here the
> difference is the evaluation date is between the swap’s effective and
> termination dates. So when I came to construct the VanillaSwap, what
> should I pass for the effective date parameter for the fixed and
> floating schedules if the date generation rule is Forward?  If I pass
> June 22, then the payment dates thus generated will be different from
> the original schedule. So I pass the original effective date
> 2010-10-01 as effective date. But with this setting, I got an
> exception in DiscountingSwapEngine::calculate() when it discounts on
> each cash flow’s startDate like startDiscounts[i] =
> discountCurve_->discount(d) because timeFromReference  (referernce
> date is June 22, 2011) will be negative. So what is this
> startDiscounts are used for in the first place and what should one
> setup to evaluate a VanillaSwap on a date between its effective and
> termonation time. Should one pass as effective date of the schedule
> the immediate cach flow date that is later than the settlement date
> (June 22, 2011, this is case)?

Jicun,
        your code works correctly on my Ubuntu machine (and yes, I'm catching
exceptions.)   It is to be expected that for some of the
startDiscounts[i] an exception is thrown, but it should be caught and
discarded a few lines later (in the catch (...) clause at line 95 of
discountingswapengine.cpp) and the execution of the code should continue
normally after this.  Are you saying that the exception escapes from the
engine?

Luigi


--

Skinner's Constant (or Flannagan's Finagling Factor):
That quantity which, when multiplied by, divided by, added to,
or subtracted from the answer you got, gives you the answer you
should have gotten.


------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security
threats, fraudulent activity, and more. Splunk takes this data and makes
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2d-c2
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: VanillaSwap evaluation between effective and termination date

Luigi Ballabio
On Thu, 2011-06-30 at 10:28 +0200, Jicun Zhong wrote:
> No. It only caught my attention when I turned on capture all C++
> exceptions. My question is really about why the startDiscounts are
> implemented there and what is its usage. If it is designed in the way
> you described, then the effectiveDate parameter for the schedule
> constructor should be the original effective date of the vanilla IRS
> not something dependent on the evaluation date right?

Right, it's the original effective date.  The discounts are used in
<ql/instruments/assetswap.cpp>.

Luigi


--

I am extraordinarily patient, provided I get my own way in the end.
-- Margaret Thatcher



------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security
threats, fraudulent activity, and more. Splunk takes this data and makes
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2d-c2
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: VanillaSwap evaluation between effective and termination date

Jicun Zhong
In reply to this post by Luigi Ballabio
Hi Luigi,
    Attached another modified swapvaluation.cpp where if the effective date of the schedules are set with the original IRS effective date will cause an missing past fixing exception and fail the calculation. In such a case, what is the general procedure to provide fixings before call NPV? Obviously this exception depends on the evaluation date. If one passes as effective date of the schedule the immediate cash flow date that is later than the settlement date, then this will not happen. So some explanation is needed here.
   Thanks!

Jicun

-----Original Message-----
From: Luigi Ballabio [mailto:[hidden email]]
Sent: den 29 juni 2011 16:36
To: Jicun Zhong
Cc: [hidden email]
Subject: Re: [Quantlib-users] VanillaSwap evaluation between effective and termination date

On Mon, 2011-06-20 at 12:42 +0200, Jicun Zhong wrote:

> Hi,
>
> I am trying to calculate NPV of a vanilla swap based in the
> swapvaluation.cpp code.
>
> I have setup the swap the following way :
>
> Effective time : 2010-10-01
>
> Termination time : 2020-10-01
>
> Evaluation date is June 20, 2011 which will have a settlement date on
> June 22, 2011. The rates used are :
>
> USDLibor BBA depo rates from ON to 12 months and several swap rates
> from 2 years to 30 years. The fixed payment frequency is annual and
> floating is semiannual. The calendar used is TARGET. As shown here the
> difference is the evaluation date is between the swap’s effective and
> termination dates. So when I came to construct the VanillaSwap, what
> should I pass for the effective date parameter for the fixed and
> floating schedules if the date generation rule is Forward?  If I pass
> June 22, then the payment dates thus generated will be different from
> the original schedule. So I pass the original effective date
> 2010-10-01 as effective date. But with this setting, I got an
> exception in DiscountingSwapEngine::calculate() when it discounts on
> each cash flow’s startDate like startDiscounts[i] =
> discountCurve_->discount(d) because timeFromReference  (referernce
> date is June 22, 2011) will be negative. So what is this
> startDiscounts are used for in the first place and what should one
> setup to evaluate a VanillaSwap on a date between its effective and
> termonation time. Should one pass as effective date of the schedule
> the immediate cach flow date that is later than the settlement date
> (June 22, 2011, this is case)?
Jicun,
        your code works correctly on my Ubuntu machine (and yes, I'm catching
exceptions.)   It is to be expected that for some of the
startDiscounts[i] an exception is thrown, but it should be caught and
discarded a few lines later (in the catch (...) clause at line 95 of
discountingswapengine.cpp) and the execution of the code should continue
normally after this.  Are you saying that the exception escapes from the
engine?

Luigi


--

Skinner's Constant (or Flannagan's Finagling Factor):
That quantity which, when multiplied by, divided by, added to,
or subtracted from the answer you got, gives you the answer you
should have gotten.



------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security
threats, fraudulent activity, and more. Splunk takes this data and makes
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2d-c2
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users

swapvaluation.cpp (43K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: VanillaSwap evaluation between effective and termination date

Luigi Ballabio
On Thu, 2011-06-30 at 11:32 +0200, Jicun Zhong wrote:
> Hi Luigi,
>     Attached another modified swapvaluation.cpp where if the effective
> date of the schedules are set with the original IRS effective date
> will cause an missing past fixing exception and fail the calculation.
> In such a case, what is the general procedure to provide fixings
> before call NPV? Obviously this exception depends on the evaluation
> date. If one passes as effective date of the schedule the immediate
> cash flow date that is later than the settlement date, then this will
> not happen. So some explanation is needed here.

Coupons whose fixing dates are after the evaluation date are forecast on
the term structure passed to the index; for the others, you have to
provide the relevant fixing (since they obviously can't be forecast.)
You can call Index::addFixing on the index instance to store the past
fixings (or on another instance; fixings are shared, so if you call
addFixing, e.g., on a Euribor6M instance, all other instances will see
them.)

Luigi


--

Better to have an approximate answer to the right question than a
precise answer to the wrong question.
-- John Tukey as quoted by John Chambers



------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security
threats, fraudulent activity, and more. Splunk takes this data and makes
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2d-c2
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: VanillaSwap evaluation between effective and termination date

Luigi Ballabio
On Tue, 2011-07-05 at 12:23 +0200, Jicun Zhong wrote:
> Thanks a lot for the analysis. It is much more clear now. However, the
> fact that QuantLib assumes that today's fixing is not available and go
> ahead to forecast it from the curve is a bit scary.

Yes, but that's the only thing you can do in the morning, before the
LIBOR fixing is published.

>  For the current case where the 6Month LIBOR is provided as part of
> the depo rate the difference between forecasted and the provided 6M
> rate won't be large. However if the 6Month depo rate is not provided
> and a linear interpolation is done between 3M and 9M, then there is
> surely error. If I explicitly set in a fixing on Sept 20, 2004, will
> QuantLib use that instead of do its own forecasting?

It will use the one you set explicitly (which is what usually happens in
the afternoon.)

Luigi



--

Grabel's Law:
2 is not equal to 3 -- not even for large values of 2.



------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security
threats, fraudulent activity, and more. Splunk takes this data and makes
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2d-c2
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users