Exposure Issues

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

Exposure Issues

Rahul Gupta
My aim has been to expose the Heston process, model, and analytic engine to QuantLibXL.

For the process/model, I simply followed the guide, and it worked fine.  However for the analytic engine, the approach I took was to inherit from the pricingengine class.  I did this as follows:

analytichestonengine.hpp:

namespace QuantLibAddin {

        //class AnalyticHestonEngine : public ObjectHandler::LibraryObject<QuantLib::PricingEngine> {
        class AnalyticHestonEngine : public QuantLibAddin::PricingEngine {
                public:
                        AnalyticHestonEngine(
                                                const boost::shared_ptr<ObjectHandler::ValueObject>& properties,
                                                const boost::shared_ptr<QuantLib::HestonModel> &model,
                                                double integrationOrder, bool permanent);
        };


}

analytichestonengine.cpp:

namespace QuantLibAddin {

        AnalyticHestonEngine::AnalyticHestonEngine(
                        const boost::shared_ptr<ObjectHandler::ValueObject> &properties,
                        const boost::shared_ptr<QuantLib::HestonModel> &model,
                        double integrationOrder, bool permanent)
                        : QuantLibAddin::PricingEngine(properties, permanent) {
                                libraryObject_ = boost::shared_ptr<QuantLib::PricingEngine>(
                                                                        new QuantLib::AnalyticHestonEngine(model, (int)integrationOrder));
        }


}

Unfortunately, whilst this works fine, I appear to have broken the core functionality.

When I try to instantiate a qlPricingEngine("AE",B30), i.e. a GeneralizedBlackScholesEngine, I get #NUM, and the following error from ohRetrieveError():

qlPricingEngine - Error retrieving Enumeration from Registry - the type 'class boost::shared_ptr<class QuantLib::PricingEngine> (__cdecl*)(class boosts::shared_ptr<class QuantLib::GeneralizedBlackScholesProcess> const &)' is not available!

I would really appreciate any input, as i'm kinda stuck.

Thanks!
Reply | Threaded
Open this post in threaded view
|

Re: Exposure Issues

Eric Ehlers-2
Hello,

On Tue, August 12, 2008 11:14, Rahul Gupta wrote:

> When I try to instantiate a qlPricingEngine("AE",B30), i.e. a
> GeneralizedBlackScholesEngine, I get #NUM, and the following error from
ohRetrieveError():

That's the wrong syntax, in the first parameter you specify the ID of the
object you're creating.  Try qlPricingEngine("my_engine", "AE", B30).

Regards,
Eric

-------------------------
Eric Ehlers
nazcatech sprl | Brussels | http://www.nazcatech.be
Distributed computing for pricing analytics - Use Microsoft Excel as a client
to the Grid





-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev
Reply | Threaded
Open this post in threaded view
|

Re: Exposure Issues

Rahul Gupta
Thanks for your response.

Unfortunately, that does not change the error that is produced.  Lack of label for the engine simply means I get a excel assigned name rather than my own.  Any other ideas?

Eric Ehlers-2 wrote
Hello,

On Tue, August 12, 2008 11:14, Rahul Gupta wrote:

> When I try to instantiate a qlPricingEngine("AE",B30), i.e. a
> GeneralizedBlackScholesEngine, I get #NUM, and the following error from
ohRetrieveError():

That's the wrong syntax, in the first parameter you specify the ID of the
object you're creating.  Try qlPricingEngine("my_engine", "AE", B30).

Regards,
Eric

-------------------------
Eric Ehlers
nazcatech sprl | Brussels | http://www.nazcatech.be
Distributed computing for pricing analytics - Use Microsoft Excel as a client
to the Grid





-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
QuantLib-dev mailing list
QuantLib-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/quantlib-dev
Reply | Threaded
Open this post in threaded view
|

Re: Exposure Issues

Eric Ehlers-2
Hello,

