Hi, I'm trying to get the Greeks for an AmericanOption. Delta and gamma are provided, but the other three are not.
void calculateGreeks(boost::shared_ptr<SimpleQuote> rQuote,
boost::shared_ptr<SimpleQuote> pQuote,
boost::shared_ptr<SimpleQuote> dQuote,
boost::shared_ptr<SimpleQuote> vQuote,
boost::shared_ptr<OneAssetOption> option) {
// Perturb the implied volatility to calculate vega.
const Rate v0 = vQuote->value();
// Bump it by 1%.
const Spread dv = v0 * 0.01;
vQuote->setValue(v0 + dv);
option->update();
const Real V1 = option->NPV();
vQuote->setValue(v0 - dv);
option->update();
const Real V2 = option->NPV();
const Real vega = (V1 - V2) / (2 * dv);
vQuote->setValue(v0); // Restore the original implied volatility.
// Do something similar for rho and theta...
}
Is there a better way to do this? The values I get for rho, vega, and theta don't really align with the expected results.
Also, since I'm using SimpleQuotes (and passing handles to the term structures), do I need to call update()?
Thanks,
Alex