Markov Functional Model

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

Markov Functional Model

Peter Caspers-4
Hi,

I implemented a Markov functional model which I would like to contribute
to the lib. I would consider the development to be something like an
alpha version.

The model is an one factor interest rate model with a non parametric
numeraire that can be fitted to a set of (arbitrage free) smiles on an
option expiry grid. In addition a volatility function can be used to
calibrate to a second instrument set (but only for one strike per
expiry). An example would be a numeraire calibration to constant
maturity swaption smiles which allows to recover market cms coupon
prices. As a second instrument set atm coterminal swaptions can be
chosen. The resulting model is then a good candidate for pricing
callable cms swaps. The mean reversion parameter in the model is fixed,
i.e. it can not be calibrated, but must be given externally. It can be
used to control intertemporal correlations. References can be found in
the documentation mentioned below.

The package comes with the model, an implementation of Kahale's method
for arbitrage free smile extrapolation (because arbitrage free smile
input is essential for the numeraire to calibrate) and vanilla pricing
engines for caps and swaptions. The swaption engine can also handle
bermudan exercise rights. At the moment all engines are based on
numerical integration. PDE engines and more product support will follow
soon.

You can find the code on github. I updated only the project files for
msvc10, but it should be easy to include the relevant files in other
enviroments. They are located in ql/experimental/models/markovfunctional.

https://github.com/pcaspers/quantlib/commit/879c0fdd4f4149facdc8e771d838acafa7d6aae9

A good starting point is probably running the test-suite to which I
added a suite for the mf model which can be found in
test-suite/markovfunctional.xpp.

There are some changes in the ql I made, some essential for the model to
work, others which I found worthwhile to do in the context and which
support the test cases to run smoothly. I posted some of these changes
on this list in the past, but I summarize all of them at the end of this
mail.

Any feedback is highly appreciated. There is also some documentation
available here

http://papers.ssrn.com/sol3/papers.cfm?abstract_id=2183721

Thank you and kind regards
Peter


Changes to the lib I made:

1 ql/math/cubicinterpolation.hpp

essential for mf model, I added the Lagrange boundary condition. I
tested against the MatLab implementation. Works fine.


2 ql/math/sabrinterpolation.hpp

not essential for mf model, but necessary for the test suite to run.

I use a derivative of swaptionvolcube1 for daily swaption smile
calibration for quite a time now. I noticed that two problems occur from
time to time: First, calibration is not satisfactory because of unlucky
start values. The solution for this I implemented is not very smart, but
it is working well and is still fast enough. Secondly (very rarely)
calibration stops with error values. I located the problem to be the
transformation of valid parameters to numeric error values during
optimization. Fix is very easy.

More specifically I added a try and error method for calibration. Up to
maxGuesses start values for the calibration are generated. If the error
is below errorAccept the current calibration is returned immedeately
without further tries. Otherwise the best calibration seen is returned.
The error here may be specified to be the average error instead of the
maximum error. The parameter transformation is adjusted to ensure that
valid parameter values are not
transformed into error values during calibration.


3 ql/models/calibrationhelper.xpp

not essential for mf model, but necessary for test suite to run.

I made the calibration helpers lazy objects. Seems reasonable because
otherwise market data structures loose their lazy behaviour.


4 ql/models/model.xpp

essential for mf model. I replaced the update() call during calibration
by generateArguments() and notifyObservers(). This allows to separate
the smile update triggered by market data change from the numeraire
update triggered by model volatility changes.
The calibration to a second instrument set is faster then. Behaviour of
existing models is not affected by this change.


5 ql/pricingengines/blackformula.xpp

not essential for mf model, but model trace output may contain false
vega for zero strike, which I corrected.


6 ql/termstructures/volatility/optionlet/strippedoptionletadapter.xpp

not essential for mf model, but if you want to calibrate the numeraire
to caplet smiles, you need a volatility structure returning a smile section.

