There's more...

QuantLib also allows us to use variance reduction techniques such as antithetic values or control variates.

Now that we have completed the preceding steps, we can calculate Greeks. Greeks (from the letters of the Greek alphabet) represent the sensitivity of the price of derivatives (for example, the option premium) to a change in one of the underlying parameters (such as the price of the underlying asset, time to expiry, volatility, the interest rate, and so on). When there is an analytical formula available for the Greeks (when the QuantlLib engine is using analytical formulas), we could just access it by running, for example, option.delta(). However, in cases such as valuations using binomial trees or simulations, there is no analytical formula and we would receive an error (RuntimeError: delta not provided). This does not mean that it is impossible to calculate it, but we need to employ numerical differentiation and calculate it ourselves.

In this example, we will only extract the delta. Therefore, the relevant two-sided formula is:

Here, P(S) is the price of the instrument given the underlying's price S; h is a very small increment.

Run the following block of code to calculate the delta:

u_0 = u.value() # original value
h = 0.01

u.setValue(u_0 + h)
P_plus_h = option.NPV()

u.setValue(u_0 - h)
P_minus_h = option.NPV()

u.setValue(u_0) # set back to the original value

delta = (P_plus_h - P_minus_h) / (2 * h)

The simplest interpretation of the delta is that the option's delta being equal to -1.25 indicates that, if the underlying stock increases in price by $1 per share, the option on it will decrease by $1.25 per share; otherwise, everything will be equal.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.128.206.91