Negative or null underlying

classic Classic list List threaded Threaded
1 message Options
v17
Reply | Threaded
Open this post in threaded view
|

Negative or null underlying

v17
I am getting exception "Negative or null underlying given" while trying to use quantlib Options. Please see below code -

shared_ptr<OneAssetOption> optionPtr;
shared_ptr<StrikedTypePayoff> payoffPtr;
shared_ptr<Exercise> exercisePtr;

payoffPtr.reset(CreatePayoff());
exercisePtr.reset(new EuropeanExercise(maturity));

optionPtr.reset(new VanillaOption(payoffPtr, exercisePtr));
optionPtr->setPricingEngine(enginePtr);
optionPtr->NPV();
optionPtr->delta();

I am new to Quantlib Options so the question might be very basic but please let me know what am I missing.

Thanks!