On Wed, August 13, 2008 11:15, Rahul Gupta wrote:
>
> Lack of label for the engine simply means I get a excel assigned name rather
than my
> own.

Not exactly ;)

For excel to assign the name you would need explicitly to provide a null:

    qlPricingEngine(, "AE", B30)

Note the comma before the "AE".  In this case QLXL generates an ID like
obj_00000.

You have this:

    qlPricingEngine("AE", B30)

In that case "AE" is interpreted as the object ID, and the contents of B30 are
used as the Engine ID.

> Any other ideas?

Assuming the above is sorted out...

> When I try to instantiate a qlPricingEngine("AE",B30), i.e. a
> GeneralizedBlackScholesEngine, I get #NUM, and the following error from
> ohRetrieveError():
>
> qlPricingEngine - Error retrieving Enumeration from Registry - the type
> 'class boost::shared_ptr<class QuantLib::PricingEngine> (__cdecl*)(class
> boosts::shared_ptr<class QuantLib::GeneralizedBlackScholesProcess> const &)'
> is not available!

That error indicates that the enumeration registry is in an inconsistent
state.  In the standard release of QLXL I believe it's completely impossible
to trigger that error regardless of the inputs, so your change has somehow
broken the initialization of the app.

The long type name you are looking at is the signature of function AE_Engine()
in file
QuantLibAddin\qlo\Enumerations\Constructors\enumeratedclasses.hpp.

The link between the string "AE" and the function AE_Engine() is established
in line 51 of file
QuantLibAddin\qlo\Enumerations\Register\register_classes.cpp:

            create.registerType("AE", reinterpret_cast<void*>(AE_Engine));

That code is autogenerated by gensrc based on the contents of
QuantLibAddin\gensrc\metadata\Enumerations\enumeratedclasses.xml.
Did you edit enumeratedclasses.xml?

I notice in the error message you have "boosts" instead of "boost".  You
didn't do some hard core hackage in which you hard coded a type name and
misspelled it?

Otherwise... I see nothing in your description of your changes which would
corrupt the enumeration registry.  Whatever the cause of the problem, I'm
afraid there's not enough info in your email to identify it.

Maybe a sanity check - comment out all of your changes, rebuild, and see if
the problem goes away?  Also compare the behavior of your XLL with that of the
binary release.

Good luck.  Pls send another message if you come across more details that
might help identify the problem.  I'd be curious to know the resolution once
you find it.

Regards,
Eric

-------------------------
Eric Ehlers
nazcatech sprl | Brussels | http://www.nazcatech.be
Distributed computing for pricing analytics - Use Microsoft Excel as a client
to the Grid


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev
Reply | Threaded
Open this post in threaded view
|

Re: Exposure Issues

Rahul Gupta
Eric,

Thank you for such a thorough reply.  I should first clarify the
following issues:

1) I was explicitly providing a null, I merely didn't type it correctly.
2) The boosts issue is again a testament to my typing skills.

Now with regards to the engine.  I believe that I may have taken an
excessively complex route towards adding an engine.  My terminal goal is
to expose Analytic and MC heston engines.  Assuming I strip my code,
would this be the best way to add the engines?

1) Provide a type in enumeratedclasses.xml - Analytic = without
timesteps, MC = with timesteps [in terms of type] (say, AHE and MCHE)
2) Add a similar definition in pricingengines.xml/cpp/hpp to what I have
already done in my own files.

Many thanks,

Rahul

-----Original Message-----
From: Eric Ehlers [mailto:[hidden email]]
Sent: 14 August 2008 12:50 PM
To: Rahul Gupta
Cc: [hidden email]
Subject: Re: [Quantlib-dev] Exposure Issues

Hello,

On Wed, August 13, 2008 11:15, Rahul Gupta wrote:
>
> Lack of label for the engine simply means I get a excel assigned name
> rather
than my
> own.

Not exactly ;)

