yassinemaaroufi / MibianLib

Python Options Pricing Library
http://code.mibian.net
254 stars 77 forks source link

Clarification on volatility value/calculation #9

Open mrcartier opened 5 years ago

mrcartier commented 5 years ago

Great library. I have a question about how you would get the volatility value (20) in the below example

c = mibian.BS([1.4565, 1.45, 1, 30], volatility=20)

I'm currently using dataframe close prices like so

logreturn = np.log(df/df.shift(1))
volatility = np.sqrt(252*logreturn.var())

I've seen in your code the line below but just multiplying what I currently use by 100 still isn't very clean

self.volatility = float(volatility) / 100

Can you clarify how you would get 20 for volatility?