Newby Question

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

Newby Question

Sutcliffe, Anthony
Newby Question

Hello all.

I'm trying to do the following:

To calculate the probability of the value of a swap falling below a given level using the quantlib xl addin. The choice of interest rate model is not that important, as this is just proof of concept, although a term-structure matching version is preferred. I'd also like to be able to display the envelope in which the yield curve will move at a given confidence interval.

I've downloaded the addin and it appears to work, but I'm not sure how to proceed from here. Can anyone give me any pointers?

Thanks very much.

Anthony Sutcliffe
Assistant Vice President
Investment Risk Management
State Street Global Advisors Limited
20 Churchill Place, London E14 5HJ

+44 (0)20 3395 6828 (Direct Line)



------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://p.sf.net/sfu/dev2dev-palm
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Newby Question

animesh
There is a sample given in StandaloneExamples/InterestRateDerivatives.xls file.

Although I am assuming you already have used that file. So regarding calculation of probability I think one of the ways is to model different term-structures, and find the swap values. Calculating the probability then is just a simple division!
In the sheets "Swaps" (Swap value is calculated using the rates in term structures sheet) and "TermStructures", this has been done.
It's been done for a flat forward rate, so a simple solution might be to use a nice macro to change it, and calculate swap values. For more complex term structures you can change this qlFlatForward function and use a different term structure.

Hope this helps.


On 8/2/10 1:00 PM, Sutcliffe, Anthony wrote:
Newby Question

Hello all.

I'm trying to do the following:

To calculate the probability of the value of a swap falling below a given level using the quantlib xl addin. The choice of interest rate model is not that important, as this is just proof of concept, although a term-structure matching version is preferred. I'd also like to be able to display the envelope in which the yield curve will move at a given confidence interval.

I've downloaded the addin and it appears to work, but I'm not sure how to proceed from here. Can anyone give me any pointers?

Thanks very much.

Anthony Sutcliffe
Assistant Vice President
Investment Risk Management
State Street Global Advisors Limited
20 Churchill Place, London E14 5HJ

+44 (0)20 3395 6828 (Direct Line)


------------------------------------------------------------------------------ The Palm PDK Hot Apps Program offers developers who use the Plug-In Development Kit to bring their C/C++ apps to Palm for a share of $1 Million in cash or HP Products. Visit us here for more details: http://p.sf.net/sfu/dev2dev-palm
_______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users

-- 
Regards,
Animesh Saxena

(http://quantanalysis.wordpress.com)

------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://p.sf.net/sfu/dev2dev-palm
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Newby Question

Sutcliffe, Anthony
Thanks Animesh.
 
Forgive me for being a little dense (I can't help it), but I'm not quite sure I follow.
 
I can see the term structure and swap example in the example sheet, and I hope I'll be able to manufacture a more complex term structure using a different function (there's a good example of this in the other example sheet). But I'm not sure how modelling the term structure a number of times will reveal the probability of different term structures occurring. Am I missing something obvious?
 
I was expecting to use qlHullWhite, or something similar to model the evolution of the term structure up to some future date, and then revalue the swap on that future date.
 
Alternatively, I wondered if there was a function that allowed the calcuation of the probability of exercise for a swaption, that way I could set up a swaption with an exercise price equal to the one I'm interested in.
 
Have I completely missed the point?
 

Anthony Sutcliffe
Assistant Vice President
Investment Risk Management

State Street Global Advisors Limited
20 Churchill Place, London E14 5HJ

+44 (0)20 3395 6828 (Direct Line)

 

 


From: animesh saxena [mailto:[hidden email]]
Sent: 02 August 2010 10:10
To: Sutcliffe, Anthony
Cc: [hidden email]
Subject: Re: [Quantlib-users] Newby Question

There is a sample given in StandaloneExamples/InterestRateDerivatives.xls file.

Although I am assuming you already have used that file. So regarding calculation of probability I think one of the ways is to model different term-structures, and find the swap values. Calculating the probability then is just a simple division!
In the sheets "Swaps" (Swap value is calculated using the rates in term structures sheet) and "TermStructures", this has been done.
It's been done for a flat forward rate, so a simple solution might be to use a nice macro to change it, and calculate swap values. For more complex term structures you can change this qlFlatForward function and use a different term structure.

Hope this helps.


On 8/2/10 1:00 PM, Sutcliffe, Anthony wrote:

Hello all.

I'm trying to do the following:

To calculate the probability of the value of a swap falling below a given level using the quantlib xl addin. The choice of interest rate model is not that important, as this is just proof of concept, although a term-structure matching version is preferred. I'd also like to be able to display the envelope in which the yield curve will move at a given confidence interval.

I've downloaded the addin and it appears to work, but I'm not sure how to proceed from here. Can anyone give me any pointers?

Thanks very much.

Anthony Sutcliffe
Assistant Vice President
Investment Risk Management
State Street Global Advisors Limited
20 Churchill Place, London E14 5HJ

+44 (0)20 3395 6828 (Direct Line)


------------------------------------------------------------------------------ The Palm PDK Hot Apps Program offers developers who use the Plug-In Development Kit to bring their C/C++ apps to Palm for a share of $1 Million in cash or HP Products. Visit us here for more details: http://p.sf.net/sfu/dev2dev-palm
_______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users

-- 
Regards,
Animesh Saxena

(http://quantanalysis.wordpress.com)

------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://p.sf.net/sfu/dev2dev-palm
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Newby Question

animesh
I had assumed a simple vanilla swap priced using a term structure.

Considering a plain vanilla swap. When you are say that you want to "calculate probability of vanilla swap falling below a given value", then this has to be under different interest rates. So mathematically for all possible (although it's lots of computation)  interest rates your swap will take different values and probability will be

Number of cases in which it ends below your pre-specified value / Total number of cases.

Although easy to say but again problem is modeling all these interest rate scenarios (BGM Framework etc). I am not sure if this is your problem or you are thinking of some other approach for calculating probability.

qlHullWhite model might be good, but choosing the parameters is messy. But if you have the calibrated parameters might work. Even if you consider hull white model the equation ( theta(t) - alpha(t) r(t) ) dt + sigma(t) dW (t) will give different values for number of simulations. So each time you do a simulation and calculate the swap value you will get a different value. If you use this to calculate probability (N simulations) then again it all comes down to the calibrated parameters.

I am not sure if there is any inbuilt function for calculating probability. A quantlib developer might know better.
Anyway am also not sure if I missed something obvious in the problem you mentioned!


On 8/2/10 3:17 PM, Sutcliffe, Anthony wrote:
Thanks Animesh.
 
Forgive me for being a little dense (I can't help it), but I'm not quite sure I follow.
 
I can see the term structure and swap example in the example sheet, and I hope I'll be able to manufacture a more complex term structure using a different function (there's a good example of this in the other example sheet). But I'm not sure how modelling the term structure a number of times will reveal the probability of different term structures occurring. Am I missing something obvious?
 
I was expecting to use qlHullWhite, or something similar to model the evolution of the term structure up to some future date, and then revalue the swap on that future date.
 
Alternatively, I wondered if there was a function that allowed the calcuation of the probability of exercise for a swaption, that way I could set up a swaption with an exercise price equal to the one I'm interested in.
 
Have I completely missed the point?
 

Anthony Sutcliffe
Assistant Vice President
Investment Risk Management

State Street Global Advisors Limited
20 Churchill Place, London E14 5HJ

+44 (0)20 3395 6828 (Direct Line)

 

 


From: animesh saxena [[hidden email]]
Sent: 02 August 2010 10:10
To: Sutcliffe, Anthony
Cc: [hidden email]
Subject: Re: [Quantlib-users] Newby Question

There is a sample given in StandaloneExamples/InterestRateDerivatives.xls file.

Although I am assuming you already have used that file. So regarding calculation of probability I think one of the ways is to model different term-structures, and find the swap values. Calculating the probability then is just a simple division!
In the sheets "Swaps" (Swap value is calculated using the rates in term structures sheet) and "TermStructures", this has been done.
It's been done for a flat forward rate, so a simple solution might be to use a nice macro to change it, and calculate swap values. For more complex term structures you can change this qlFlatForward function and use a different term structure.

Hope this helps.


On 8/2/10 1:00 PM, Sutcliffe, Anthony wrote:

Hello all.

I'm trying to do the following:

To calculate the probability of the value of a swap falling below a given level using the quantlib xl addin. The choice of interest rate model is not that important, as this is just proof of concept, although a term-structure matching version is preferred. I'd also like to be able to display the envelope in which the yield curve will move at a given confidence interval.

I've downloaded the addin and it appears to work, but I'm not sure how to proceed from here. Can anyone give me any pointers?

Thanks very much.

Anthony Sutcliffe
Assistant Vice President
Investment Risk Management
State Street Global Advisors Limited
20 Churchill Place, London E14 5HJ

+44 (0)20 3395 6828 (Direct Line)


------------------------------------------------------------------------------ The Palm PDK Hot Apps Program offers developers who use the Plug-In Development Kit to bring their C/C++ apps to Palm for a share of $1 Million in cash or HP Products. Visit us here for more details: http://p.sf.net/sfu/dev2dev-palm
_______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users

-- 
Regards,
Animesh Saxena

(http://quantanalysis.wordpress.com)

-- 
Regards,
Animesh Saxena

(http://quantanalysis.wordpress.com)

------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://p.sf.net/sfu/dev2dev-palm
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Newby Question

Sutcliffe, Anthony
Thanks again Animesh.
 
So you are essentially suggesting a Monte Carlo type approach? I'm very open to that, just not sure how to implement that either (in quantlib - but keen to avoid reinventing the wheel when quantlib provides a high quality alternative). I've literally just found quantlib so these things are all very much a mystery to me. I think you have got my problem nailed, it's not a complicated problem but as you say the swap value can be achieved by any number of different term structures so maybe a Monte Carlo approach is best.
 
Can I use QuantLibXL to generate a termstructure on a future date? Then as you suggest I could just revalue the swap (right?).
 
I'm also a little foxed by how one gets information out of a handle once it's been created. I used to work with a system called GDA at Merrill Lynch which was similar in that you would create an object from an excel front end, and the quant library would return a handle. But GDA also provided a function called "gdaapply" where you could provide the handle and the name of the field you were after and the value of that field would be returned. Is there something similar in QuantLib.
 
Thanks very much for all your help!
 

Anthony Sutcliffe
Assistant Vice President
Investment Risk Management

State Street Global Advisors Limited
20 Churchill Place, London E14 5HJ

+44 (0)20 3395 6828 (Direct Line)

 

 


From: animesh saxena [mailto:[hidden email]]
Sent: 02 August 2010 11:26
To: Sutcliffe, Anthony
Cc: [hidden email]
Subject: Re: [Quantlib-users] Newby Question

I had assumed a simple vanilla swap priced using a term structure.

Considering a plain vanilla swap. When you are say that you want to "calculate probability of vanilla swap falling below a given value", then this has to be under different interest rates. So mathematically for all possible (although it's lots of computation)  interest rates your swap will take different values and probability will be

Number of cases in which it ends below your pre-specified value / Total number of cases.

Although easy to say but again problem is modeling all these interest rate scenarios (BGM Framework etc). I am not sure if this is your problem or you are thinking of some other approach for calculating probability.

qlHullWhite model might be good, but choosing the parameters is messy. But if you have the calibrated parameters might work. Even if you consider hull white model the equation ( theta(t) - alpha(t) r(t) ) dt + sigma(t) dW (t) will give different values for number of simulations. So each time you do a simulation and calculate the swap value you will get a different value. If you use this to calculate probability (N simulations) then again it all comes down to the calibrated parameters.

I am not sure if there is any inbuilt function for calculating probability. A quantlib developer might know better.
Anyway am also not sure if I missed something obvious in the problem you mentioned!


On 8/2/10 3:17 PM, Sutcliffe, Anthony wrote:
Thanks Animesh.
 
Forgive me for being a little dense (I can't help it), but I'm not quite sure I follow.
 
I can see the term structure and swap example in the example sheet, and I hope I'll be able to manufacture a more complex term structure using a different function (there's a good example of this in the other example sheet). But I'm not sure how modelling the term structure a number of times will reveal the probability of different term structures occurring. Am I missing something obvious?
 
I was expecting to use qlHullWhite, or something similar to model the evolution of the term structure up to some future date, and then revalue the swap on that future date.
 
Alternatively, I wondered if there was a function that allowed the calcuation of the probability of exercise for a swaption, that way I could set up a swaption with an exercise price equal to the one I'm interested in.
 
Have I completely missed the point?
 

Anthony Sutcliffe
Assistant Vice President
Investment Risk Management

State Street Global Advisors Limited
20 Churchill Place, London E14 5HJ

+44 (0)20 3395 6828 (Direct Line)

 


From: animesh saxena [[hidden email]]
Sent: 02 August 2010 10:10
To: Sutcliffe, Anthony
Cc: [hidden email]
Subject: Re: [Quantlib-users] Newby Question

There is a sample given in StandaloneExamples/InterestRateDerivatives.xls file.

Although I am assuming you already have used that file. So regarding calculation of probability I think one of the ways is to model different term-structures, and find the swap values. Calculating the probability then is just a simple division!
In the sheets "Swaps" (Swap value is calculated using the rates in term structures sheet) and "TermStructures", this has been done.
It's been done for a flat forward rate, so a simple solution might be to use a nice macro to change it, and calculate swap values. For more complex term structures you can change this qlFlatForward function and use a different term structure.

Hope this helps.


On 8/2/10 1:00 PM, Sutcliffe, Anthony wrote:

Hello all.

I'm trying to do the following:

To calculate the probability of the value of a swap falling below a given level using the quantlib xl addin. The choice of interest rate model is not that important, as this is just proof of concept, although a term-structure matching version is preferred. I'd also like to be able to display the envelope in which the yield curve will move at a given confidence interval.

I've downloaded the addin and it appears to work, but I'm not sure how to proceed from here. Can anyone give me any pointers?

Thanks very much.

Anthony Sutcliffe
Assistant Vice President
Investment Risk Management
State Street Global Advisors Limited
20 Churchill Place, London E14 5HJ

+44 (0)20 3395 6828 (Direct Line)


------------------------------------------------------------------------------ The Palm PDK Hot Apps Program offers developers who use the Plug-In Development Kit to bring their C/C++ apps to Palm for a share of $1 Million in cash or HP Products. Visit us here for more details: http://p.sf.net/sfu/dev2dev-palm
_______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users

-- 
Regards,
Animesh Saxena

(http://quantanalysis.wordpress.com)

-- 
Regards,
Animesh Saxena

(http://quantanalysis.wordpress.com)

------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://p.sf.net/sfu/dev2dev-palm
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Newby Question

animesh
Can I use QuantLibXL to generate a termstructure on a future date? Then as you suggest I could just revalue the swap (right?).

Yes that's correct. There are two options for generating term structure on future date. One is using Quantllib which has some functions like qlMarketModelInitialRates etc, but am not sure how they work in excel. I mostly use C++ for quantlib.

Another option is using simple Heath Jarrow Morton Framework in excel. I had sent an excel implementation sometime back, to this mailing list. It was a very simple 2 factor model for generating forward rates. It can easily be modified for n factors. downside of using this is you have to do a PCA (principal component analysis) for your data to figure out the factor values. But I prefer HJM to quantlib coz it allows a cleaner approach and at least I know what is actually happening in the simulations. Each time you refresh the sheet it generates a different set of rates. Let me know if you need the HJM implmentation.

On 8/2/10 5:21 PM, Sutcliffe, Anthony wrote:
Thanks again Animesh.
 
So you are essentially suggesting a Monte Carlo type approach? I'm very open to that, just not sure how to implement that either (in quantlib - but keen to avoid reinventing the wheel when quantlib provides a high quality alternative). I've literally just found quantlib so these things are all very much a mystery to me. I think you have got my problem nailed, it's not a complicated problem but as you say the swap value can be achieved by any number of different term structures so maybe a Monte Carlo approach is best.
 
Can I use QuantLibXL to generate a termstructure on a future date? Then as you suggest I could just revalue the swap (right?).
 
I'm also a little foxed by how one gets information out of a handle once it's been created. I used to work with a system called GDA at Merrill Lynch which was similar in that you would create an object from an excel front end, and the quant library would return a handle. But GDA also provided a function called "gdaapply" where you could provide the handle and the name of the field you were after and the value of that field would be returned. Is there something similar in QuantLib.
 
Thanks very much for all your help!
 

Anthony Sutcliffe
Assistant Vice President
Investment Risk Management

State Street Global Advisors Limited
20 Churchill Place, London E14 5HJ

+44 (0)20 3395 6828 (Direct Line)

 

 


From: animesh saxena [[hidden email]]
Sent: 02 August 2010 11:26
To: Sutcliffe, Anthony
Cc: [hidden email]
Subject: Re: [Quantlib-users] Newby Question

I had assumed a simple vanilla swap priced using a term structure.

Considering a plain vanilla swap. When you are say that you want to "calculate probability of vanilla swap falling below a given value", then this has to be under different interest rates. So mathematically for all possible (although it's lots of computation)  interest rates your swap will take different values and probability will be

Number of cases in which it ends below your pre-specified value / Total number of cases.

Although easy to say but again problem is modeling all these interest rate scenarios (BGM Framework etc). I am not sure if this is your problem or you are thinking of some other approach for calculating probability.

qlHullWhite model might be good, but choosing the parameters is messy. But if you have the calibrated parameters might work. Even if you consider hull white model the equation ( theta(t) - alpha(t) r(t) ) dt + sigma(t) dW (t) will give different values for number of simulations. So each time you do a simulation and calculate the swap value you will get a different value. If you use this to calculate probability (N simulations) then again it all comes down to the calibrated parameters.

I am not sure if there is any inbuilt function for calculating probability. A quantlib developer might know better.
Anyway am also not sure if I missed something obvious in the problem you mentioned!


On 8/2/10 3:17 PM, Sutcliffe, Anthony wrote:
Thanks Animesh.
 
Forgive me for being a little dense (I can't help it), but I'm not quite sure I follow.
 
I can see the term structure and swap example in the example sheet, and I hope I'll be able to manufacture a more complex term structure using a different function (there's a good example of this in the other example sheet). But I'm not sure how modelling the term structure a number of times will reveal the probability of different term structures occurring. Am I missing something obvious?
 
I was expecting to use qlHullWhite, or something similar to model the evolution of the term structure up to some future date, and then revalue the swap on that future date.
 
Alternatively, I wondered if there was a function that allowed the calcuation of the probability of exercise for a swaption, that way I could set up a swaption with an exercise price equal to the one I'm interested in.
 
Have I completely missed the point?
 

Anthony Sutcliffe
Assistant Vice President
Investment Risk Management

State Street Global Advisors Limited
20 Churchill Place, London E14 5HJ

+44 (0)20 3395 6828 (Direct Line)

 


From: animesh saxena [[hidden email]]
Sent: 02 August 2010 10:10
To: Sutcliffe, Anthony
Cc: [hidden email]
Subject: Re: [Quantlib-users] Newby Question

There is a sample given in StandaloneExamples/InterestRateDerivatives.xls file.

Although I am assuming you already have used that file. So regarding calculation of probability I think one of the ways is to model different term-structures, and find the swap values. Calculating the probability then is just a simple division!
In the sheets "Swaps" (Swap value is calculated using the rates in term structures sheet) and "TermStructures", this has been done.
It's been done for a flat forward rate, so a simple solution might be to use a nice macro to change it, and calculate swap values. For more complex term structures you can change this qlFlatForward function and use a different term structure.

Hope this helps.


On 8/2/10 1:00 PM, Sutcliffe, Anthony wrote:

Hello all.

I'm trying to do the following:

To calculate the probability of the value of a swap falling below a given level using the quantlib xl addin. The choice of interest rate model is not that important, as this is just proof of concept, although a term-structure matching version is preferred. I'd also like to be able to display the envelope in which the yield curve will move at a given confidence interval.

I've downloaded the addin and it appears to work, but I'm not sure how to proceed from here. Can anyone give me any pointers?

Thanks very much.

Anthony Sutcliffe
Assistant Vice President
Investment Risk Management
State Street Global Advisors Limited
20 Churchill Place, London E14 5HJ

+44 (0)20 3395 6828 (Direct Line)


------------------------------------------------------------------------------ The Palm PDK Hot Apps Program offers developers who use the Plug-In Development Kit to bring their C/C++ apps to Palm for a share of $1 Million in cash or HP Products. Visit us here for more details: http://p.sf.net/sfu/dev2dev-palm
_______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users

-- 
Regards,
Animesh Saxena

(http://quantanalysis.wordpress.com)

-- 
Regards,
Animesh Saxena

(http://quantanalysis.wordpress.com)

-- 
Regards,
Animesh Saxena

(http://quantanalysis.wordpress.com)

------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://p.sf.net/sfu/dev2dev-palm
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Newby Question

animesh
I'm also a little foxed by how one gets information out of a handle once it's been created. I used to work with a system called GDA at Merrill Lynch which was similar in that you would create an object from an excel front end, and the quant library would return a handle. But GDA also provided a function called "gdaapply" where you could provide the handle and the name of the field you were after and the value of that field would be returned. Is there something similar in QuantLib.


I don't think quantlib is that generic! You have to read the documentation of the function to figure out which one's accept the objectId. For example qlSwapLegAnalysis() accepts the object Id and Leg number and returns all the information.



On 8/2/10 5:52 PM, animesh saxena wrote:
Can I use QuantLibXL to generate a termstructure on a future date? Then as you suggest I could just revalue the swap (right?).

Yes that's correct. There are two options for generating term structure on future date. One is using Quantllib which has some functions like qlMarketModelInitialRates etc, but am not sure how they work in excel. I mostly use C++ for quantlib.

Another option is using simple Heath Jarrow Morton Framework in excel. I had sent an excel implementation sometime back, to this mailing list. It was a very simple 2 factor model for generating forward rates. It can easily be modified for n factors. downside of using this is you have to do a PCA (principal component analysis) for your data to figure out the factor values. But I prefer HJM to quantlib coz it allows a cleaner approach and at least I know what is actually happening in the simulations. Each time you refresh the sheet it generates a different set of rates. Let me know if you need the HJM implmentation.

On 8/2/10 5:21 PM, Sutcliffe, Anthony wrote:
Thanks again Animesh.
 
So you are essentially suggesting a Monte Carlo type approach? I'm very open to that, just not sure how to implement that either (in quantlib - but keen to avoid reinventing the wheel when quantlib provides a high quality alternative). I've literally just found quantlib so these things are all very much a mystery to me. I think you have got my problem nailed, it's not a complicated problem but as you say the swap value can be achieved by any number of different term structures so maybe a Monte Carlo approach is best.
 
Can I use QuantLibXL to generate a termstructure on a future date? Then as you suggest I could just revalue the swap (right?).
 
I'm also a little foxed by how one gets information out of a handle once it's been created. I used to work with a system called GDA at Merrill Lynch which was similar in that you would create an object from an excel front end, and the quant library would return a handle. But GDA also provided a function called "gdaapply" where you could provide the handle and the name of the field you were after and the value of that field would be returned. Is there something similar in QuantLib.
 
Thanks very much for all your help!
 

Anthony Sutcliffe
Assistant Vice President
Investment Risk Management

State Street Global Advisors Limited
20 Churchill Place, London E14 5HJ

+44 (0)20 3395 6828 (Direct Line)

 

 


From: animesh saxena [[hidden email]]
Sent: 02 August 2010 11:26
To: Sutcliffe, Anthony
Cc: [hidden email]
Subject: Re: [Quantlib-users] Newby Question

I had assumed a simple vanilla swap priced using a term structure.

Considering a plain vanilla swap. When you are say that you want to "calculate probability of vanilla swap falling below a given value", then this has to be under different interest rates. So mathematically for all possible (although it's lots of computation)  interest rates your swap will take different values and probability will be

Number of cases in which it ends below your pre-specified value / Total number of cases.

Although easy to say but again problem is modeling all these interest rate scenarios (BGM Framework etc). I am not sure if this is your problem or you are thinking of some other approach for calculating probability.

qlHullWhite model might be good, but choosing the parameters is messy. But if you have the calibrated parameters might work. Even if you consider hull white model the equation ( theta(t) - alpha(t) r(t) ) dt + sigma(t) dW (t) will give different values for number of simulations. So each time you do a simulation and calculate the swap value you will get a different value. If you use this to calculate probability (N simulations) then again it all comes down to the calibrated parameters.

I am not sure if there is any inbuilt function for calculating probability. A quantlib developer might know better.
Anyway am also not sure if I missed something obvious in the problem you mentioned!


On 8/2/10 3:17 PM, Sutcliffe, Anthony wrote:
Thanks Animesh.
 
Forgive me for being a little dense (I can't help it), but I'm not quite sure I follow.
 
I can see the term structure and swap example in the example sheet, and I hope I'll be able to manufacture a more complex term structure using a different function (there's a good example of this in the other example sheet). But I'm not sure how modelling the term structure a number of times will reveal the probability of different term structures occurring. Am I missing something obvious?
 
I was expecting to use qlHullWhite, or something similar to model the evolution of the term structure up to some future date, and then revalue the swap on that future date.
 
Alternatively, I wondered if there was a function that allowed the calcuation of the probability of exercise for a swaption, that way I could set up a swaption with an exercise price equal to the one I'm interested in.
 
Have I completely missed the point?
 

Anthony Sutcliffe
Assistant Vice President
Investment Risk Management

State Street Global Advisors Limited
20 Churchill Place, London E14 5HJ

+44 (0)20 3395 6828 (Direct Line)

 


From: animesh saxena [[hidden email]]
Sent: 02 August 2010 10:10
To: Sutcliffe, Anthony
Cc: [hidden email]
Subject: Re: [Quantlib-users] Newby Question

There is a sample given in StandaloneExamples/InterestRateDerivatives.xls file.

Although I am assuming you already have used that file. So regarding calculation of probability I think one of the ways is to model different term-structures, and find the swap values. Calculating the probability then is just a simple division!
In the sheets "Swaps" (Swap value is calculated using the rates in term structures sheet) and "TermStructures", this has been done.
It's been done for a flat forward rate, so a simple solution might be to use a nice macro to change it, and calculate swap values. For more complex term structures you can change this qlFlatForward function and use a different term structure.

Hope this helps.


On 8/2/10 1:00 PM, Sutcliffe, Anthony wrote:

Hello all.

I'm trying to do the following:

To calculate the probability of the value of a swap falling below a given level using the quantlib xl addin. The choice of interest rate model is not that important, as this is just proof of concept, although a term-structure matching version is preferred. I'd also like to be able to display the envelope in which the yield curve will move at a given confidence interval.

I've downloaded the addin and it appears to work, but I'm not sure how to proceed from here. Can anyone give me any pointers?

Thanks very much.

Anthony Sutcliffe
Assistant Vice President
Investment Risk Management
State Street Global Advisors Limited
20 Churchill Place, London E14 5HJ

+44 (0)20 3395 6828 (Direct Line)


------------------------------------------------------------------------------ The Palm PDK Hot Apps Program offers developers who use the Plug-In Development Kit to bring their C/C++ apps to Palm for a share of $1 Million in cash or HP Products. Visit us here for more details: http://p.sf.net/sfu/dev2dev-palm
_______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users

-- 
Regards,
Animesh Saxena

(http://quantanalysis.wordpress.com)

-- 
Regards,
Animesh Saxena

(http://quantanalysis.wordpress.com)

-- 
Regards,
Animesh Saxena

(http://quantanalysis.wordpress.com)

-- 
Regards,
Animesh Saxena

(http://quantanalysis.wordpress.com)

------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://p.sf.net/sfu/dev2dev-palm
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Newby Question

Sutcliffe, Anthony
In reply to this post by animesh
You really are very generous! So in that case, qlMarketModelInitialRates how would you use it in C++? I'll see if I can draw some kind of analogy in Excel (there is a function with the same name in QuantLibXL).
 
Plus, if you are willing to provide it, your HJM implementation would be super helpful.
 
Thanks again!

Anthony Sutcliffe
Assistant Vice President
Investment Risk Management

State Street Global Advisors Limited
20 Churchill Place, London E14 5HJ

+44 (0)20 3395 6828 (Direct Line)

 

 


From: animesh saxena [mailto:[hidden email]]
Sent: 02 August 2010 13:22
To: Sutcliffe, Anthony
Cc: [hidden email]
Subject: Re: [Quantlib-users] Newby Question

Can I use QuantLibXL to generate a termstructure on a future date? Then as you suggest I could just revalue the swap (right?).

Yes that's correct. There are two options for generating term structure on future date. One is using Quantllib which has some functions like qlMarketModelInitialRates etc, but am not sure how they work in excel. I mostly use C++ for quantlib.

Another option is using simple Heath Jarrow Morton Framework in excel. I had sent an excel implementation sometime back, to this mailing list. It was a very simple 2 factor model for generating forward rates. It can easily be modified for n factors. downside of using this is you have to do a PCA (principal component analysis) for your data to figure out the factor values. But I prefer HJM to quantlib coz it allows a cleaner approach and at least I know what is actually happening in the simulations. Each time you refresh the sheet it generates a different set of rates. Let me know if you need the HJM implmentation.

On 8/2/10 5:21 PM, Sutcliffe, Anthony wrote:
Thanks again Animesh.
 
So you are essentially suggesting a Monte Carlo type approach? I'm very open to that, just not sure how to implement that either (in quantlib - but keen to avoid reinventing the wheel when quantlib provides a high quality alternative). I've literally just found quantlib so these things are all very much a mystery to me. I think you have got my problem nailed, it's not a complicated problem but as you say the swap value can be achieved by any number of different term structures so maybe a Monte Carlo approach is best.
 
Can I use QuantLibXL to generate a termstructure on a future date? Then as you suggest I could just revalue the swap (right?).
 
I'm also a little foxed by how one gets information out of a handle once it's been created. I used to work with a system called GDA at Merrill Lynch which was similar in that you would create an object from an excel front end, and the quant library would return a handle. But GDA also provided a function called "gdaapply" where you could provide the handle and the name of the field you were after and the value of that field would be returned. Is there something similar in QuantLib.
 
Thanks very much for all your help!
 

Anthony Sutcliffe
Assistant Vice President
Investment Risk Management

State Street Global Advisors Limited
20 Churchill Place, London E14 5HJ

+44 (0)20 3395 6828 (Direct Line)

 


From: animesh saxena [[hidden email]]
Sent: 02 August 2010 11:26
To: Sutcliffe, Anthony
Cc: [hidden email]
Subject: Re: [Quantlib-users] Newby Question

I had assumed a simple vanilla swap priced using a term structure.

Considering a plain vanilla swap. When you are say that you want to "calculate probability of vanilla swap falling below a given value", then this has to be under different interest rates. So mathematically for all possible (although it's lots of computation)  interest rates your swap will take different values and probability will be

Number of cases in which it ends below your pre-specified value / Total number of cases.

Although easy to say but again problem is modeling all these interest rate scenarios (BGM Framework etc). I am not sure if this is your problem or you are thinking of some other approach for calculating probability.

qlHullWhite model might be good, but choosing the parameters is messy. But if you have the calibrated parameters might work. Even if you consider hull white model the equation ( theta(t) - alpha(t) r(t) ) dt + sigma(t) dW (t) will give different values for number of simulations. So each time you do a simulation and calculate the swap value you will get a different value. If you use this to calculate probability (N simulations) then again it all comes down to the calibrated parameters.

I am not sure if there is any inbuilt function for calculating probability. A quantlib developer might know better.
Anyway am also not sure if I missed something obvious in the problem you mentioned!


On 8/2/10 3:17 PM, Sutcliffe, Anthony wrote:
Thanks Animesh.
 
Forgive me for being a little dense (I can't help it), but I'm not quite sure I follow.
 
I can see the term structure and swap example in the example sheet, and I hope I'll be able to manufacture a more complex term structure using a different function (there's a good example of this in the other example sheet). But I'm not sure how modelling the term structure a number of times will reveal the probability of different term structures occurring. Am I missing something obvious?
 
I was expecting to use qlHullWhite, or something similar to model the evolution of the term structure up to some future date, and then revalue the swap on that future date.
 
Alternatively, I wondered if there was a function that allowed the calcuation of the probability of exercise for a swaption, that way I could set up a swaption with an exercise price equal to the one I'm interested in.
 
Have I completely missed the point?
 

Anthony Sutcliffe
Assistant Vice President
Investment Risk Management

State Street Global Advisors Limited
20 Churchill Place, London E14 5HJ

+44 (0)20 3395 6828 (Direct Line)

 


From: animesh saxena [[hidden email]]
Sent: 02 August 2010 10:10
To: Sutcliffe, Anthony
Cc: [hidden email]
Subject: Re: [Quantlib-users] Newby Question

There is a sample given in StandaloneExamples/InterestRateDerivatives.xls file.

Although I am assuming you already have used that file. So regarding calculation of probability I think one of the ways is to model different term-structures, and find the swap values. Calculating the probability then is just a simple division!
In the sheets "Swaps" (Swap value is calculated using the rates in term structures sheet) and "TermStructures", this has been done.
It's been done for a flat forward rate, so a simple solution might be to use a nice macro to change it, and calculate swap values. For more complex term structures you can change this qlFlatForward function and use a different term structure.

Hope this helps.


On 8/2/10 1:00 PM, Sutcliffe, Anthony wrote:

Hello all.

I'm trying to do the following:

To calculate the probability of the value of a swap falling below a given level using the quantlib xl addin. The choice of interest rate model is not that important, as this is just proof of concept, although a term-structure matching version is preferred. I'd also like to be able to display the envelope in which the yield curve will move at a given confidence interval.

I've downloaded the addin and it appears to work, but I'm not sure how to proceed from here. Can anyone give me any pointers?

Thanks very much.

Anthony Sutcliffe
Assistant Vice President
Investment Risk Management
State Street Global Advisors Limited
20 Churchill Place, London E14 5HJ

+44 (0)20 3395 6828 (Direct Line)


------------------------------------------------------------------------------ The Palm PDK Hot Apps Program offers developers who use the Plug-In Development Kit to bring their C/C++ apps to Palm for a share of $1 Million in cash or HP Products. Visit us here for more details: http://p.sf.net/sfu/dev2dev-palm
_______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users

-- 
Regards,
Animesh Saxena

(http://quantanalysis.wordpress.com)

-- 
Regards,
Animesh Saxena

(http://quantanalysis.wordpress.com)

-- 
Regards,
Animesh Saxena

(http://quantanalysis.wordpress.com)

------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://p.sf.net/sfu/dev2dev-palm
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users