Problem in extending QuantLibXL functionality

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

Problem in extending QuantLibXL functionality

Max-118
Hi,

I am trying to follow the online tuturial to add a new function to QuantLibXL:
http://quantlib.sourceforge.net/quantlibaddin/extend_tutorial.html

I have created the following files:
QuantLibAddin\qlo\stock.hpp (added to project QuantLibObjects)
QuantLibAddin\qlo\stock.cpp (added to project QuantLibObjects)
QuantLibAddin\gensrc\metadata\Functions\stock.xml (added to project qlgensrc)

And edit the file QuantLibAddin\gensrc\config\categories.xml by adding
this line:
    <categoryName>stock</categoryName>
(without this step, rebuilding project qlgensrc is fine but no new
files are generated)

However when I rebuild project qlgensrc, the following error occurs:
------------------------------------------------------------------------------------------------------------------------------
Performing Makefile project actions
Microsoft (R) Program Maintenance Utility Version 8.00.50727.762
Copyright (C) Microsoft Corporation.  All rights reserved.
 if not exist build\vc mkdir build\vc
 ..\..\gensrc\gensrc.py -a
>
> gensrc has encountered a fatal error.
>
> >>>>>>>>>> BEGIN STACK TRACE >>>>>>>>>>
  File "d:\build_ql_0_9_0\gensrc\gensrc.py", line 102, in
    addinList = addinlist.AddinList(addinIds)
  File "d:\build_ql_0_9_0\gensrc\gensrc\Addins\addinlist.py", line
127, in __init__
    self.categoryList_ = categorylist.CategoryList()
  File "d:\build_ql_0_9_0\gensrc\gensrc\Categories\categorylist.py",
line 72, in __init__
    self.loadCategories(self.addinCategoryNames_,
environment.config().addinFunctions())
  File "d:\build_ql_0_9_0\gensrc\gensrc\Categories\categorylist.py",
line 57, in loadCategories
    cat = utilities.serializeObject(category.Category, catDir + categoryName)
  File "d:\build_ql_0_9_0\gensrc\gensrc\Utilities\utilities.py", line
30, in serializeObject
    objectInstance.serialize(serializer)
  File "d:\build_ql_0_9_0\gensrc\gensrc\Categories\category.py", line
100, in serialize
    serializer.serializeObjectDict(self, function.Function)
  File "d:\build_ql_0_9_0\gensrc\gensrc\Serialization\xmlreader.py",
line 161, in serializeObjectDict
    objectInstance.serialize(self)
  File "d:\build_ql_0_9_0\gensrc\gensrc\Functions\constructor.py",
line 70, in serialize
    super(Constructor, self).serialize(serializer)
  File "d:\build_ql_0_9_0\gensrc\gensrc\Functions\function.py", line
128, in serialize
    serializer.serializeObject(self, parameterlist.ParameterList)
  File "d:\build_ql_0_9_0\gensrc\gensrc\Serialization\xmlreader.py",
line 119, in serializeObject
    objectInstance.serialize(self)
  File "d:\build_ql_0_9_0\gensrc\gensrc\Parameters\parameterlist.py",
line 89, in serialize
    serializer.serializeObjectList(self, parameter.Parameter)
  File "d:\build_ql_0_9_0\gensrc\gensrc\Serialization\xmlreader.py",
line 134, in serializeObjectList
    objectInstance.postSerialize()
  File "d:\build_ql_0_9_0\gensrc\gensrc\Parameters\parameter.py", line
143, in postSerialize
    raise exceptions.ParameterNameCapitalizationException(self.name_)
> <<<<<<<<<<  END STACK TRACE  <<<<<<<<<<
>
> gensrc error:
>
> The string "quote" is not a valid parameter name -
> All parameter names must begin with an uppercase letter.
>
NMAKE : fatal error U1077: '..\..\gensrc\gensrc.py' : return code '0x1'
Stop.
Project : error PRJ0019: A tool returned an error code from
"Performing Makefile project actions"
------------------------------------------------------------------------------------------------------------------------------

Any help? Thanks in advance!

Cheers,
Max

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Problem in extending QuantLibXL functionality

Eric Ehlers-2
Hello,

[resending quantlib-dev response to quantlib-users]

Max wrote:

> Hi,
>
> I am trying to follow the online tuturial to add a new function to
> QuantLibXL:
> http://quantlib.sourceforge.net/quantlibaddin/extend_tutorial.html
>
> I have created the following files:
> QuantLibAddin\qlo\stock.hpp (added to project QuantLibObjects)
> QuantLibAddin\qlo\stock.cpp (added to project QuantLibObjects)
> QuantLibAddin\gensrc\metadata\Functions\stock.xml (added to project
> qlgensrc)
>
> And edit the file QuantLibAddin\gensrc\config\categories.xml by adding
> this line:
>     <categoryName>stock</categoryName>
> (without this step, rebuilding project qlgensrc is fine but no new
> files are generated)
>
> However when I rebuild project qlgensrc, the following error occurs:
> ------------------------------------------------------------------------------------------------------------------------------
> Performing Makefile project actions
> Microsoft (R) Program Maintenance Utility Version 8.00.50727.762
> Copyright (C) Microsoft Corporation.  All rights reserved.
>  if not exist build\vc mkdir build\vc
>  ..\..\gensrc\gensrc.py -a
>>
>> gensrc has encountered a fatal error.
>>
>> >>>>>>>>>> BEGIN STACK TRACE >>>>>>>>>>
>   File "d:\build_ql_0_9_0\gensrc\gensrc.py", line 102, in
>     addinList = addinlist.AddinList(addinIds)
>   File "d:\build_ql_0_9_0\gensrc\gensrc\Addins\addinlist.py", line

