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 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); |
On Dec 20, 2007, at 2:37 AM, vema wrote: > 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 &' Mahesh, this is fixed in the upcoming 0.9.0 release. In the meantime, instead of dividends = (0.07,0.5) you'll have to use the more verbose: dividends = DoubleVector(2) dividends[0] = 0.07 dividends[1] = 0.5 Later, Luigi ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Free forum by Nabble | Edit this page |