-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtest_plot.py
More file actions
34 lines (26 loc) · 782 Bytes
/
Copy pathtest_plot.py
File metadata and controls
34 lines (26 loc) · 782 Bytes
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
import pandas as pd
import matplotlib.pyplot as plt
from vol_surface import VolatilitySurface
df = pd.read_csv('data/spy_options.csv')
surface = VolatilitySurface(S=590, r=0.045)
surface.load_data(df)
surface.compute_ivs()
# Test smile plot
print("Displaying smile plot...")
surface.plot_smile(expiry=df['expiry'].iloc[0])
plt.show()
# Test SVI fitting and surface
print("Fitting SVI and displaying surface...")
surface.fit_svi()
surface.plot_surface_3d(model='svi')
plt.show()
# Plot raw market data (no fitting needed)
print("Displaying market surface...")
surface.plot_surface_3d(model='market')
plt.show()
# Test term structure
print("Displaying term structure...")
surface.term_structure(moneyness=1.0)
plt.show()
surface.summary()
print("\nOK - All plots displayed!")