Derivative pricing formulas implemented by Python and Numpy

## Project description

## Delib

Delib is a python library for pricing derivatives. Currently it supports only:

- Forward price estimation based on Put-Call parity
- Forward option pricing based on the Black model

### Installing

Install and update using pip:

```
pip install -U delib
```

### Simple Examples

Estimate forward price of underlying asset from put and call options:

```
import numpy as np
from delib.forward import forward
p = np.array([14.35, 17.18]) # Put option price
c = np.array([19.60, 17.00]) # Call option price
K = np.array([2780, 2785]) # Strike price
r = np.array([0.0196, 0.0196]) # Risk free rate (annual rate)
T = np.array([8/252, 8/252]) # Time to maturity
F = forward(p, c, K, r, T) # Estimate forward price
```

If an underlying asset of an option have a forward price, you can compute a theoretical option price based on the Black model:

```
import numpy as np
from delib.option import black
pc = np.array([-1, 1]) # Put(-1) Call(+1) indicator
F = np.array([20, 1240]) # Forward price of the underlying asset
K = np.array([20, 1200]) # Strike price
r = np.array([0.09, 0.05]) # Risk free rate (annual rate)
T = np.array([4/12, 6/12]) # Time to maturity
s = np.array([0.25, 0.20]) # Volatility
df = black(pc, F, K, r, T, s=s) # Compute an option price and some useful greeks
print(df['price'], df['delta'], df['theta'])
```

If you don't know a volatility but you have market prices of options, you can calculate implied volatilities by black() function:

```
import numpy as np
from delib.option import black
pc = np.array([-1, 1]) # Put(-1) Call(+1) indicator
F = np.array([20, 1240]) # Forward price of the underlying asset
K = np.array([20, 1200]) # Strike price
r = np.array([0.09, 0.05]) # Risk free rate (annual rate)
T = np.array([4/12, 6/12]) # Time to maturity
p = np.array([1.12, 88.37]) # Market price of options
df = black(pc, F, K, r, T, p=p) # Compute implied volatilities
print(df['price'], df['vol'], df['delta'])
```

## Project details

## Release history Release notifications

## Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help | File type | Python version | Upload date |
---|---|---|---|

delib-0.0.1-py3-none-any.whl (5.4 kB) Copy SHA256 hash SHA256 | Wheel | py3 | Jul 11, 2018 |

delib-0.0.1.tar.gz (4.0 kB) Copy SHA256 hash SHA256 | Source | None | Jul 11, 2018 |