1
下面是我使用Quantlib blackvariance表面的代碼。但它抱怨。你能建議嗎?在這個函數中,我調用Blackvariance功能與6個變量Quantlib - BlackVariancesurface
from QuantLib import *
# global data
todaysDate = Date(24,September,2013)
Settings.instance().evaluationDate = todaysDate
settlementDate = Date(24,September,2013)
riskFreeRate = FlatForward(settlementDate, 0.0025, Actual365Fixed())
# option parameters
exercise = EuropeanExercise(Date(23,December,2013))
payoff = PlainVanillaPayoff(Option.Call, 170.365)
# market data
underlying = SimpleQuote(170.365)
volatility = BlackConstantVol(todaysDate, TARGET(), 0.13538, Actual365Fixed())
dividendYield = FlatForward(settlementDate, 0.0227, Actual365Fixed())
dc=ActualActual()
eurexCal=Germany.Eurex
print eurexCal
dateVec=[]
strikes=[]
blackVolMatrix=[]
vol=[]
for i in range(10):
dateVec.append(Date(24, October, 2013)+Period(i, Months))
strikes.append(170+i*10)
vol.append(0.1+i/10)
def create_matrix(m, n):
return [[0.1]*n for _ in xrange(m)]
blackVolMatrix = create_matrix(10, 10)
#for x in range (10):
# for y in range(10):
# blackVolMatrix[x,y]=0.1
volsurf=BlackVarianceSurface(settlementDate,eurexCal,dateVec,
strikes,blackVolMatrix,dc)
我已經加入了第六的說法。 * ** * ** * ** * *
錯誤消息:
Traceback (most recent call last):
File "/home/chandra/Software/snotes/test4.py", line 39, in <module>
strikes,blackVolMatrix,dc)
File "/usr/local/lib/python2.7/dist-packages/QuantLib/QuantLib.py", line 3371, in __init__
this = _QuantLib.new_BlackVarianceSurface(*args)
NotImplementedError: Wrong number or type of arguments for overloaded function 'new_BlackVarianceSurface'.
Possible C/C++ prototypes are:
BlackVarianceSurfacePtr(Date const &,Calendar const &,std::vector< Date,std::allocator<Date> > const &,std::vector< Real,std::allocator<Real> > const &,Matrix const &,DayCounter const &,BlackVarianceSurface::Extrapolation,BlackVarianceSurface::Extrapolation)
BlackVarianceSurfacePtr(Date const &,Calendar const &,std::vector< Date,std::allocator<Date> > const &,std::vector< Real,std::allocator<Real> > const &,Matrix const &,DayCounter const &,BlackVarianceSurface::Extrapolation)
BlackVarianceSurfacePtr(Date const &,Calendar const &,std::vector< Date,std::allocator<Date> > const &,std::vector< Real,std::allocator<Real> > const &,Matrix const &,DayCounter const &)
據我統計該類型需要6,7或8個參數,但你的代碼只傳遞在5 –
volsurf = BlackVarianceSurface(settlementDate,eurexCal,dateVec, 罷工,blackVolMatrix,DC) 它仍然給同樣的錯誤。 (這是一個錯字,我沒有包括日計數) –
然後參數*類型*不正確。請編輯你的問題,至少糾正那個缺失的論點。 –