Re: Option Expiry using Date and time (intraday decay/fractional days)

Posted by Slava Mazur-2 on
URL: http://quantlib.414.s1.nabble.com/Option-Expiry-using-Date-and-time-intraday-decay-fractional-days-tp140p142.html

Greetings,

I'd recommend changing the underlying type from BigInteger to something more relevant to time arithmetic or better yet providing the underlying type as a template parameter.
This way the new date-time class would serve a simple wrapper around other existing time arithmetic solutions like time_t, Boost date time, etc.
I realize however, that given the current state of this project such a suggestion has a slim chance to succeed, so consider it just an idea.

Slava Mazur

-----Original Message-----
From: Luigi Ballabio [mailto:[hidden email]]
Sent: Thursday, March 01, 2012 4:19 AM
To: Shailesh Parmar
Cc: [hidden email]
Subject: Re: [Quantlib-users] Option Expiry using Date and time (intraday decay/fractional days)

Hi,
    it's probably not that easy.  You might try adding a time part to the Date class (which is delicate work, since you'll have to make sure that the whole date algebra still works correctly).  At that point, modifying DayCounter::yearFraction so that it takes the added time part into account should cause all term structures to work correctly and your calculation to work.  Assuming that there are no problems down the road that I'm not foreseeing, of course.

If you want to patch the current option quickly, you might add a time part to its constructor, copy it to its arguments class, and patch the analytic engine so that it takes it into account. You'll have to manage time conversions yourself to do that; for instance, you'll
replace:

    DiscountFactor riskFreeDiscount =
        process_->riskFreeRate()->discount(arguments_.exercise->lastDate());

with:

    Time t = process_->riskFreeRate()->dayCounter().yearFraction(
            process_->riskFreeRate()->referenceDate(),
            arguments_.exercise->lastDate());
    DiscountFactor riskFreeDiscount =
        process_->riskFreeRate()->discount(t + fractional_time_in_years);

where fractional_time_in_years is the fractional day, converted to a fraction of year to be consistent with t.  This would do the job quickly for you, but I don't think I'd put it in the library.

Later,
    Luigi


On Wed, Feb 29, 2012 at 11:46 PM, Shailesh Parmar <[hidden email]> wrote:

> I am trying to calculate Implied Volatility for European options using
> fractional days. Currently Expiry date only takes date. Is it possible
> to modify the code so that I can take into account time of day as well
> in evaluating. I would like some guidance as to how I should go about
> implementing this.
>
> Thanks in advance,
>
> Shailesh Parmar
>
> ----------------------------------------------------------------------
> -------- Virtualization & Cloud Management Using Capacity Planning
> Cloud computing makes use of virtualization - but cloud computing also
> focuses on allowing computing to be delivered as a service.
> http://www.accelacomm.com/jaw/sfnl/114/51521223/
> _______________________________________________
> QuantLib-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/quantlib-users




------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users