[snip]

>> <<<<<<<<<<  END STACK TRACE  <<<<<<<<<<
>>
>> gensrc error:
>>
>> The string "quote" is not a valid parameter name -
>> All parameter names must begin with an uppercase letter.
>>
> NMAKE : fatal error U1077: '..\..\gensrc\gensrc.py' : return code '0x1'
> Stop.
> Project : error PRJ0019: A tool returned an error code from
> "Performing Makefile project actions"
> ------------------------------------------------------------------------------------------------------------------------------
>
> Any help? Thanks in advance!
>
> Cheers,
> Max

Nicola Jean wrote:

> In your stock.xml do you have something like this?
> <Parameter name='quote'>
> In this case change it to
> <Parameter name='Quote'>
> that's what the error message is telling you.
> For the reason of having all the parameter names starting with a capital
> letter
> probably Eric might give us some insight.

Eric Ehlers wrote:

> The requirement was introduced to enforce consistency with the Excel
> Function Wizard which uppercases the first letter of every parameter name
> whether you like it or not.

Regards,
Eric



-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Problem in extending QuantLibXL functionality

Max-118
Hi Eric, Nicola,

Thanks for your quick help and explanation! Now the code generation
works after changing "quote" to "Quote" in stock.xml.

But I failed to compile "QuantLibAddin/qlo/stock.cpp" and
"QuantLibXL/qlxl/Functions/stock.cpp".

Here is the error from building project QuantLibObjects:
Compiling...
vo_stock.cpp
stock.cpp
.\qlo\stock.cpp(8) : error C2512: 'QuantLibAddin::Instrument' : no
appropriate default constructor available

Here is the error from building project QuantLibXLStatic:
Compiling...
stock.cpp
.\Functions\stock.cpp(88) : error C2661: 'QuantLibAddin::Stock::Stock'
: no overloaded function takes 3 arguments

The source code of QuantLibAddin\qlo\stock.hpp and
QuantLibAddin\qlo\stock.cpp are exactly the same as the online
tutorial example. So what could be the possible problems?

Thanks in advance!

Cheers,
Max

On Feb 6, 2008 7:37 PM, Eric Ehlers <[hidden email]> wrote:

>
> Nicola Jean wrote:
>
> > In your stock.xml do you have something like this?
> > <Parameter name='quote'>
> > In this case change it to
> > <Parameter name='Quote'>
> > that's what the error message is telling you.
> > For the reason of having all the parameter names starting with a capital
> > letter
> > probably Eric might give us some insight.
>
> Eric Ehlers wrote:
>
> > The requirement was introduced to enforce consistency with the Excel
> > Function Wizard which uppercases the first letter of every parameter name
> > whether you like it or not.
>
> Regards,
> Eric
>
>
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> QuantLib-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Problem in extending QuantLibXL functionality

Eric Ehlers-2
Hi Max,

> Hi Eric, Nicola,
>
> Thanks for your quick help and explanation! Now the code generation
works after changing "quote" to "Quote" in stock.xml.
>
> But I failed to compile "QuantLibAddin/qlo/stock.cpp" and
> "QuantLibXL/qlxl/Functions/stock.cpp".

The tutorial was out of date in places with respect to release 0.9.0.  I
have updated the document, please try again and let us know if you have
any further problems.

Regards,
Eric





-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Problem in extending QuantLibXL functionality

Nicola Jean
In reply to this post by Max-118
In stock.hpp instead of:
namespace QuantLibAddin {
    class Stock : public Instrument {
        public:
            Stock(const QuantLib::Handle<QuantLib::Quote>& quote);
    };
}
I was expecting something like
namespace QuantLibAddin {
    class Stock : public Instrument {
        public:
            Stock(const boost::shared_ptr<ObjectHandler::ValueObject>&
properties,
                      const QuantLib::Handle<QuantLib::Quote>& quote,
                      bool permanent);
    };
}

Therefore your new stock.cpp should be:

    Stock::Stock(const boost::shared_ptr<ObjectHandler::ValueObject>&
properties,
                      const QuantLib::Handle<QuantLib::Quote>& quote,
                      bool permanent):Instrument(properties, permanent){
        libraryObject_ = boost::shared_ptr<QuantLib::Stock>(
            new QuantLib::Stock(quote));
    }
Try with these two files and tell me if it works.

To Eric: is there any reason why properties and permanent variables
were not in the tutorial files?

N.Jean

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Problem in extending QuantLibXL functionality

Max-118
In reply to this post by Eric Ehlers-2
Hi Eric, Nicola,

On Feb 8, 2008 8:21 PM, Eric Ehlers <[hidden email]> wrote:
> The tutorial was out of date in places with respect to release 0.9.0.  I
> have updated the document, please try again and let us know if you have
> any further problems.

Yes, both of your solutions resolved the compilation problem. I
managed to re-build QuantLibXL successfully.

However, after reloading the XLL "QuantLibXL-vc80-mt-s-0_9_0.xll" in
Excel, the "=qlStock("my_stock",1.23)" only returns "#NAME?". It seems
that the function "qlStock" is not recognised.

I guess I must have missed out some important steps...

Any hint? Thanks in advance!

Cheers,
Max

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Problem in extending QuantLibXL functionality

Eric Ehlers-2
Hi Max,

> However, after reloading the XLL "QuantLibXL-vc80-mt-s-0_9_0.xll" in
> Excel, the "=qlStock("my_stock",1.23)" only returns "#NAME?". It seems
> that the function "qlStock" is not recognised.

Are you sure that the XLL you loaded is the one with the new function
compiled in?  What result do you get from this?

=qlxlVersion(TRUE)

The timestamp should correspond to the creation date of the XLL.  For
example for the binary release of QLXL I get

QuantLibXL 0.9.0 - MS VC++ 8.0 - Multithreaded Static Runtime library -
Release Configuration - Jan 23 2008 18:20:22

Regards,
Eric



-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Problem in extending QuantLibXL functionality

Max-118
Hi Eric,

Thank you very much for the quick help!

My mistake: I forgot the proper procedure of loading the new add-in in
Excel 2003. I have to deselect the old one from the add-in menu, exit
Excel, re-open Excel, and then load the new add-in.

Now everything works fine. I also successfully added a new function
"qlMCPricingEngine()" which creates a crude monte carlo pricing engine
object. And I am happy to contribute more QuantLibXL functions if
needed. Thanks!

Cheers,
Max

On Feb 10, 2008 9:31 PM, Eric Ehlers <[hidden email]> wrote:

> Hi Max,
>
> > However, after reloading the XLL "QuantLibXL-vc80-mt-s-0_9_0.xll" in
> > Excel, the "=qlStock("my_stock",1.23)" only returns "#NAME?". It seems
> > that the function "qlStock" is not recognised.
>
> Are you sure that the XLL you loaded is the one with the new function
> compiled in?  What result do you get from this?
>
> =qlxlVersion(TRUE)
>
> The timestamp should correspond to the creation date of the XLL.  For
> example for the binary release of QLXL I get
>
> QuantLibXL 0.9.0 - MS VC++ 8.0 - Multithreaded Static Runtime library -
> Release Configuration - Jan 23 2008 18:20:22
>
> Regards,
> Eric
>
>
>

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: [Quantlib-dev] Problem in extending QuantLibXL functionality

Ferdinando M. Ametrano-3
Max,

if you own the copyright to the files you've used to extend QLXL and
want to contribute them just send them to me or Eric.

ciao -- Nando

On Sun, Feb 10, 2008 at 3:44 PM, Max <[hidden email]> wrote:

> Hi Eric,
>
>  Thank you very much for the quick help!
>
>  My mistake: I forgot the proper procedure of loading the new add-in in
>  Excel 2003. I have to deselect the old one from the add-in menu, exit
>  Excel, re-open Excel, and then load the new add-in.
>
>  Now everything works fine. I also successfully added a new function
>  "qlMCPricingEngine()" which creates a crude monte carlo pricing engine
>  object. And I am happy to contribute more QuantLibXL functions if
>  needed. Thanks!
>
>  Cheers,
>  Max
>
>
>
>  On Feb 10, 2008 9:31 PM, Eric Ehlers <[hidden email]> wrote:
>  > Hi Max,
>  >
>  > > However, after reloading the XLL "QuantLibXL-vc80-mt-s-0_9_0.xll" in
>  > > Excel, the "=qlStock("my_stock",1.23)" only returns "#NAME?". It seems
>  > > that the function "qlStock" is not recognised.
>  >
>  > Are you sure that the XLL you loaded is the one with the new function
>  > compiled in?  What result do you get from this?
>  >
>  > =qlxlVersion(TRUE)
>  >
>  > The timestamp should correspond to the creation date of the XLL.  For
>  > example for the binary release of QLXL I get
>  >
>  > QuantLibXL 0.9.0 - MS VC++ 8.0 - Multithreaded Static Runtime library -
>  > Release Configuration - Jan 23 2008 18:20:22
>  >
>  > Regards,
>  > Eric
>  >
>  >
>  >
>
>  -------------------------------------------------------------------------
>  This SF.net email is sponsored by: Microsoft
>  Defy all challenges. Microsoft(R) Visual Studio 2008.
>  http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
>  _______________________________________________
>  QuantLib-dev mailing list
>  [hidden email]
>  https://lists.sourceforge.net/lists/listinfo/quantlib-dev
>

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users