0

Following this document on how to port a python QL program to C++, I try:

auto cp = 'C';
auto k = 100.0;
auto u = make_shared<SimpleQuote>(100.0);
auto r = make_shared<SimpleQuote>(0.01);
auto sigma = make_shared<SimpleQuote>(0.20);
auto t = calendar.businessDaysBetween(d1, expiry) / cDays;

auto exercise = EuropeanExercise(expiry);
auto payoff = ('C' == cp ? PlainVanillaPayoff(Option::Call, k) :
                             PlainVanillaPayoff(Option::Put, k));

auto european_option = EuropeanOption(
    boost::make_shared<PlainVanillaPayoff>(payoff),
    boost::make_shared<EuropeanExercise>(exercise));

auto riskFreeCurve =
    make_shared<FlatForward>(0, TARGET(), Handle<Quote>(r), Actual360());

I get the following error:

qldate.cpp:49:58: error: no matching function for call to \u2018QuantLib::Handle<QuantLib::Quote>::Handle(std::shared_ptr<QuantLib::SimpleQuote>&)\u2019
     make_shared<FlatForward>(0, TARGET(), Handle<Quote>(r), Actual360());
Ivan
  • 7,448
  • 14
  • 69
  • 134

1 Answers1

0

Instead of

auto u = make_shared<SimpleQuote>(100.0);

Make sure you qualify the boost version:

auto u = boost::make_shared<SimpleQuote>(100.0);
Ivan
  • 7,448
  • 14
  • 69
  • 134
  • See also: https://stackoverflow.com/questions/1452721/why-is-using-namespace-std-considered-bad-practice – NicholasM Nov 13 '19 at 21:12