How do I amend parameters in a Quantlib Option?

Viewed 61

So, I've built a PlainVanilla option in the C# QuantLib wrapper. This is then running in Excel to provide the greeks via Excel DNA. It's all working well.

What do I do, for example if the Underlyer Price changes, and I want to reprice the option and not create the whole object again?

For example, when I create the option I have:

QuoteHandle underlyingQuoteH = new QuoteHandle(new SimpleQuote(Convert.ToDouble(param.UnderlyerPrice)));

How do I simply update the underlyer price without a 'rebuild' of a new option object? Same for Div Yield, RFR, Vol and so on.

1 Answers

You need to keep the SimpleQuote around. You can do something like

var underlyingQuote = new SimpleQuote(Convert.ToDouble(param.UnderlyerPrice));
var underlyingQuoteH = new QuoteHandle(underlyingQuote);

and when the value of the parameter changes, run

underlyingQuote.setValue(newPrice);
Related