Awesome but light option price calculator in Python
Project description
option-price
option-price
is a Python-based powerful but simple option price calculator. A GUI version is available here. It makes use of vectorization, which makes it pretty fast.
Installation
pip install option-price
Installation
pip install option-price
Quick Start
from optionprice import Option
An option can be initialized by:
some_option = Option(european=False,
kind=1,
s0=100,
k=120,
t=45,
sigma=0.01,
r=0.05,
dv=0)
Attributes
Name | Type | Definition |
---|---|---|
european | boolean | True if the option is an European option and False if it's an American one. |
kind | int | 1 for call option while -1 for put option. Other number are not valid. |
s0 | number | initial price |
k | int | strike price |
t | int | length of option in days |
sigma | float | volatility of stock |
r | float | risk free interest rate per annum |
dv | float | dividend rate. 0 for non-stock option, which is also the default |
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 5000. Note that the larger the value, the slower and more precise the price.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for option_price-0.1.7-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3c2d51fc1b3228f661cceaeb78af0852c7cf2ebf601df9905b5068f8e2d73bcc |
|
MD5 | ae32d0a67fb4b2c1257d78e4435c48c0 |
|
BLAKE2b-256 | cda437a2a8d06e278da11dce6fa61b90a343eb7d278bac08ccd0485d17eb9e86 |