1

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.

Nick
  • 11
  • 1

1 Answers1

0

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);
Luigi Ballabio
  • 4,128
  • 21
  • 29
  • Thanks Luigi. I'm thinking to cache the created options in the C# layer, then when the re-calc comes in from Excel I just update the inputs and call the relevant greek as requested by Excel. Can I do a similar process with the FlatForward object I'm using to create the Dividend Yield and Risk Free Rate structures? – Nick Oct 21 '21 at 13:08
  • Same. Keep hold of the corresponding `SimpleQuote` objects and call `setValue`. – Luigi Ballabio Oct 21 '21 at 16:21