For excel to assign the name you would need explicitly to provide a
null:

    qlPricingEngine(, "AE", B30)

Note the comma before the "AE".  In this case QLXL generates an ID like
obj_00000.

You have this:

    qlPricingEngine("AE", B30)

In that case "AE" is interpreted as the object ID, and the contents of
B30 are used as the Engine ID.

> Any other ideas?

Assuming the above is sorted out...

> When I try to instantiate a qlPricingEngine("AE",B30), i.e. a
> GeneralizedBlackScholesEngine, I get #NUM, and the following error
> from
> ohRetrieveError():
>
> qlPricingEngine - Error retrieving Enumeration from Registry - the
> type 'class boost::shared_ptr<class QuantLib::PricingEngine>
> (__cdecl*)(class boosts::shared_ptr<class
QuantLib::GeneralizedBlackScholesProcess> const &)'
> is not available!

That error indicates that the enumeration registry is in an inconsistent
state.  In the standard release of QLXL I believe it's completely
impossible to trigger that error regardless of the inputs, so your
change has somehow broken the initialization of the app.

The long type name you are looking at is the signature of function
AE_Engine() in file
QuantLibAddin\qlo\Enumerations\Constructors\enumeratedclasses.hpp.

The link between the string "AE" and the function AE_Engine() is
established in line 51 of file
QuantLibAddin\qlo\Enumerations\Register\register_classes.cpp:

            create.registerType("AE",
reinterpret_cast<void*>(AE_Engine));

That code is autogenerated by gensrc based on the contents of
QuantLibAddin\gensrc\metadata\Enumerations\enumeratedclasses.xml.
Did you edit enumeratedclasses.xml?

I notice in the error message you have "boosts" instead of "boost".  You
didn't do some hard core hackage in which you hard coded a type name and
misspelled it?

Otherwise... I see nothing in your description of your changes which
would corrupt the enumeration registry.  Whatever the cause of the
problem, I'm afraid there's not enough info in your email to identify
it.

Maybe a sanity check - comment out all of your changes, rebuild, and see
if the problem goes away?  Also compare the behavior of your XLL with
that of the binary release.

Good luck.  Pls send another message if you come across more details
that might help identify the problem.  I'd be curious to know the
resolution once you find it.

Regards,
Eric

-------------------------
Eric Ehlers
nazcatech sprl | Brussels | http://www.nazcatech.be Distributed
computing for pricing analytics - Use Microsoft Excel as a client to the
Grid


*********** Legal Disclaimer and Other Information***********

The information contained in this e-mail message is intended only for the use of the individual named above. If the reader of this e-mail message is not the intended recipient, or the employee or agent responsible to deliver it to the intended recipient, you are hereby notified that any dissemination, distribution, or copying of this message is strictly prohibited. If you have received this message in error, please immediately notify us by telephone at 020.7470.7400, and destroy the original message.

Moore Europe Capital Management, LLP - One Curzon Street, London, W1J 5HA, UK

Registered as a limited liability partnership in England and Wales No: OC322533
with its registered office at One Silk Street, London, EC2Y 8HQ

Authorised and regulated by the Financial Services Authority


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev
Reply | Threaded
Open this post in threaded view
|

Re: Exposure Issues

Eric Ehlers-2
Hi Rahul,

On Thu, August 14, 2008 12:38, Rahul Gupta wrote:
> Eric,
>
> Thank you for such a thorough reply.

Happy to help.

> I should first clarify the following issues:
>
> 1) I was explicitly providing a null, I merely didn't type it correctly. 2)
The boosts issue is again a testament to my typing skills.

That makes more sense.

> Now with regards to the engine.  I believe that I may have taken an
excessively complex route towards adding an engine.  My terminal goal is to
expose Analytic and MC heston engines.  Assuming I strip my code, would this
be the best way to add the engines?
>
> 1) Provide a type in enumeratedclasses.xml - Analytic = without
> timesteps, MC = with timesteps [in terms of type] (say, AHE and MCHE) 2) Add
a similar definition in pricingengines.xml/cpp/hpp to what I have already
done in my own files.

