```python
import numpy as np
import scipy.stats as si
import sympy as sy
from sympy.stats import Normal, cdf
```


```python
def black_scholes(S, K, T, r, q, sigma, option):
    
    #S: spot price
    #K: strike price
    #T: time to maturity
    #r: interest rate
    #q: rate of continuous dividend paying asset 
    #sigma: volatility of underlying asset
    #option: "call" or "put"
    
    if option is "call":
        d1 = (np.log(S / K) + (r - q + 0.5 * sigma ** 2) * T) / (sigma * np.sqrt(T))
        d2 = (np.log(S / K) + (r - q - 0.5 * sigma ** 2) * T) / (sigma * np.sqrt(T))
        
        call = (S * np.exp(-q * T) * si.norm.cdf(d1, 0.0, 1.0) - K * np.exp(-r * T) * si.norm.cdf(d2, 0.0, 1.0))
        return call
    
    elif option is "put":
        d1 = (np.log(S / K) + (r - q + 0.5 * sigma ** 2) * T) / (sigma * np.sqrt(T))
        d2 = (np.log(S / K) + (r - q - 0.5 * sigma ** 2) * T) / (sigma * np.sqrt(T))
        
        put = (K * np.exp(-r * T) * si.norm.cdf(-d2, 0.0, 1.0) - S * np.exp(-q * T) * si.norm.cdf(-d1, 0.0, 1.0))
        return put
    
    else:
        print("you've made an error")
```


```python
# Price of a put option expiring in one year with strike price €100
# Current share price is €50
# dividend yield of 0, risk free rate of 0.05 and volatility of 0.25

black_scholes(50, 100, 1, 0.05, 0, 0.25, option = 'put')
```




    45.15029495944084




```python

    
    
```


```python

```

b44fe81610ece8f5dbcc84610cfb926f4c67e0c8
ipynb
Jupyter Notebook
Black-Scholes Pricing.ipynb
jackapbutler/Black-Scholes-Option-Pricing
b6207ee39ac5ce206d391fdeff530c96877a0fcf
MIT
Black-Scholes Pricing.ipynb
jackapbutler/Black-Scholes-Option-Pricing
b6207ee39ac5ce206d391fdeff530c96877a0fcf
MIT
Black-Scholes Pricing.ipynb
jackapbutler/Black-Scholes-Option-Pricing
b6207ee39ac5ce206d391fdeff530c96877a0fcf
MIT
Qwen/Qwen-72B
1. YES
2. YES