-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
61 lines (47 loc) · 1.53 KB
/
main.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
def plotQ1paths():
# Read the CSV data into a pandas DataFrame
data = pd.read_csv("Q1path.csv", header=None)
# Plotting all paths
plt.figure(figsize=(10, 6))
for index, row in data.iterrows():
plt.plot(row, linewidth=0.5)
plt.title("Stock Price Paths")
plt.xlabel("Time Steps")
plt.ylabel("Stock Price")
plt.savefig("Q1_path_self.png")
plt.show()
plt.close()
def plotQ1HE():
# Assuming the hedging errors data is in a list called 'hedging_errors'
hedging_errors = pd.read_csv("Q1HE.csv", header=None).iloc[:,:100]
hedging_errors = hedging_errors.values.reshape(-1)
# Plotting the distribution
plt.figure(figsize=(10, 6))
sns.histplot(hedging_errors, kde=True, bins=30)
plt.title("Distribution of Hedging Errors")
plt.xlabel("Hedging Error Value")
plt.ylabel("Frequency")
plt.grid(True)
plt.savefig("Q1_HE_self.png")
plt.show()
plt.close()
def plotQ1Option():
# Load the data
data = pd.read_csv("Q1option_values.csv", header=None).T
# Plotting all paths
plt.figure(figsize=(10, 6))
for index, row in data.iterrows():
plt.plot(row, linewidth=0.5)
plt.title("Option Price Paths")
plt.xlabel("Time Steps")
plt.ylabel("Option Price")
plt.savefig("Q1_Option.png")
plt.show()
plt.close()
if __name__ == "__main__":
# plotQ1paths()
# plotQ1HE()
plotQ1Option()