Re: Additional result as an array

Posted by Bogdan Popa on
URL: http://quantlib.414.s1.nabble.com/Additional-result-as-an-array-tp8666p8667.html

Hi,

I think I have an answer to your problem. I needed to extract an array from the InstrumentResults, and not only a double, this functionnality wasn't implemented in the QuantLibXLStatic project of 0.9.9. So what I did was to create another function, qlInstrumentResults2, by adding the following code in the file instruments.xml of the project qlgensrc (the QLXLStatic function generator) :

    <Member name='qlInstrumentResults2' type='QuantLib::Instrument'>
      <description>Returns the required result (if available) for the given Instrument object.</description>
      <libraryFunction>result<QuantLib::Real></libraryFunction>
      <SupportedPlatforms>
       
        <SupportedPlatform name='Excel'/>
       
      </SupportedPlatforms>
      <ParameterList>
        <Parameters>
          <Parameter name='ResultType' exampleValue='vega'>
            <type>string</type>
            <tensorRank>scalar</tensorRank>
            <description>result type (e.g. 'vega').</description>
          </Parameter>
        </Parameters>
      </ParameterList>
      <ReturnValue>
        <type>double</type>
        <tensorRank>vector</tensorRank>
      </ReturnValue>
    </Member>


After you generate the project, a new function should normally appear in QuantLibXLStatic/instruments.cpp . The only thing you need to do next is to replace :

std::vector<double> returnValue = ObjectIdLibObjPtr->result< QuantLib::Real>(ResultType);

with

std::vector<double> returnValue = ObjectIdLibObjPtr->result<std::vector<QuantLib::Real>>(
                ResultType);

This will ensure the proper cast of an array.

Hope this helps,

Bogdan

www.riskedge.fr


Yomi wrote
Hi,

Here is what I am trying to do:
I have a PDE engine that I am happy with but I would like to see the delta on the full grid (to see the behavior at the barrier).
As of today the additionalResults_ should be a single value due to the boost::any type.
Is there any otherway to see my result instead of developping a pecial function for this special model?

Cheers