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.

  • 1
    $\begingroup$ I am not familiar with py_vollib.black_scholes. Are the functions you call the option prices or the delta? 2 different things. $\endgroup$
    – AlRacoon
    Feb 18 at 18:35
  • $\begingroup$ 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 $\endgroup$
    – AKdemy
    Feb 18 at 18:59
  • 2
    $\begingroup$ Sigma is IV and you cannot use historical vol. See here for details. $\endgroup$
    – AKdemy
    Feb 18 at 19:02
  • $\begingroup$ Sigma is the volatility of the underlying based on mathworks.com/help/symbolic/… σ is the standard deviation of continuously compounded annual returns of the stock, which is called volatility. $\endgroup$
    – Titu
    Feb 18 at 19:58
  • 1
    $\begingroup$ It explains how to find IB if you scroll down in the MATLAB link you provided. $\endgroup$
    – AKdemy
    Feb 19 at 0:04

2 Answers 2


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).

  • $\begingroup$ 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) $\endgroup$
    – Titu
    Feb 18 at 20:32
  • 2
    $\begingroup$ You are using historical volatility, which is not correct. $\endgroup$
    – KaiSqDist
    Feb 18 at 20:47
  • $\begingroup$ 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. quant.stackexchange.com/questions/78389/… $\endgroup$
    – Titu
    Feb 19 at 23:24

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
  • $\begingroup$ And how does it help me evaluate delta? I have the option price, but not the delta. Can I reverse calculate? $\endgroup$
    – Titu
    Feb 19 at 23:26
  • $\begingroup$ 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. $\endgroup$
    – BloomShell
    Feb 27 at 14:12

Not the answer you're looking for? Browse other questions tagged or ask your own question.