yassinemaaroufi / MibianLib

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

ZeroDivisionError: float division by zero - not able to get calculation on expiry day. #11

Open maxh8086 opened 3 years ago

maxh8086 commented 3 years ago
\python\python36\lib\site-packages\mibian\__init__.py in __init__(self, args, volatility, callPrice, putPrice, performance)
    271             self._d1_ = (log(self.underlyingPrice / self.strikePrice) + \
    272                                         (self.interestRate + (self.volatility**2) / 2) * \
--> 273                     self.daysToExpiration) / self._a_
    274                         self._d2_ = self._d1_ - self._a_
    275                         if performance:

ZeroDivisionError: float division by zero

i have suggession to add '+ 0.0001' to line of division or try catch and add 0.0001 which will give correct ans rather than error:

        self._d1_ = (log(self.underlyingPrice / self.strikePrice) + \
                (self.interestRate - self.dividendYield + \
                (self.volatility**2) / 2) * self.daysToExpiration) / \
                self._a_ + 0.0001
PriyankSinghal90 commented 2 years ago

I think On Expiry day the no. of days will be 1 cause we will have that trading day.....

sathyarajshetigar commented 1 year ago

Which is correct answer? adding + 0.0001 or 1

sidnet033 commented 1 year ago

what do we do on expiry day? consider daysLeftToExpiry as 1? or 0.0001?

if 0.0001, why this specific figure? why not 0.1 or 0.001?