1 votos

Fallo en la creación del objeto LM Fixed Volatility Model de Quantlib

Quiero crear am LmFixedVolatilityModel como se define en http://www.jquantlib.com/en/latest/_static/javadocs/0.2.6-SNAPSHOT/jquantlib/index.html?org/jquantlib/pricingengines/swap/DiscountingSwapEngine.html

Abajo está mi código -

#include <iostream>
#include <cstring>
#include <ql/quantlib.hpp>

int main() 
{
    using namespace QuantLib;

    std::vector<QuantLib::Date> voldays;
    std::vector<QuantLib::Real> volvalues;

    voldays = TARGET().businessDayList(Date(29, March, 2019), Date(29, April, 2019));
    for (int i = 0; i < voldays.size(); i++) volvalues.push_back(0.10);

    ext::shared_ptr<LmVolatilityModel> volModel(new LmFixedVolatilityModel(volvalues, voldays);
}

Sin embargo, con esta implementación, estoy recibiendo el siguiente error -

aa.cpp:17:50: error: no matching constructor for initialization of 'QuantLib::LmFixedVolatilityModel'
        ext::shared_ptr<LmVolatilityModel> volModel(new LmFixedVolatilityModel(volvalues, voldays));
                                                        ^                      ~~~~~~~~~~~~~~~~~~
/usr/local/include/ql/legacy/libormarketmodels/lmfixedvolmodel.hpp:33:9: note: candidate constructor not viable: no known conversion from 'std::vector<QuantLib::Real>'
      (aka 'vector<double>') to 'const QuantLib::Array' for 1st argument
        LmFixedVolatilityModel(const Array& volatilities,
        ^
/usr/local/include/ql/legacy/libormarketmodels/lmfixedvolmodel.hpp:31:11: note: candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 2
      were provided
    class LmFixedVolatilityModel : public LmVolatilityModel {

Podrían por favor ayudarme con la forma correcta de crear un LmFixedVolatilityModel ¿Objeto?

Muchas gracias por su tiempo y ayuda.

0voto

user50229 Puntos 935

No tengo QuantLib instalado en este momento, por lo que no tengo medios para comprobar el código de abajo. Sin embargo, no he podido resistirme a publicar esto. Por favor, verifique si funciona.

#include <iostream>
#include <cstring>
#include <ql/quantlib.hpp>

using namespace QuantLib;

int main() 
{
    std::vector<Date> voldays;
    std::vector<Real> volvalues(voldays.size(), 0.1);

    voldays = TARGET().businessDayList(Date(29, March, 2019), Date(29, April, 2019));

    Array volarray(volvalues.begin(), volvalues.end());    // added line

    ext::shared_ptr<LmVolatilityModel> volModel(new LmFixedVolatilityModel(volarray, voldays));

return 0;
}

Finanhelp.com

FinanHelp es una comunidad para personas con conocimientos de economía y finanzas, o quiere aprender. Puedes hacer tus propias preguntas o resolver las de los demás.

Powered by:

X