I added a smile section section implementation returning a smooth spline
interpolated smile curve. The markov functional
model requires the volatility structure to provide a smile section. In
addition this should be smooth in prices, at least C^1,
to ensure smooth digital prices. I did not put much energy in this
enhancement, just wanted to make the model work with cap smiles.


7 ql/termstructures/volatility/sabrsmilesection.xpp

not essential for mf model, but needed if you want to feed
sabrsmilesections for numeraire calibration. I floored the strike at
0.1bp for volatility computation to avoid problems for strikes near zero.


8 ql/termstructures/volatility/smilesection.xpp

essential for mf model. I added some supporting functions including
arbitrage tests and option price calculation. The best place for these
functions seemed here.


9 ql/termstructures/volatility/swaption/swaptionvolcube1.xpp

not essential for mf model, just the same comments as under 2 apply.

I added functionality to exclude negative strikes in single smiles, so
that the -200bp quotes can be used where reasonable. Furthermore I added
the same functionality as in sabrinterpolation above.


------------------------------------------------------------------------------
Keep yourself connected to Go Parallel:
DESIGN Expert tips on starting your parallel project right.
http://goparallel.sourceforge.net/
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev
Reply | Threaded
Open this post in threaded view
|

Re: Markov Functional Model

Luigi Ballabio
Thanks Peter, I'll try and have a look.

Luigi

On Sun, Dec 2, 2012 at 9:03 PM, Peter Caspers <[hidden email]> wrote:

