0

my data is as follow:

enter image description here

and I first plot volatility surface for this:

surface = (
 calls[['Time_To_Maturity', 'Strike_Price', 'Implied_Volatility']]
 .pivot_table(values='Implied_Volatility', index='Strike_Price', columns='Time_To_Maturity')
 .dropna()
)

X, Y = np.meshgrid(surface.columns, surface.index)
Z = surface.values

fig = plt.figure(figsize=(10, 8))
ax = fig.add_subplot(111, projection='3d')

ax.plot_surface(X, Y, Z, cmap='viridis', edgecolor='gray', linewidth=0.1)

ax.set_xlabel('Time to Maturity')
ax.set_ylabel('Strike Price')
ax.set_zlabel('Implied Volatility')

plt.title('Implied Volatility Surface')
plt.show()

and got this: enter image description here I am quite confused. there is 33000 in data for strike price, but on the plot, maximum is just 32000.

And then I tried to plot a volatility surface replacing strike price with moneyness. I used the similar code:

surface = (calls[['Time_To_Maturity', 'Moneyness','Implied_Volatility']].pivot_table(values='Implied_Volatility', index='Moneyness',columns='Time_To_Maturity').dropna())
X, Y = np.meshgrid(surface.columns, surface.index)
Z = surface.values
fig = plt.figure(figsize=(10, 8))
ax = fig.add_subplot(111, projection='3d')

ax.plot_surface(X, Y, Z, cmap='viridis', edgecolor='gray', linewidth=0.1)

ax.set_xlabel('Time to Maturity')
ax.set_ylabel('Moneyness')
ax.set_zlabel('Implied Volatility')

plt.title('Implied Volatility Surface')
plt.show()

But got empty graph: enter image description here

I don't know why. Could anyone help me with that?

eng
  • 443
  • 1
  • 4
  • 10

0 Answers0