option-price
option-price is a Python-based powerful but simple option price calculator. It makes use of vectorization, which makes it pretty fast.
A GUI version is available here.
Docs are available here.
Installation
pip install option-price
Quick Start
from optionprice import Option
An option can be initialized by:
some_option = Option(european=True,
kind='put',
s0=100,
k=120,
t=45,
sigma=0.01,
r=0.05,
dv=0)
Or
some_option = Option(european=False,
kind='call',
s0=120,
k=100,
sigma=0.01,
r=0.05,
start='2008-2-14',
end='2008-3-14',
dv=0)
You can check the option by
print(some_option)
which will print out the option’s info.
Type: European
Kind: call
Price initial: 80
Price strike: 120
Volatility: 1.0%
Risk free rate: 5.0%
Start Date: 2020-03-24
Expire Date: 2020-04-24
Time span: 31.0 days
Attributes
| Name | Type | Definition |
|---|---|---|
| european | boolean | True if the option is an European option and False if it's an American one. |
| kind | str | ‘call’ for call option while ‘put’ for put option. Other strs are not valid. |
| s0 | number | initial price |
| k | int | strike price |
| sigma | float | volatility of stock |
| r | float | risk free interest rate per annum |
| [optional] dv | float | dividend rate. 0 for non-stock option, which is also the default |
| [optional] t | int | length of option in days |
| [optional] start | str | beginning date of the option, string like '2008-02-14',default today |
| [optional] end | str | end date of the option, string like '2008-02-14',default today plus param t |
Note that if start,end and t are all given, then t will choose the difference between end and start
Also, either t or (start and end) should exists
Calculate
option-price has three approaches to calculate the price of the price of the option. They are
- B-S-M
- Monte Carlo
- Binomial Tree
option-price will choose B-S-M algorithm by default. Prices can be simply calculated by
price = some_option.getPrice()
Other methods of calculation are available by adding some parameters. For instance,
price = some_option.getPrice(method='MC',iteration = 500000)
or
price = some_option.getPrice(method='BT',iteration = 1000)
while MC stands for Monte Carlo and BT stands for Binomial Tree.
The iteration has a default value. Note that the larger the value, the slower and more precise the price.
Default value is a balance of speed and accuracy.
Release files for option-price 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| option-price-0.2.0.tar.gz | 5.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| option_price-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 11.1 kB
Release files / option-price-0.2.0.tar.gz
| Download URL | option-price-0.2.0.tar.gz |
|---|---|
| Size | 5.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2c1fd30a2b1b6c4f8a3cd59301b074c453b3b363867fd6ae3d46c3ca14d9168b
|
|
BLAKE2b-256 checksum How to use checksums |
b109149ef50e8481f9791f5c079ec19a320e42766cc5341338f1396fdca5020c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.6
|
Release files / option_price-0.2.0-py3-none-any.whl
| Download URL | option_price-0.2.0-py3-none-any.whl |
|---|---|
| Size | 5.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8a218e8bc0119593d2a8aea0484ec3e8527f400e1a599dbe4ac7683de1305f00
|
|
BLAKE2b-256 checksum How to use checksums |
f0122efe484e73407fe73690a398d480408d9e698458531c5569a55dedbe87af
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.6
|