> Hi,
>
> I implemented a Markov functional model which I would like to contribute
> to the lib. I would consider the development to be something like an
> alpha version.
>
> The model is an one factor interest rate model with a non parametric
> numeraire that can be fitted to a set of (arbitrage free) smiles on an
> option expiry grid. In addition a volatility function can be used to
> calibrate to a second instrument set (but only for one strike per
> expiry). An example would be a numeraire calibration to constant
> maturity swaption smiles which allows to recover market cms coupon
> prices. As a second instrument set atm coterminal swaptions can be
> chosen. The resulting model is then a good candidate for pricing
> callable cms swaps. The mean reversion parameter in the model is fixed,
> i.e. it can not be calibrated, but must be given externally. It can be
> used to control intertemporal correlations. References can be found in
> the documentation mentioned below.
>
> The package comes with the model, an implementation of Kahale's method
> for arbitrage free smile extrapolation (because arbitrage free smile
> input is essential for the numeraire to calibrate) and vanilla pricing
> engines for caps and swaptions. The swaption engine can also handle
> bermudan exercise rights. At the moment all engines are based on
> numerical integration. PDE engines and more product support will follow
> soon.
>
> You can find the code on github. I updated only the project files for
> msvc10, but it should be easy to include the relevant files in other
> enviroments. They are located in ql/experimental/models/markovfunctional.
>
> https://github.com/pcaspers/quantlib/commit/879c0fdd4f4149facdc8e771d838acafa7d6aae9
>
> A good starting point is probably running the test-suite to which I
> added a suite for the mf model which can be found in
> test-suite/markovfunctional.xpp.
>
> There are some changes in the ql I made, some essential for the model to
> work, others which I found worthwhile to do in the context and which
> support the test cases to run smoothly. I posted some of these changes
> on this list in the past, but I summarize all of them at the end of this
> mail.
>
> Any feedback is highly appreciated. There is also some documentation
> available here
>
> http://papers.ssrn.com/sol3/papers.cfm?abstract_id=2183721
>
> Thank you and kind regards
> Peter
>
>
> Changes to the lib I made:
>
> 1 ql/math/cubicinterpolation.hpp
>
> essential for mf model, I added the Lagrange boundary condition. I
> tested against the MatLab implementation. Works fine.
>
>
> 2 ql/math/sabrinterpolation.hpp
>
> not essential for mf model, but necessary for the test suite to run.
>
> I use a derivative of swaptionvolcube1 for daily swaption smile
> calibration for quite a time now. I noticed that two problems occur from
> time to time: First, calibration is not satisfactory because of unlucky
> start values. The solution for this I implemented is not very smart, but
> it is working well and is still fast enough. Secondly (very rarely)
> calibration stops with error values. I located the problem to be the
> transformation of valid parameters to numeric error values during
> optimization. Fix is very easy.
>
> More specifically I added a try and error method for calibration. Up to
> maxGuesses start values for the calibration are generated. If the error
> is below errorAccept the current calibration is returned immedeately
> without further tries. Otherwise the best calibration seen is returned.
> The error here may be specified to be the average error instead of the
> maximum error. The parameter transformation is adjusted to ensure that
> valid parameter values are not
> transformed into error values during calibration.
>
>
> 3 ql/models/calibrationhelper.xpp
>
> not essential for mf model, but necessary for test suite to run.
>
> I made the calibration helpers lazy objects. Seems reasonable because
> otherwise market data structures loose their lazy behaviour.
>
>
> 4 ql/models/model.xpp
>
> essential for mf model. I replaced the update() call during calibration
> by generateArguments() and notifyObservers(). This allows to separate
> the smile update triggered by market data change from the numeraire
> update triggered by model volatility changes.
> The calibration to a second instrument set is faster then. Behaviour of
> existing models is not affected by this change.
>
>
> 5 ql/pricingengines/blackformula.xpp
>
> not essential for mf model, but model trace output may contain false
> vega for zero strike, which I corrected.
>
>
> 6 ql/termstructures/volatility/optionlet/strippedoptionletadapter.xpp
>
> not essential for mf model, but if you want to calibrate the numeraire
> to caplet smiles, you need a volatility structure returning a smile section.
>
> I added a smile section section implementation returning a smooth spline
> interpolated smile curve. The markov functional
> model requires the volatility structure to provide a smile section. In
> addition this should be smooth in prices, at least C^1,
> to ensure smooth digital prices. I did not put much energy in this
> enhancement, just wanted to make the model work with cap smiles.
>
>
> 7 ql/termstructures/volatility/sabrsmilesection.xpp
>
> not essential for mf model, but needed if you want to feed
> sabrsmilesections for numeraire calibration. I floored the strike at
> 0.1bp for volatility computation to avoid problems for strikes near zero.
>
>
> 8 ql/termstructures/volatility/smilesection.xpp
>
> essential for mf model. I added some supporting functions including
> arbitrage tests and option price calculation. The best place for these
> functions seemed here.
>
>
> 9 ql/termstructures/volatility/swaption/swaptionvolcube1.xpp
>
> not essential for mf model, just the same comments as under 2 apply.
>
> I added functionality to exclude negative strikes in single smiles, so
> that the -200bp quotes can be used where reasonable. Furthermore I added
> the same functionality as in sabrinterpolation above.
>
>
> ------------------------------------------------------------------------------
> Keep yourself connected to Go Parallel:
> DESIGN Expert tips on starting your parallel project right.
> http://goparallel.sourceforge.net/
> _______________________________________________
> QuantLib-dev mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/quantlib-dev

------------------------------------------------------------------------------
Keep yourself connected to Go Parallel:
BUILD Helping you discover the best ways to construct your parallel projects.
http://goparallel.sourceforge.net
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev
Reply | Threaded
Open this post in threaded view
|

Re: Markov Functional Model

Roland Lichters-2
In reply to this post by Peter Caspers-4
Hi Peter,

great! I will have a look at it over Christmas and come back to you in January.

Best wishes,
Roland

On 2 Dec 2012, at 21:03, Peter Caspers wrote:

> Hi,
>
> I implemented a Markov functional model which I would like to contribute
> to the lib. I would consider the development to be something like an
> alpha version.
>
> The model is an one factor interest rate model with a non parametric
> numeraire that can be fitted to a set of (arbitrage free) smiles on an
> option expiry grid. In addition a volatility function can be used to
> calibrate to a second instrument set (but only for one strike per
> expiry). An example would be a numeraire calibration to constant
> maturity swaption smiles which allows to recover market cms coupon
> prices. As a second instrument set atm coterminal swaptions can be
> chosen. The resulting model is then a good candidate for pricing
> callable cms swaps. The mean reversion parameter in the model is fixed,
> i.e. it can not be calibrated, but must be given externally. It can be
> used to control intertemporal correlations. References can be found in
> the documentation mentioned below.
>
> The package comes with the model, an implementation of Kahale's method
> for arbitrage free smile extrapolation (because arbitrage free smile
> input is essential for the numeraire to calibrate) and vanilla pricing
> engines for caps and swaptions. The swaption engine can also handle
> bermudan exercise rights. At the moment all engines are based on
> numerical integration. PDE engines and more product support will follow
> soon.
>
> You can find the code on github. I updated only the project files for
> msvc10, but it should be easy to include the relevant files in other
> enviroments. They are located in ql/experimental/models/markovfunctional.
>
> https://github.com/pcaspers/quantlib/commit/879c0fdd4f4149facdc8e771d838acafa7d6aae9
>
> A good starting point is probably running the test-suite to which I
> added a suite for the mf model which can be found in
> test-suite/markovfunctional.xpp.
>
> There are some changes in the ql I made, some essential for the model to
> work, others which I found worthwhile to do in the context and which
> support the test cases to run smoothly. I posted some of these changes
> on this list in the past, but I summarize all of them at the end of this
> mail.
>
> Any feedback is highly appreciated. There is also some documentation
> available here
>
> http://papers.ssrn.com/sol3/papers.cfm?abstract_id=2183721
>
> Thank you and kind regards
> Peter
>
>
> Changes to the lib I made:
>
> 1 ql/math/cubicinterpolation.hpp
>
> essential for mf model, I added the Lagrange boundary condition. I
> tested against the MatLab implementation. Works fine.
>
>
> 2 ql/math/sabrinterpolation.hpp
>
> not essential for mf model, but necessary for the test suite to run.
>
> I use a derivative of swaptionvolcube1 for daily swaption smile
> calibration for quite a time now. I noticed that two problems occur from
> time to time: First, calibration is not satisfactory because of unlucky
> start values. The solution for this I implemented is not very smart, but
> it is working well and is still fast enough. Secondly (very rarely)
> calibration stops with error values. I located the problem to be the
> transformation of valid parameters to numeric error values during
> optimization. Fix is very easy.
>
> More specifically I added a try and error method for calibration. Up to
> maxGuesses start values for the calibration are generated. If the error
> is below errorAccept the current calibration is returned immedeately
> without further tries. Otherwise the best calibration seen is returned.
> The error here may be specified to be the average error instead of the
> maximum error. The parameter transformation is adjusted to ensure that
> valid parameter values are not
> transformed into error values during calibration.
>
>
> 3 ql/models/calibrationhelper.xpp
>
> not essential for mf model, but necessary for test suite to run.
>
> I made the calibration helpers lazy objects. Seems reasonable because
> otherwise market data structures loose their lazy behaviour.
>
>
> 4 ql/models/model.xpp
>
> essential for mf model. I replaced the update() call during calibration
> by generateArguments() and notifyObservers(). This allows to separate
> the smile update triggered by market data change from the numeraire
> update triggered by model volatility changes.
> The calibration to a second instrument set is faster then. Behaviour of
> existing models is not affected by this change.
>
>
> 5 ql/pricingengines/blackformula.xpp
>
> not essential for mf model, but model trace output may contain false
> vega for zero strike, which I corrected.
>
>
> 6 ql/termstructures/volatility/optionlet/strippedoptionletadapter.xpp
>
> not essential for mf model, but if you want to calibrate the numeraire
> to caplet smiles, you need a volatility structure returning a smile section.
>
> I added a smile section section implementation returning a smooth spline
> interpolated smile curve. The markov functional
> model requires the volatility structure to provide a smile section. In
> addition this should be smooth in prices, at least C^1,
> to ensure smooth digital prices. I did not put much energy in this
> enhancement, just wanted to make the model work with cap smiles.
>
>
> 7 ql/termstructures/volatility/sabrsmilesection.xpp
>
> not essential for mf model, but needed if you want to feed
> sabrsmilesections for numeraire calibration. I floored the strike at
> 0.1bp for volatility computation to avoid problems for strikes near zero.
>
>
> 8 ql/termstructures/volatility/smilesection.xpp
>
> essential for mf model. I added some supporting functions including
> arbitrage tests and option price calculation. The best place for these
> functions seemed here.
>
>
> 9 ql/termstructures/volatility/swaption/swaptionvolcube1.xpp
>
> not essential for mf model, just the same comments as under 2 apply.
>
> I added functionality to exclude negative strikes in single smiles, so
> that the -200bp quotes can be used where reasonable. Furthermore I added
> the same functionality as in sabrinterpolation above.
>
>
> ------------------------------------------------------------------------------
> Keep yourself connected to Go Parallel:
> DESIGN Expert tips on starting your parallel project right.
> http://goparallel.sourceforge.net/
> _______________________________________________
> QuantLib-dev mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/quantlib-dev