I have just reviewed the code in more detail, it's slightly more complicated.
Pricing engines come in 2 flavors:

1) Full fledged objects
2) Enumerated classes
   2a) Without timesteps
   2b) With timesteps

DiscountingSwapEngine is an example of 1):
- Class QuantLibAddin::DiscountingSwapEngine is implemented in files
    QuantLibAddin\qlo\pricingengines.*pp
- Function qlDiscountingSwapEngine() is configured in file
    QuantLibAddin\gensrc\metadata\functions\pricingengines.xml

AnalyticEuropeanEngine is an example of 2a):
- Function AE_Engine() is implemented in files
    QuantLibAddin\qlo\enumerations\constructors\enumeratedclasses.*pp
- Enumeration AE is configured in file
    QuantLibAddin\gensrc\metadata\enumerations\enumeratedclasses.xml

Note that in the case of 2) no QuantLibAddin class is implemented.

Your new classes would need to follow one approach or the other.  The
differences between the two approaches should be fairly clear:

    1) Fully fledged stateful object which can be instantiated in its own
        cell, serialized, etc.  No restrictions on the signature of the
        constructor.

    2) Enumeration, exists only as a transient object which cannot be directly
        accessed by the user, must conform to one of the two available
        constructor signatures (2a or 2b).

Before starting on this I would first identify the cause of the "class xxx is
not available" error.  As mentioned I can't see anything in your description
of your initial changes which would have caused that error and you should get
to the bottom of that before proceeding.

Please let me know how it goes.  Maybe when this is done there will be some
code to contribute back to the project, and perhaps a new section on
enumerations in the "Extending QuantLibXL" tutorial?

Regards,
Eric

-------------------------
Eric Ehlers
nazcatech sprl | Brussels | http://www.nazcatech.be
Distributed computing for pricing analytics - Use Microsoft Excel as a client
to the Grid


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev
Reply | Threaded
Open this post in threaded view
|

Re: Exposure Issues

Rahul Gupta
I've now been through this in detail, and here are my results.  I assumed that the Heston engine implementation broke QLA, whereas in fact, it is the Heston process.  I removed the engine (still broken), the model (still broken), and the process (still broken) in that order.

The strange thing was that even having removed all of my code, the same error persisted.  As such, I took a fresh code base, and implemented:

1a) Heston Process as definition in processes.*pp
OR
1b) Heston Process as a totally separate class (hestonprocess.*pp)

1a - edited processes.xml, added QuantLib::YieldTermStructure to types.xml (libraryClass)
1b - edited categories.xml, added hestonprocess.xml, added QuantLib::YieldTermStructure to types.xml (libraryClass)

And then as per usual, generate files, add to project, compile.

The result of both approaches was the same:

qlPricingEngine - Error retrieving Enumeration from Registry - the type 'class boost::shared_ptr<class QuantLib::PricingEngine> (__cdecl*)(class boost::shared_ptr<class QuantLib::GeneralizedBlackScholesProcess> const &)' is not available!

Any ideas?

Eric Ehlers-2 wrote
Hi Rahul,

On Thu, August 14, 2008 12:38, Rahul Gupta wrote:
> Eric,
>
> Thank you for such a thorough reply.

Happy to help.

> I should first clarify the following issues:
>
> 1) I was explicitly providing a null, I merely didn't type it correctly. 2)
The boosts issue is again a testament to my typing skills.

That makes more sense.

> Now with regards to the engine.  I believe that I may have taken an
excessively complex route towards adding an engine.  My terminal goal is to
expose Analytic and MC heston engines.  Assuming I strip my code, would this
be the best way to add the engines?
>
> 1) Provide a type in enumeratedclasses.xml - Analytic = without
> timesteps, MC = with timesteps [in terms of type] (say, AHE and MCHE) 2) Add
a similar definition in pricingengines.xml/cpp/hpp to what I have already
done in my own files.

