我正在尝试使用以下代码绘制波动率表面:
plot_years = np.arange(0, 2, 0.1)
plot_strikes = np.arange(535, 750, 1)
fig = plt.figure()
ax = fig.gca(projection='3d')
X, Y = np.meshgrid(plot_strikes, plot_years)
Z = np.array([black_var_surface.blackVol(y, x)
for xr, yr in zip(X, Y)
for x, y in zip(xr,yr) ]
).reshape(len(X), len(X[0]))
surf = ax.plot_surface(X,Y,Z, rstride=1, cstride=1, cmap=cm.coolwarm,
linewidth=0.1)
fig.colorbar(surf, shrink=0.5, aspect=5)
但我得到这个错误:
TypeError Traceback (most recent call last)
<ipython-input-55-8132b1b292ed> in <module>
4 ax = fig.gca(projection='3d')
5 X, Y = np.meshgrid(plot_strikes, plot_years)
----> 6 Z = np.array([black_var_surface.blackVol(y, x)
7 for xr, yr in zip(X, Y)
8 for x, y in zip(xr,yr) ]
<ipython-input-55-8132b1b292ed> in <listcomp>(.0)
4 ax = fig.gca(projection='3d')
5 X, Y = np.meshgrid(plot_strikes, plot_years)
----> 6 Z = np.array([black_var_surface.blackVol(y, x)
7 for xr, yr in zip(X, Y)
8 for x, y in zip(xr,yr) ]
~\anaconda3\lib\site-packages\QuantLib\QuantLib.py in blackVol(self, *args)
7566
7567 def blackVol(self, *args):
-> 7568 return _QuantLib.BlackVolTermStructure_blackVol(self, *args)
7569
7570 def blackVariance(self, *args):
TypeError: Wrong number or type of arguments for overloaded function 'BlackVolTermStructure_blackVol'.
Possible C/C++ prototypes are:
BlackVolTermStructure::blackVol(Date const &,Real,bool) const
BlackVolTermStructure::blackVol(Date const &,Real) const
BlackVolTermStructure::blackVol(Time,Real,bool) const
BlackVolTermStructure::blackVol(Time,Real) const
我使用的是旧版本的软件包吗?因为我正在使用 Goutham Balaraman 在 2016 年分享的笔记本。
谢谢您的帮助 !