------------------------------------------------------------------------------
Keep yourself connected to Go Parallel:
BUILD Helping you discover the best ways to construct your parallel projects.
http://goparallel.sourceforge.net
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev
Reply | Threaded
Open this post in threaded view
|

Re: Markov Functional Model

Klaus Spanderen-2
In reply to this post by Peter Caspers-4

Hi Peter,

 

impressive! ...and it will take some time to browse throw the code.

 

regards

Klaus

 

On Sunday, December 02, 2012 09:03:54 PM Peter Caspers wrote:

> Hi,

>

> I implemented a Markov functional model which I would like to contribute

> to the lib. I would consider the development to be something like an

> alpha version.

>

> The model is an one factor interest rate model with a non parametric

> numeraire that can be fitted to a set of (arbitrage free) smiles on an

> option expiry grid. In addition a volatility function can be used to

> calibrate to a second instrument set (but only for one strike per

> expiry). An example would be a numeraire calibration to constant

> maturity swaption smiles which allows to recover market cms coupon

> prices. As a second instrument set atm coterminal swaptions can be

> chosen. The resulting model is then a good candidate for pricing

> callable cms swaps. The mean reversion parameter in the model is fixed,

> i.e. it can not be calibrated, but must be given externally. It can be

> used to control intertemporal correlations. References can be found in

> the documentation mentioned below.

>

> The package comes with the model, an implementation of Kahale's method

> for arbitrage free smile extrapolation (because arbitrage free smile

> input is essential for the numeraire to calibrate) and vanilla pricing

> engines for caps and swaptions. The swaption engine can also handle

> bermudan exercise rights. At the moment all engines are based on

> numerical integration. PDE engines and more product support will follow

> soon.

>

> You can find the code on github. I updated only the project files for

> msvc10, but it should be easy to include the relevant files in other

> enviroments. They are located in ql/experimental/models/markovfunctional.

>

> https://github.com/pcaspers/quantlib/commit/879c0fdd4f4149facdc8e771d838acaf

> a7d6aae9

>

> A good starting point is probably running the test-suite to which I

> added a suite for the mf model which can be found in

> test-suite/markovfunctional.xpp.

>

> There are some changes in the ql I made, some essential for the model to

> work, others which I found worthwhile to do in the context and which

> support the test cases to run smoothly. I posted some of these changes

> on this list in the past, but I summarize all of them at the end of this

> mail.

>

> Any feedback is highly appreciated. There is also some documentation

> available here

>

> http://papers.ssrn.com/sol3/papers.cfm?abstract_id=2183721

>

> Thank you and kind regards

> Peter

>

>

> Changes to the lib I made:

>

> 1 ql/math/cubicinterpolation.hpp

>

> essential for mf model, I added the Lagrange boundary condition. I