I have just reviewed the code in more detail, it's slightly more complicated.
Pricing engines come in 2 flavors:

1) Full fledged objects
2) Enumerated classes
   2a) Without timesteps
   2b) With timesteps

DiscountingSwapEngine is an example of 1):
- Class QuantLibAddin::DiscountingSwapEngine is implemented in files
    QuantLibAddin\qlo\pricingengines.*pp
- Function qlDiscountingSwapEngine() is configured in file
    QuantLibAddin\gensrc\metadata\functions\pricingengines.xml

AnalyticEuropeanEngine is an example of 2a):
- Function AE_Engine() is implemented in files
    QuantLibAddin\qlo\enumerations\constructors\enumeratedclasses.*pp
- Enumeration AE is configured in file
    QuantLibAddin\gensrc\metadata\enumerations\enumeratedclasses.xml

Note that in the case of 2) no QuantLibAddin class is implemented.

Your new classes would need to follow one approach or the other.  The
differences between the two approaches should be fairly clear:

    1) Fully fledged stateful object which can be instantiated in its own
        cell, serialized, etc.  No restrictions on the signature of the
        constructor.

    2) Enumeration, exists only as a transient object which cannot be directly
        accessed by the user, must conform to one of the two available
        constructor signatures (2a or 2b).

Before starting on this I would first identify the cause of the "class xxx is
not available" error.  As mentioned I can't see anything in your description
of your initial changes which would have caused that error and you should get
to the bottom of that before proceeding.

Please let me know how it goes.  Maybe when this is done there will be some
code to contribute back to the project, and perhaps a new section on
enumerations in the "Extending QuantLibXL" tutorial?

Regards,
Eric

-------------------------
Eric Ehlers
nazcatech sprl | Brussels | http://www.nazcatech.be
Distributed computing for pricing analytics - Use Microsoft Excel as a client
to the Grid


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
QuantLib-dev mailing list
QuantLib-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/quantlib-dev
Reply | Threaded
Open this post in threaded view
|

Re: Exposure Issues

Eric Ehlers-2
Hello,

On Tue, September 23, 2008 11:17, Rahul Gupta wrote:
>
> I've now been through this in detail, and here are my results.  I assumed
that the Heston engine implementation broke QLA, whereas in fact, it is the
Heston process.  I removed the engine (still broken), the model (still
broken), and the process (still broken) in that order.
>
> The strange thing was that even having removed all of my code, the same
error persisted.  As such, I took a fresh code base, and implemented:
>
> 1a) Heston Process as definition in processes.*pp
> OR
> 1b) Heston Process as a totally separate class (hestonprocess.*pp)
>
> 1a - edited processes.xml, added QuantLib::YieldTermStructure to types.xml
(libraryClass)
> 1b - edited categories.xml, added hestonprocess.xml, added
> QuantLib::YieldTermStructure to types.xml (libraryClass)
>
> And then as per usual, generate files, add to project, compile.

Either approach seems sensible to me.

> The result of both approaches was the same:
>
> qlPricingEngine - Error retrieving Enumeration from Registry - the type
'class boost::shared_ptr<class QuantLib::PricingEngine> (__cdecl*)(class
boost::shared_ptr<class QuantLib::GeneralizedBlackScholesProcess> const &)'
is not available!
>
> Any ideas?

Based on the info you provide I can't see what would cause that error.

If you send me your code I'll have a look.  I would suggest that you provide
the smallest possible example that would enable me to recreate the error,
ideally in the form of a patch which I could uncompress over the standard
0.9.6 build.

Regards,
Eric

-------------------------
Eric Ehlers
nazcatech sprl | Brussels | http://www.nazcatech.be
Distributed computing for pricing analytics - Use Microsoft Excel as a client
to the Grid





-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev