-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpart1.py
30 lines (25 loc) · 946 Bytes
/
part1.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from stock_simulations import BetaMotion, European_Call_Payoff
import matplotlib.pyplot as plt
import numpy as np
# Model Parameters
paths = 5000 #iterations?
initial_price = 100
drift = -0.01
volatility = 0.5
dt = 1/365
T = 1
price_paths = []
# Generate a set of sample paths
for i in range(0, paths):
price_paths.append(BetaMotion(initial_price, drift, volatility, dt, T).prices)
call_payoffs = []
ec = European_Call_Payoff(initial_price)
risk_free_rate = .01
for price_path in price_paths:
call_payoffs.append(ec.get_payoff(price_path[-1])/(1 + risk_free_rate)) # We get the last stock price in the series generated by GBM to determin the payoff and discount it by one year
# Plot the set of generated sample paths
for price_path in price_paths:
plt.plot(price_path)
plt.show()
average_payoff = round(np.average(call_payoffs)*100, 2)
print(f"Average payoff for 100 options: ${average_payoff}") # Options are in blocks of 100