Closed sauravkedia10 closed 1 year ago
ref_python, as the name implies, is just there for reference. It does not benefit from any of the speedups of Peter Jaeckel's algorithms. That said, if you don't need the speed, ref_python should work for you.
I don't understand why there should be any Windows dependencies. We made py_vollib to remove all SWIG and C compiler dependencies, and we thoroughly tested it on Python 3.x. When I run the example above on Python 3.6.4 on Mac OSX, I get:
>>> import py_vollib.black.implied_volatility as biv
>>> P = 30.70
>>> F = 1685
>>> K = 1680
>>> r= .06
>>> flag = "c"
>>> biv.implied_volatility(P, F, K, r, 0.35, flag)
0.07248728185534212
It has been a long time since you opened this issue. (Apologies for not noticing until now) I would be interested to know whether you still have the problem and with which versions of Python & Windows.
Larry
By the way, you're using Black IV in your example. Black IV expect you to use the forward price (or futures price, in the case of futures options). Are you confident that your F is the forward price, and not the spot?
If you want to use the spot price, you should use py_vollib.black_scholes.implied_volatility
instead.
BTW, thank you for highlighting this misuse of _testcapi.
It should not be included in a production library, and sys.float_info
should be used instead, as you have indicated. I will put on my TODO list to fix this and issue an update.
I just ran into the same problem while launching it in an Amazon compute engine with Linux. Has this issue been solved? Just installed py_vollib using pip for python3, so I would expect it to be the latest.
_testcapi now removed from github repository version.ee
I am using Winpython64bit Python3.5 distribution on my Windows10 64 bit pc. When I first ran function to find black implied volatility I got an error saying that
ImportError: No module named _testcapi
Apparently _testcapi is not a package which can be installed using pip. It comes pre-installed. Neverthless, I went to py_lets_be_rational\constants and removed the
from _testcapi import DBL_MIN, DBL_MAX
line and added the following:The values captured by DBL_MIN and DBL_MAX are as follows:
After this the code was compiling and I could run the example mentioned in the documentation. It worked okay. Next, I tried to find the iv of an actual trading option on link: https://nseindia.com/live_market/dynaContent/live_watch/get_quote/GetQuoteFO.jsp?underlying=ACC&instrument=FUTSTK&type=-&strike=-&expiry=25MAY2017
I used the following and got the error:
I keep getting this error for almost all options. Then on my windows machine again, I tried calculating the implied vol using the py_vollib.ref_python modules and it worked. Next, I used another pc with linux and Anaconda python distribution and ran the original py_vollib.black.implied_volatility module and it worked well.
So, we have a situation where I am able to calculate options prices on linux distribution and on Windows 64bit platform using ref_python module but not through the recommended way on Windows 64 bit platform. Any suggestions? I want to use this package on a windows machine, would you recommend me using the ref_python modules in the interim? What could be the challenge?