On integrating a new numerical method into QL

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

On integrating a new numerical method into QL

Joe FitzGerald
Very new to QuantLib. Very comfortable with C++.

I want to replicate some results from the following paper: "Psuedospectral methods for pricing options", Sangwon Suh (2009), Quantitative Finance, 9:6, 705-715

QL looks ideal as I can very quickly/easily compare results with the more traditional means (MC simulation, FDM, etc). The SpectralMethod technique per the paper is relatively straightforward and I think I can exploit much of what QL already offers to achieve it. As an added bonus, if done right, it's potentially another feather in QL's cap as regards option pricing engines.

I'm really at ground-zero with QL & need good advice on the best approach here wrt where to start and any recommended texts (bought Luigi's book already) &/or links taking me through QL's internal architecture in as much painstaking detail as possible. 

At first glance it looks like I'd want to derive from GenericEngine (or even PricingEngine) and implement what I need for Euro/American/Bermudans in a selft-contained way therein. Looking a little deeper, I might instead want to follow as a template what's been done in the FDEuropeanEngine, FDAmericanEngine, FDBermudanEngine classes - although obviously altering the implementation etc to fit my purposes.

Hence I'm confused as to the best/correct approach.

Advice / explanations gratefully received!

Joe

------------------------------------------------------------------------------

_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: On integrating a new numerical method into QL

Peter Caspers-4
Hey Joe,

I guess Luigi's book or the courses he teaches from time to time are
the best entry points. The book covers the interplay between pricing
engines and instruments quite detailed if I remember correctly.

If you start from scratch you would derive from GenericEngine (or
GenericModelEngine if a "model" is involved) and implement the
calculate() method. That's it. :-)

Although I would recommend to use an existing engine as a template,
that is always a good way to get started. Choose an engine that prices
the same instrument (if possible), then you already have a lot.

Maybe it would be helpful if you describe the kind of instrument you
plan to price and give a rough picture of the methodology.

Best regards
Peter


On 26 September 2015 at 12:21, Joe FitzGerald <[hidden email]> wrote:

> Very new to QuantLib. Very comfortable with C++.
>
> I want to replicate some results from the following paper: "Psuedospectral
> methods for pricing options", Sangwon Suh (2009), Quantitative Finance, 9:6,
> 705-715
>
> QL looks ideal as I can very quickly/easily compare results with the more
> traditional means (MC simulation, FDM, etc). The SpectralMethod technique
> per the paper is relatively straightforward and I think I can exploit much
> of what QL already offers to achieve it. As an added bonus, if done right,
> it's potentially another feather in QL's cap as regards option pricing
> engines.
>
> I'm really at ground-zero with QL & need good advice on the best approach
> here wrt where to start and any recommended texts (bought Luigi's book
> already) &/or links taking me through QL's internal architecture in as much
> painstaking detail as possible.
>
> At first glance it looks like I'd want to derive from GenericEngine (or even
> PricingEngine) and implement what I need for Euro/American/Bermudans in a
> selft-contained way therein. Looking a little deeper, I might instead want
> to follow as a template what's been done in the FDEuropeanEngine,
> FDAmericanEngine, FDBermudanEngine classes - although obviously altering the
> implementation etc to fit my purposes.
>
> Hence I'm confused as to the best/correct approach.
>
> Advice / explanations gratefully received!
>
> Joe
>
> ------------------------------------------------------------------------------
>
> _______________________________________________
> QuantLib-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>

------------------------------------------------------------------------------
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: On integrating a new numerical method into QL

Joe FitzGerald
Thanks for the quick response, Peter!

In terms of instruments I'm looking simply at European & American options (per the paper), so in terms of QL Instruments I can just instantiate a VanillaOption (with associated payoff & exercise) I think. In terms of the underlying model, again per the paper, I'll use BlackScholesMerton (& Heston where necessary) - thus in QL terms I can use an instance of say the BlackScholesMertonProcess & look to tie it all in much in the same way as  QL's EquityOption.cpp examples

Cheers,
Joe


On Sat, Sep 26, 2015 at 8:39 PM, Peter Caspers <[hidden email]> wrote:
Hey Joe,

I guess Luigi's book or the courses he teaches from time to time are
the best entry points. The book covers the interplay between pricing
engines and instruments quite detailed if I remember correctly.

If you start from scratch you would derive from GenericEngine (or
GenericModelEngine if a "model" is involved) and implement the
calculate() method. That's it. :-)

Although I would recommend to use an existing engine as a template,
that is always a good way to get started. Choose an engine that prices
the same instrument (if possible), then you already have a lot.

Maybe it would be helpful if you describe the kind of instrument you
plan to price and give a rough picture of the methodology.

