yassinemaaroufi / MibianLib

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

Name norm is not defined using python 3.9 version #13

Open akashiitd opened 2 years ago

akashiitd commented 2 years ago

``[self.callPrice, self.putPrice] = self._price() 277 else: --> 278 [self.callPrice, self.putPrice] = self._price() 279 [self.callDelta, self.putDelta] = self._delta() 280 [self.callDelta2, self.putDelta2] = self._delta2()

File c:\program files\python39\lib\site-packages\mibian__init__.py:307, in BS._price(self) 305 raise ZeroDivisionError('The strike price cannot be zero') 306 else: --> 307 call = self.underlyingPrice norm.cdf(self.d1) - \ 308 self.strikePrice e*(-self.interestRate \ 309 self.daysToExpiration) norm.cdf(self.d2) 310 put = self.strikePrice e*(-self.interestRate \ 311 self.daysToExpiration) norm.cdf(-self.d2) - \ 312 self.underlyingPrice norm.cdf(-self.d1) 313 return [call, put]

NameError: name 'norm' is not defined

sidnet033 commented 1 year ago

i am getting the same error. what is the solution?

anurag199831 commented 6 months ago

pip install scipy, then using from scipy.stats import norm in my code solved it for me.

apmcodes commented 5 months ago

The above did not solve the issue.