Login  Register

Re: European option validation

Posted by Luigi Ballabio on Jan 09, 2013; 8:42am
URL: http://quantlib.414.s1.nabble.com/Re-European-option-validation-tp13880p13886.html

Here's the transcript of my Python session.

Python 2.7.3 (default, Sep 26 2012, 21:53:58)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.

>>> from QuantLib import *
>>>
>>> today = Date.todaysDate()
>>>
>>> spot = SimpleQuote(100.0)
>>> q = SimpleQuote(0.0)
>>> r = SimpleQuote(0.1)
>>> vol = SimpleQuote(0.5)
>>>
>>> dc = Actual360()
>>> rTS = FlatForward(today, QuoteHandle(r), dc)
>>> qTS = FlatForward(today, QuoteHandle(q), dc)
>>> volTS = BlackConstantVol(today, NullCalendar(), QuoteHandle(vol), dc)
>>>
>>> process = BlackScholesMertonProcess(
...     QuoteHandle(spot),
...     YieldTermStructureHandle(qTS),
...     YieldTermStructureHandle(rTS),
...     BlackVolTermStructureHandle(volTS))

>>>
>>> exerciseDate = today+90
>>> exercise = EuropeanExercise(exerciseDate)
>>>
>>> payoff = PlainVanillaPayoff(Option.Call, 97.0)
>>>
>>> option = EuropeanOption(payoff, exercise)
>>> engine = AnalyticEuropeanEngine(process)
>>> option.setPricingEngine(engine)
>>>
>>> option.NPV()
12.612666351689272
>>>

On Wed, Jan 9, 2013 at 6:13 AM, ray 176 <[hidden email]> wrote:

> Can you post me your code.
>
> I still can't get it to give  a valid results
> DayCounter is Actual360 and today date is used for yield term structure as
> per below.
>
>
> QuantLib::DayCounter dc = QuantLib::Actual360();
> QuantLib::Date today = QuantLib::Date::todaysDate();
>
> boost::shared_ptr<QuantLib::YieldTermStructure> rTS = flatRate(today, rRate,
> dc);
>
> boost::shared_ptr<QuantLib::YieldTermStructure>
>     flatRate(const QuantLib::Date& today,
>              const boost::shared_ptr<QuantLib::Quote>& forward,
>              const QuantLib::DayCounter& dc) {
>         return boost::shared_ptr<QuantLib::YieldTermStructure>(
>                           new QuantLib::FlatForward(today,
> QuantLib::Handle<QuantLib::Quote>(forward), dc));
>     }
>
>
>
> On 9 January 2013 00:47, Luigi Ballabio <[hidden email]> wrote:
>>
>> tried the thing in QuantLib via Pyt
>
>
>

------------------------------------------------------------------------------
Master Java SE, Java EE, Eclipse, Spring, Hibernate, JavaScript, jQuery
and much more. Keep your Java skills current with LearnJavaNow -
200+ hours of step-by-step video tutorials by Java experts.
SALE $49.99 this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122612 
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev