-2

I am calculating option delta using py_vollib.black_scholes

from py_vollib.black_scholes.greeks.analytical import delta

if option_type == 'call': delta_calc = delta('c', S, K, t, r, sigma) elif option_type == 'put': delta_calc = delta('p', S, K, t, r, sigma)

How do I calculate the sigma? Do I need the closing process of the underlying for one year?

Please keep in my mind, I am a python programmer and I do not understand the math behind it.

Titu
  • 97
  • 1
  • 1
    I am not familiar with py_vollib.black_scholes. Are the functions you call the option prices or the delta? 2 different things. – AlRacoon Feb 18 '24 at 18:35
  • I second @AIRacoon's comment. I would be surprised if BS() would be delta.a quick Google search suggests there delta() implemented to do just this – AKdemy Feb 18 '24 at 18:59
  • 2
    Sigma is IV and you cannot use historical vol. See here for details. – AKdemy Feb 18 '24 at 19:02
  • Sigma is the volatility of the underlying based on https://www.mathworks.com/help/symbolic/the-black-scholes-formula-for-call-option-price.html

    σ is the standard deviation of continuously compounded annual returns of the stock, which is called volatility.

    – Titu Feb 18 '24 at 19:58
  • I edited the question using delta() – Titu Feb 18 '24 at 20:13
  • 1
    It explains how to find IB if you scroll down in the MATLAB link you provided. – AKdemy Feb 19 '24 at 00:04

2 Answers2

1

Do you have the price of the option and the other variables? The sigma is commonly known as implied volatility, which is another way of quoting the option price. Usually it is listed alongside the price of the option and its other variables.

If it is not listed, you can also solve for sigma numerically by using a root finding approach such as SOLVER in Excel or Newton's method coded out (or by using packages).

KaiSqDist
  • 1,010
  • 1
  • 3
  • 15
  • Most of the examples, I saw. People set sigma as 0.2 or 0.3. σ is the standard deviation of continuously compounded annual returns of the stock, which is called volatility. I am thinking of doing something like this and pass daily returns for a year. Am I thinking right?

    import numpy as np import math returns = [0.05, 0.03, -0.02, 0.08, -0.01, 0.13, -0.06] def annualized_volatility(returns): returns_np = np.array(returns) std_daily = returns_np.std() * np.sqrt(252) return std_daily sigma = annualized_volatility(returns) print(sigma)

    – Titu Feb 18 '24 at 20:32
  • 2
    You are using historical volatility, which is not correct. – KaiSqDist Feb 18 '24 at 20:47
  • How do the option chain prices get calculated? How do the brokers calculate sigma when there is no volume? Don't they use historical data?

    The problem I am to solve is this but the mods considered it a duplicate.

    https://quant.stackexchange.com/questions/78389/is-it-possible-to-reverse-calculate-greek-if-i-have-the-option-price

    – Titu Feb 19 '24 at 23:24
1

You need, for each point of the implied volatility surface, the relative quote from option market:

from py_vollib_vectorized import vectorized_implied_volatility

quotes: np.ndarray = np.array([5.0,10.]) s0: float = 100 tau: np.ndarray = np.array([0.1,0.2]) strike: np.ndarray = np.array([105.0,110.]) risk_free_rate: float = 0.02

$_implied_volatilities_for_puts

vectorized_implied_volatility(quotes, s0, strike, tau, risk_free_rate, 'p').values

BloomShell
  • 21
  • 2
  • And how does it help me evaluate delta? I have the option price, but not the delta. Can I reverse calculate? – Titu Feb 19 '24 at 23:26
  • Sigma in this case is not a number estimated from historical data, instead is an implied volatility estimated from market expectations. Implied volatility and options premiums move together since as markets expects more (less) volatility for the underlying process, it will reflects in option markets as an increase (decrease) in implied volatilities -> hence, in option premium -> hence, in time value of the option. – BloomShell Feb 27 '24 at 14:12