Best regards
Peter


On 26 September 2015 at 12:21, Joe FitzGerald <[hidden email]> wrote:
> Very new to QuantLib. Very comfortable with C++.
>
> I want to replicate some results from the following paper: "Psuedospectral
> methods for pricing options", Sangwon Suh (2009), Quantitative Finance, 9:6,
> 705-715
>
> QL looks ideal as I can very quickly/easily compare results with the more
> traditional means (MC simulation, FDM, etc). The SpectralMethod technique
> per the paper is relatively straightforward and I think I can exploit much
> of what QL already offers to achieve it. As an added bonus, if done right,
> it's potentially another feather in QL's cap as regards option pricing
> engines.
>
> I'm really at ground-zero with QL & need good advice on the best approach
> here wrt where to start and any recommended texts (bought Luigi's book
> already) &/or links taking me through QL's internal architecture in as much
> painstaking detail as possible.
>
> At first glance it looks like I'd want to derive from GenericEngine (or even
> PricingEngine) and implement what I need for Euro/American/Bermudans in a
> selft-contained way therein. Looking a little deeper, I might instead want
> to follow as a template what's been done in the FDEuropeanEngine,
> FDAmericanEngine, FDBermudanEngine classes - although obviously altering the
> implementation etc to fit my purposes.
>
> Hence I'm confused as to the best/correct approach.
>
> Advice / explanations gratefully received!
>
> Joe
>
> ------------------------------------------------------------------------------
>
> _______________________________________________
> QuantLib-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>


------------------------------------------------------------------------------

_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: On integrating a new numerical method into QL

Luigi Ballabio
Yes, that's the way.  For the instrument, you'll instantiate a VanillaOption. For the engine, you'll inherit from VanillaOption::engine and provide (1) a constructor that takes the process and (2) a calculate() method that implements your calculations.

Luigi


On Sat, Sep 26, 2015 at 8:27 PM Joe FitzGerald <[hidden email]> wrote:
Thanks for the quick response, Peter!

In terms of instruments I'm looking simply at European & American options (per the paper), so in terms of QL Instruments I can just instantiate a VanillaOption (with associated payoff & exercise) I think. In terms of the underlying model, again per the paper, I'll use BlackScholesMerton (& Heston where necessary) - thus in QL terms I can use an instance of say the BlackScholesMertonProcess & look to tie it all in much in the same way as  QL's EquityOption.cpp examples

Cheers,
Joe


On Sat, Sep 26, 2015 at 8:39 PM, Peter Caspers <[hidden email]> wrote:
Hey Joe,

I guess Luigi's book or the courses he teaches from time to time are
the best entry points. The book covers the interplay between pricing
engines and instruments quite detailed if I remember correctly.

If you start from scratch you would derive from GenericEngine (or
GenericModelEngine if a "model" is involved) and implement the
calculate() method. That's it. :-)

Although I would recommend to use an existing engine as a template,
that is always a good way to get started. Choose an engine that prices
the same instrument (if possible), then you already have a lot.

Maybe it would be helpful if you describe the kind of instrument you
plan to price and give a rough picture of the methodology.

Best regards
Peter


On 26 September 2015 at 12:21, Joe FitzGerald <[hidden email]> wrote:
> Very new to QuantLib. Very comfortable with C++.
>
> I want to replicate some results from the following paper: "Psuedospectral
> methods for pricing options", Sangwon Suh (2009), Quantitative Finance, 9:6,
> 705-715
>
> QL looks ideal as I can very quickly/easily compare results with the more
> traditional means (MC simulation, FDM, etc). The SpectralMethod technique
> per the paper is relatively straightforward and I think I can exploit much
> of what QL already offers to achieve it. As an added bonus, if done right,
> it's potentially another feather in QL's cap as regards option pricing
> engines.
>
> I'm really at ground-zero with QL & need good advice on the best approach
> here wrt where to start and any recommended texts (bought Luigi's book
> already) &/or links taking me through QL's internal architecture in as much
> painstaking detail as possible.
>
> At first glance it looks like I'd want to derive from GenericEngine (or even
> PricingEngine) and implement what I need for Euro/American/Bermudans in a
> selft-contained way therein. Looking a little deeper, I might instead want
> to follow as a template what's been done in the FDEuropeanEngine,
> FDAmericanEngine, FDBermudanEngine classes - although obviously altering the
> implementation etc to fit my purposes.
>
> Hence I'm confused as to the best/correct approach.
>
> Advice / explanations gratefully received!
>
> Joe
>
> ------------------------------------------------------------------------------
>
> _______________________________________________
> QuantLib-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>

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

------------------------------------------------------------------------------

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