|
From: Luigi B. <lui...@gm...> - 2018-02-05 08:33:42
|
Just for future reference: this was solved on https://github.com/lballabio/QuantLib-SWIG/issues/98. (Thanks, Peter and Benjamin.) Luigi On Mon, Feb 5, 2018 at 9:26 AM bjonen <bj...@gm...> wrote: > I'm having trouble using the BlackSwaptionEngine with displacement. While > the > displacement can be passed to the ql.BlackSwaptionEngine, swap.blackPrice > returns an error indicating that the displacement is ignored (this is > QuantLib 1.12 on Linux). > > forward_rate = -0.01 > day_count = ql.Thirty360() > todays_date = ql.Date(20, 10, 2017) > spot_curve = ql.FlatForward(todays_date, > ql.QuoteHandle(ql.SimpleQuote(forward_rate)), > day_count) > termstruct = ql.YieldTermStructureHandle(spot_curve) > displacement = 0.5 > eng = ql.BlackSwaptionEngine(termstruct, > ql.QuoteHandle(ql.SimpleQuote(0.1)), ql.Actual365Fixed(), displacement) > index = ql.USDLibor(ql.Period(3, ql.Months), termstruct) > swap = ql.SwaptionHelper(ql.Period(2, ql.Years), ql.Period(3, ql.Years), > ql.QuoteHandle(ql.SimpleQuote(0.15)), index, > index.tenor(), index.dayCounter(), > index.dayCounter(), termstruct) > swap.setPricingEngine(eng) > swap.blackPrice(0.1) > > RuntimeErrorTraceback (most recent call last) > <ipython-input-125-7c601816769d> in <module>() > 13 index.dayCounter(), termstruct) > 14 swap.setPricingEngine(eng) > ---> 15 swap.blackPrice(0.1) > > /opt/conda/envs/main/lib/python2.7/site-packages/QuantLib/QuantLib.py in > blackPrice(self, volatility) > 10116 > 10117 def blackPrice(self, volatility): > > 10118 return _QuantLib.CalibrationHelper_blackPrice(self, > > volatility) > 10119 > 10120 def volatility(self): > > RuntimeError: strike + displacement (-0.00984189 + 0) must be non-negative > > This question is related to > > http://quantlib.10058.n7.nabble.com/Swaption-pricing-with-negative-rates-in-python-td17714.html > > Also I posted the question on github but realized that probably more people > read this mailing list > (https://github.com/lballabio/QuantLib-SWIG/issues/98). > > Am I missing something? > > > > -- > Sent from: http://quantlib.10058.n7.nabble.com/quantlib-users-f3.html > > > ------------------------------------------------------------------------------ > Check out the vibrant tech community on one of the world's most > engaging tech sites, Slashdot.org! http://sdm.link/slashdot > _______________________________________________ > QuantLib-users mailing list > Qua...@li... > https://lists.sourceforge.net/lists/listinfo/quantlib-users > |