> tested against the MatLab implementation. Works fine.

>

>

> 2 ql/math/sabrinterpolation.hpp

>

> not essential for mf model, but necessary for the test suite to run.

>

> I use a derivative of swaptionvolcube1 for daily swaption smile

> calibration for quite a time now. I noticed that two problems occur from

> time to time: First, calibration is not satisfactory because of unlucky

> start values. The solution for this I implemented is not very smart, but

> it is working well and is still fast enough. Secondly (very rarely)

> calibration stops with error values. I located the problem to be the

> transformation of valid parameters to numeric error values during

> optimization. Fix is very easy.

>

> More specifically I added a try and error method for calibration. Up to

> maxGuesses start values for the calibration are generated. If the error

> is below errorAccept the current calibration is returned immedeately

> without further tries. Otherwise the best calibration seen is returned.

> The error here may be specified to be the average error instead of the

> maximum error. The parameter transformation is adjusted to ensure that

> valid parameter values are not

> transformed into error values during calibration.

>

>

> 3 ql/models/calibrationhelper.xpp

>

> not essential for mf model, but necessary for test suite to run.

>

> I made the calibration helpers lazy objects. Seems reasonable because

> otherwise market data structures loose their lazy behaviour.

>

>

> 4 ql/models/model.xpp

>

> essential for mf model. I replaced the update() call during calibration

> by generateArguments() and notifyObservers(). This allows to separate

> the smile update triggered by market data change from the numeraire

> update triggered by model volatility changes.

> The calibration to a second instrument set is faster then. Behaviour of

> existing models is not affected by this change.

>

>

> 5 ql/pricingengines/blackformula.xpp

>

> not essential for mf model, but model trace output may contain false

> vega for zero strike, which I corrected.

>

>

> 6 ql/termstructures/volatility/optionlet/strippedoptionletadapter.xpp

>

> not essential for mf model, but if you want to calibrate the numeraire

> to caplet smiles, you need a volatility structure returning a smile section.

>

> I added a smile section section implementation returning a smooth spline

> interpolated smile curve. The markov functional

> model requires the volatility structure to provide a smile section. In

> addition this should be smooth in prices, at least C^1,

> to ensure smooth digital prices. I did not put much energy in this

> enhancement, just wanted to make the model work with cap smiles.

>

>

> 7 ql/termstructures/volatility/sabrsmilesection.xpp

>

> not essential for mf model, but needed if you want to feed

> sabrsmilesections for numeraire calibration. I floored the strike at

> 0.1bp for volatility computation to avoid problems for strikes near zero.

>

>

> 8 ql/termstructures/volatility/smilesection.xpp

>

> essential for mf model. I added some supporting functions including

> arbitrage tests and option price calculation. The best place for these

> functions seemed here.

>

>

> 9 ql/termstructures/volatility/swaption/swaptionvolcube1.xpp

>

> not essential for mf model, just the same comments as under 2 apply.

>

> I added functionality to exclude negative strikes in single smiles, so

> that the -200bp quotes can be used where reasonable. Furthermore I added

> the same functionality as in sabrinterpolation above.

>

>

> ----------------------------------------------------------------------------

> -- Keep yourself connected to Go Parallel:

> DESIGN Expert tips on starting your parallel project right.

> http://goparallel.sourceforge.net/

> _______________________________________________

> QuantLib-dev mailing list

> [hidden email]

> https://lists.sourceforge.net/lists/listinfo/quantlib-dev


------------------------------------------------------------------------------
Keep yourself connected to Go Parallel:
BUILD Helping you discover the best ways to construct your parallel projects.
http://goparallel.sourceforge.net
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev
Reply | Threaded
Open this post in threaded view
|

Re: Markov Functional Model

Peter Caspers-4
Thanks for your interest in the code, Roland, Klaus, Luigi. It may be
worth to pull from the current HEAD from time to time, since it is still
work in progress (already put some minor changes there ...). As I said
any hints you might have are very very welcome.
Peter


------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev