Python Swig TypeError in DividendVanillaOption method
Posted by vema on
URL: http://quantlib.414.s1.nabble.com/Python-Swig-TypeError-in-DividendVanillaOption-method-tp5356.html
Hi,
I am trying to evaluate the price of a dividend American Option and i was using the DividendVanillaOption method for obtaining it in Python. (I have been abel to successfuly build the Quantlib libs via the SWIG-python access methods)
However I am gettign this error which says
dividendDates=(Date(17,June,1998),Date(17,July,1998))
dividends=(0.07,0.5)
option = DividendVanillaOption(payoff,exercise,dividendDates,dividends);
TypeError: in method 'new_DividendVanillaOption', argument 4 of type 'std::vector<Real,std::allocator<Real > > const &'
The entire code is as below. The fourth argument is definitely creating a problem. I am toying around with a similar function called RealtimeSeries in Quantlib which takes as arguments the dates and the values and I havent had any problems with it as such. I somehow feel that the problem is much more subtle. I greatly appreciate any help in this matter.
Thanking You
Mahesh Vemula
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
from QuantLib import *
# global data
todaysDate = Date(15,May,1998)
Settings.instance().evaluationDate = todaysDate
settlementDate = Date(17,September,1998)
riskFreeRate = FlatForward(settlementDate, 0.06, Actual365Fixed())
# option parameters
exercise = AmericanExercise(settlementDate, Date(17,May,1999))
payoff = PlainVanillaPayoff(Option.Put, 40.0)
# market data
underlying = SimpleQuote(36.0)
volatility = BlackConstantVol(todaysDate, TARGET(), 0.20, Actual365Fixed())
dividendYield = FlatForward(settlementDate, 0.00, Actual365Fixed())
# report
header = '%19s' % 'method' + ' |' + \
' |'.join(['%17s' % tag for tag in ['value',
'estimated error',
'actual error' ] ])
print
print header
print '-'*len(header)
refValue = None
def report(method, x, dx = None):
e = '%.4f' % abs(x-refValue)
x = '%.5f' % x
if dx:
dx = '%.4f' % dx
else:
dx = 'n/a'
print '%19s' % method + ' |' + \
' |'.join(['%17s' % y for y in [x, dx, e] ])
# good to go
process = BlackScholesMertonProcess(QuoteHandle(underlying),
YieldTermStructureHandle(dividendYield),
YieldTermStructureHandle(riskFreeRate),
BlackVolTermStructureHandle(volatility))
#option = VanillaOption(payoff, exercise)
dividendDates=(Date(17,June,1998),Date(17,July,1998))
dividends=(0.07,0.5)
option = DividendVanillaOption(payoff,exercise,dividendDates,dividends);