0
$\begingroup$

I was trying to replicate one example from

http://www.bnikolic.co.uk/blog/ql-fx-option-simple.html

In QuantLib general practice is to use Handle to manage change in the observed variable. I am fine with that.

However for my case, I do not want to use Handle but want to use direct pointer (smart). So I replace below line -

Handle<Quote> underlyingH(boost::shared_ptr<Quote>(new SimpleQuote(in.S)));

with

boost::shared_ptr<SimpleQuote> underlyingH = boost::make_shared<SimpleQuote>(in.S);

With this I am getting error as -

/Users/aa.cpp:60:59: error: no matching constructor for initialization of
      'QuantLib::GarmanKohlagenProcess'
     boost::shared_ptr<GarmanKohlagenProcess> process(new GarmanKohlagenProcess(underlyingH, fTS, rTS, flatVolTS));
                                                          ^                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/include/ql/processes/blackscholesprocess.hpp:196:9: note: candidate constructor not viable: no known conversion from 'boost::shared_ptr<SimpleQuote>' to
      'const Handle<QuantLib::Quote>' for 1st argument
        GarmanKohlagenProcess(
        ^
/usr/local/include/ql/processes/blackscholesprocess.hpp:194:11: note: candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 4 were
      provided
    class GarmanKohlagenProcess : public GeneralizedBlackScholesProcess {
          ^
1 error generated.

Is there any way to not use Handle?

Many thanks for your kind help.

$\endgroup$
3
$\begingroup$

The constructor of GarmanKohlagenProcess takes a Handle, so if you really want to avoid it you'll have to modify the constructor (and the type of the corresponding data member it initializes).

$\endgroup$
3
  • $\begingroup$ Thanks Luigi for this information $\endgroup$
    – Daniel
    Sep 18 '20 at 7:05
  • $\begingroup$ Is there any way to writing the same line as something like underlyingH = ... instead underlyingH(...) $\endgroup$
    – Daniel
    Sep 18 '20 at 7:47
  • $\begingroup$ Handle<Quote> underlyingH = Handle<Quote>(...), or auto underlyingH = Handle<Quote>(...) if you're using C++11 or later $\endgroup$ Sep 18 '20 at 11:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.