{ "info": { "author": "Erkan Demiralay", "author_email": "erkan@erkan.io", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "Intended Audience :: Education", "Intended Audience :: Financial and Insurance Industry", "Intended Audience :: Science/Research", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: Implementation :: PyPy", "Topic :: Office/Business :: Financial", "Topic :: Office/Business :: Financial :: Spreadsheet" ], "description": "\n[![Build Status](https://travis-ci.com/erkandem/calcbsimpvol.svg?token=EM8YQfR9wuLvQFQzBZ5o&branch=master)](https://travis-ci.com/erkandem/calcbsimpvol)\n![](https://img.shields.io/badge/License-MIT-blue.svg)\n![](https://img.shields.io/badge/Python-3.4%20%7C%203.5%20%7C%203.6%20%7C%203.7%20%7C%20PyPy3-blue.svg)\n[![](https://img.shields.io/badge/PyPi-v1.13.0-blue.svg)](https://pypi.org/project/calcbsimpvol/)\n\n# calcbsimpvol\n\n*Calculate Black-Scholes Implied Volatility - Vectorwise*\n\n----------------------\n\n* `:)` native python code\n* `:)` lightweight footprint\n* `:)` sample data included\n* `:(` not suited for single / low number of options\n* `:(` code reads un-pythonic\n* `:(` not yet thoroughly tested\n\n## Getting started\n\n### Requirements\n\n* Python 3.x (currently) or PyPy3\n* NumPy\n* SciPy\n* (MatPlotLib to visualize results in some examples)\n\n### Installation\n\nWhile the code consists of single digit functions,\nI recommend using the `pip install` way to get the code.\nThat way you would take advantage of bug fixes, updates,\nand possible extensions.\n\n```bash\n$ pip install calcbsimpvol\n```\n\n### Example\n\nPass your `args` bundled in a `dict`.\n\n```python\nfrom calcbsimpvol import calcbsimpvol\nimport numpy as np\n\nS = np.asarray(100)\nK_value = np.arange(40, 160, 25)\nK = np.ones((np.size(K_value), 1))\nK[:, 0] = K_value\ntau_value = np.arange(0.25, 1.01, 0.25)\ntau = np.ones((np.size(tau_value), 1))\ntau[:, 0] = tau_value\nr = np.asarray(0.01)\nq = np.asarray(0.03)\ncp = np.asarray(1)\nP = [[59.35, 34.41, 10.34, 0.50, 0.01],\n[58.71, 33.85, 10.99, 1.36, 0.14],\n[58.07, 33.35, 11.50, 2.12, 0.40],\n[57.44, 32.91, 11.90, 2.77, 0.70]]\n\nP = np.asarray(P)\n[K, tau] = np.meshgrid(K, tau)\n\nsigma = calcbsimpvol(dict(cp=cp, P=P, S=S, K=K, tau=tau, r=r, q=q))\nprint(sigma)\n\n# [[ nan, nan, 0.20709362, 0.21820954, 0.24188675],\n# [ nan, 0.22279836, 0.20240934, 0.21386148, 0.23738982],\n# [ nan, 0.22442837, 0.1987048 , 0.21063506, 0.23450013],\n# [ nan, 0.22188111, 0.19564657, 0.20798285, 0.23045406]]\n\n```\n\nMore usage examples are available in [example3.py](https://github.com/erkandem/calcbsimpvol) \n(additional sample data required which is available at [GitHub Repo](https://github.com/erkandem/calcbsimpvol)\n\n## Performance\n```\nDesign a test. \nGet the results you want.\n```\n\n* `k_max = 10` (default) \n* `tolerance = 10E-12` (default)\n* linear regression steps are commented out (default)\n\n```bash\n# assuming you did install it already\ngit clone https://github.com/erkandem/calcbsimpvol.git\ncd calcbsimpvol\npython examples/example3.py --steps 100 --mode reference\n```\n\n\n* 15 \u00b5s per option\n* 41 ms per surface\n\ntested with 3.6, 3.7 and PyPy3\n```bash\nmatlab -nodisplay -nosplash -nodesktop -r \"run('mlb_reference_example.m');\"\n```\n\n* 12 \u00b5s per option\n* 34 ms per surface \n\n\nObviously, these values are per core (i5 4210U 1.7 GHz).\n\n\n## Notes\nGood Python code reads like a novel. Right? So should math.\nI preferred short math-like variable names in this case.\nThat makes the code less readable compared to other Python code \nbut the docstrings should make up for the lack of readability.\n\nOriginally, I left the camelCase function name and spelling in place but eventually got annoyed.\n> calcbsimpvol it is\n\n\n## Code Origin\n\n* first thought of by Li (2006) (see References)\n* implemented and published by Mark Whirdy as MATLAB .m-code (see References)\n* numpyified from `.m` to `.py` by me\n\n\n## Contact\n* email: [erkan@erkan.io](mailto:me@erkan.io)\n* documentation: [erkandem.github.io/calcbsimpvol/](https://erkandem.github.io/calcbsimpvol/)\n* source: [github.com/erkandem/calcbsimpvol](https://github.com/erkandem/calcbsimpvol)\n* issues: [github.com/erkandem/calcbsimpvol/issues](https://github.com/erkandem/calcbsimpvol/issues)\n* author website: [erkan.io](https://erkan.io) (under construction)\n\n## ToDos\n* make the code compatible with `Python 2`\n* make it `PyPy`\n\n\n\n## References\n1) Li, 2006, \"You Don't Have to Bother Newton for Implied Volatility\"\n\n [http://papers.ssrn.com/sol3/papers.cfm?abstract_id=952727](http://papers.ssrn.com/sol3/papers.cfm?abstract_id=952727)\n\n2) MATLAB source code available at:\n\n [https://www.mathworks.com/matlabcentral/fileexchange/41473-calcbsimpvol-cp-p-s-k-t-r-q](https://www.mathworks.com/matlabcentral/fileexchange/41473-calcbsimpvol-cp-p-s-k-t-r-q)\n\n## License\nThe included Python code is licensed under `MIT` [License](https://github.com/calcbsimpvol/calcbsimpvol/LICENCE)\n\nThe Code by Mark Whirdy is licensed under `MIT` [License](https://github.com/erkandem/calcbsimpvol/calcBSImpVol_mlab/LICENSE)\n\nThe translation is not related or endorsed by the original author.\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://erkandem.github.io/calcbsimpvol/", "keywords": "options implied volatility option iv ivol options-on-futures ivsurface black-scholes", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "calcbsimpvol", "package_url": "https://pypi.org/project/calcbsimpvol/", "platform": "", "project_url": "https://pypi.org/project/calcbsimpvol/", "project_urls": { "Bug Reports": "https://github.com/erkandem/calcbsimpvol/issues", "Documentation": "https://erkandem.github.io/calcbsimpvol/", "Homepage": "https://erkandem.github.io/calcbsimpvol/", "Source": "https://github.com/erkandem/calcbsimpvol" }, "release_url": "https://pypi.org/project/calcbsimpvol/1.13.0/", "requires_dist": [ "numpy", "scipy", "matplotlib" ], "requires_python": "", "summary": "Calculate Black Scholes Implied Volatility - Vectorwise", "version": "1.13.0" }, "last_serial": 4763691, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "7d5fd3eb411fe77c91ab8f2d3aca9016", "sha256": "73ea20e5397bf4c21ee6c045dc740f4355981b54db0e32e2fdd45d91fb0ae0e2" }, "downloads": -1, "filename": "calcbsimpvol-0.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "7d5fd3eb411fe77c91ab8f2d3aca9016", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 1439, "upload_time": "2019-01-12T16:42:47", "url": "https://files.pythonhosted.org/packages/0f/0e/0474cf5f96d257a732fa90a6a27364e4ab7292183edd09bda4782fbcf0ba/calcbsimpvol-0.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "1f155cf2f985dc226b4b913c6eee0908", "sha256": "3c0fb55569feabd4f0893f9e790f1340c578f08af8a7c5c0ec7e74c7e178a44f" }, "downloads": -1, "filename": "calcbsimpvol-0.0.1.tar.gz", "has_sig": false, "md5_digest": "1f155cf2f985dc226b4b913c6eee0908", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 1297, "upload_time": "2019-01-12T16:42:49", "url": "https://files.pythonhosted.org/packages/80/fa/a2d998782d46585af657ec2edac6bff6fba494b3ef4f3de8a852bdb179c1/calcbsimpvol-0.0.1.tar.gz" } ], "1.13.0": [ { "comment_text": "", "digests": { "md5": "af32792e734677f02e28587e3cfbcd36", "sha256": "82c0abca239f24c1cf88efb1ccc50a1548825ed66085830399eb787af19ff3bc" }, "downloads": -1, "filename": "calcbsimpvol-1.13.0-py3-none-any.whl", "has_sig": false, "md5_digest": "af32792e734677f02e28587e3cfbcd36", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 442154, "upload_time": "2019-01-31T13:26:31", "url": "https://files.pythonhosted.org/packages/30/75/b615b38364e186be3922b1ce4144497e34eec7f8f4a9b39e472ef2bedf4c/calcbsimpvol-1.13.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "2eb84add62f8befac1b8c206db9a3945", "sha256": "5a670b43b31e5eec195f0292e8ebd837cbdc27c17ad487c002fba6bb85a29392" }, "downloads": -1, "filename": "calcbsimpvol-1.13.0.tar.gz", "has_sig": false, "md5_digest": "2eb84add62f8befac1b8c206db9a3945", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 438582, "upload_time": "2019-01-31T13:26:41", "url": "https://files.pythonhosted.org/packages/e5/3a/df99a1c89478b94715b3beffae0641a9fc1ab80e4b41168713a0ca5cb483/calcbsimpvol-1.13.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "af32792e734677f02e28587e3cfbcd36", "sha256": "82c0abca239f24c1cf88efb1ccc50a1548825ed66085830399eb787af19ff3bc" }, "downloads": -1, "filename": "calcbsimpvol-1.13.0-py3-none-any.whl", "has_sig": false, "md5_digest": "af32792e734677f02e28587e3cfbcd36", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 442154, "upload_time": "2019-01-31T13:26:31", "url": "https://files.pythonhosted.org/packages/30/75/b615b38364e186be3922b1ce4144497e34eec7f8f4a9b39e472ef2bedf4c/calcbsimpvol-1.13.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "2eb84add62f8befac1b8c206db9a3945", "sha256": "5a670b43b31e5eec195f0292e8ebd837cbdc27c17ad487c002fba6bb85a29392" }, "downloads": -1, "filename": "calcbsimpvol-1.13.0.tar.gz", "has_sig": false, "md5_digest": "2eb84add62f8befac1b8c206db9a3945", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 438582, "upload_time": "2019-01-31T13:26:41", "url": "https://files.pythonhosted.org/packages/e5/3a/df99a1c89478b94715b3beffae0641a9fc1ab80e4b41168713a0ca5cb483/calcbsimpvol-1.13.0.tar.gz" } ] }