TARGET() macro and default calendar (RuntimeError: option expired)

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

TARGET() macro and default calendar (RuntimeError: option expired)

Morpheous
I am using the Python binding to Quantlib to perform calculations on historic data.

After setting up the required framework (curves etc), When I call `option.ImpliedVolatility()` I get the following exception thrown (for options that have expired):


      File "/usr/local/lib/python2.6/dist-packages/QuantLib/QuantLib.py", line 3683, in impliedVolatility
        def impliedVolatility(self, *args): return _QuantLib.VanillaOption_impliedVolatility(self, *args)
    RuntimeError: option expired


A snippet of the lines of code for setting up required curves etc is shown below:

            dividend_yield = YieldTermStructureHandle(FlatForward(0, TARGET(), div_yield, Actual365Fixed()))
            risk_free_rate = YieldTermStructureHandle(FlatForward(0, TARGET(), rf_rate, Actual365Fixed()))
            volatility = BlackVolTermStructureHandle(BlackConstantVol(0, TARGET(), annualized_histvol, Actual360()))


I **STRONGLY** suspect that the `TARGET()` macro used defaults to the current system date.

How may I set up the library to use a specific historic date?
Reply | Threaded
Open this post in threaded view
|

Re: TARGET() macro and default calendar (RuntimeError: option expired)

Luigi Ballabio
Hi,
    apologies for the delay, I was on vacation.  The TARGET calendar
only specifies what days are business days and what days are holidays.
 If you want to set an evaluation date, you'll have to add, say,

Settings::instance().evaluationDate() = Date(8,February,2011);

before performing the calculations.  If the evaluation date is not
set, it defaults to the system date as you inferred.

Luigi

On Wed, Aug 1, 2012 at 3:45 AM, Morpheous <[hidden email]> wrote:

>
> I am using the Python binding to Quantlib to perform calculations on historic
> data.
>
> After setting up the required framework (curves etc), When I call
> `option.ImpliedVolatility()` I get the following exception thrown (for
> options that have expired):
>
>
>       File "/usr/local/lib/python2.6/dist-packages/QuantLib/QuantLib.py",
> line 3683, in impliedVolatility
>         def impliedVolatility(self, *args): return
> _QuantLib.VanillaOption_impliedVolatility(self, *args)
>     RuntimeError: option expired
>
>
> A snippet of the lines of code for setting up required curves etc is shown
> below:
>
>             dividend_yield = YieldTermStructureHandle(FlatForward(0,
> TARGET(), div_yield, Actual365Fixed()))
>             risk_free_rate = YieldTermStructureHandle(FlatForward(0,
> TARGET(), rf_rate, Actual365Fixed()))
>             volatility = BlackVolTermStructureHandle(BlackConstantVol(0,
> TARGET(), annualized_histvol, Actual360()))
>
>
> I **STRONGLY** suspect that the `TARGET()` macro used defaults to the
> current system date.
>
> How may I set up the library to use a specific historic date?
> --
> View this message in context: http://old.nabble.com/TARGET%28%29-macro-and-default-calendar-%28RuntimeError%3A-option-expired%29-tp34238686p34238686.html
> Sent from the quantlib-dev mailing list archive at Nabble.com.
>
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> QuantLib-dev mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/quantlib-dev

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev
Reply | Threaded
Open this post in threaded view
|

Re: TARGET() macro and default calendar (RuntimeError: option expired)

Luigi Ballabio
Oh, you're using Python.  Then the statement would be

Settings.instance().evaluationDate = Date(8,February,2011)

instead.

Luigi

On Fri, Aug 24, 2012 at 1:01 PM, Luigi Ballabio
<[hidden email]> wrote:

> Hi,
>     apologies for the delay, I was on vacation.  The TARGET calendar
> only specifies what days are business days and what days are holidays.
>  If you want to set an evaluation date, you'll have to add, say,
>
> Settings::instance().evaluationDate() = Date(8,February,2011);
>
> before performing the calculations.  If the evaluation date is not
> set, it defaults to the system date as you inferred.
>
> Luigi
>
> On Wed, Aug 1, 2012 at 3:45 AM, Morpheous <[hidden email]> wrote:
>>
>> I am using the Python binding to Quantlib to perform calculations on historic
>> data.
>>
>> After setting up the required framework (curves etc), When I call
>> `option.ImpliedVolatility()` I get the following exception thrown (for
>> options that have expired):
>>
>>
>>       File "/usr/local/lib/python2.6/dist-packages/QuantLib/QuantLib.py",
>> line 3683, in impliedVolatility
>>         def impliedVolatility(self, *args): return
>> _QuantLib.VanillaOption_impliedVolatility(self, *args)
>>     RuntimeError: option expired
>>
>>
>> A snippet of the lines of code for setting up required curves etc is shown
>> below:
>>
>>             dividend_yield = YieldTermStructureHandle(FlatForward(0,
>> TARGET(), div_yield, Actual365Fixed()))
>>             risk_free_rate = YieldTermStructureHandle(FlatForward(0,
>> TARGET(), rf_rate, Actual365Fixed()))
>>             volatility = BlackVolTermStructureHandle(BlackConstantVol(0,
>> TARGET(), annualized_histvol, Actual360()))
>>
>>
>> I **STRONGLY** suspect that the `TARGET()` macro used defaults to the
>> current system date.
>>
>> How may I set up the library to use a specific historic date?
>> --
>> View this message in context: http://old.nabble.com/TARGET%28%29-macro-and-default-calendar-%28RuntimeError%3A-option-expired%29-tp34238686p34238686.html
>> Sent from the quantlib-dev mailing list archive at Nabble.com.
>>
>>
>> ------------------------------------------------------------------------------
>> Live Security Virtual Conference
>> Exclusive live event will cover all the ways today's security and
>> threat landscape has changed and how IT managers can respond. Discussions
>> will include endpoint security, mobile security and the latest in malware
>> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
>> _______________________________________________
>> QuantLib-dev mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/quantlib-dev

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev
Reply | Threaded
Open this post in threaded view
|

Re: TARGET() macro and default calendar (RuntimeError: option expired)

Morpheous
Hi Luigi,

Hope you had a nice relaxing holiday!. Thanks for the reply. BTW, I am using QuantLib with C++ too, so the original snippet is useful too :)

Thanks

Luigi Ballabio wrote
Oh, you're using Python.  Then the statement would be

Settings.instance().evaluationDate = Date(8,February,2011)

instead.

Luigi

On Fri, Aug 24, 2012 at 1:01 PM, Luigi Ballabio
<luigi.ballabio@gmail.com> wrote:
> Hi,
>     apologies for the delay, I was on vacation.  The TARGET calendar
> only specifies what days are business days and what days are holidays.
>  If you want to set an evaluation date, you'll have to add, say,
>
> Settings::instance().evaluationDate() = Date(8,February,2011);
>
> before performing the calculations.  If the evaluation date is not
> set, it defaults to the system date as you inferred.
>
> Luigi
>
> On Wed, Aug 1, 2012 at 3:45 AM, Morpheous <takashi_949@hotmail.com> wrote:
>>
>> I am using the Python binding to Quantlib to perform calculations on historic
>> data.
>>
>> After setting up the required framework (curves etc), When I call
>> `option.ImpliedVolatility()` I get the following exception thrown (for
>> options that have expired):
>>
>>
>>       File "/usr/local/lib/python2.6/dist-packages/QuantLib/QuantLib.py",
>> line 3683, in impliedVolatility
>>         def impliedVolatility(self, *args): return
>> _QuantLib.VanillaOption_impliedVolatility(self, *args)
>>     RuntimeError: option expired
>>
>>
>> A snippet of the lines of code for setting up required curves etc is shown
>> below:
>>
>>             dividend_yield = YieldTermStructureHandle(FlatForward(0,
>> TARGET(), div_yield, Actual365Fixed()))
>>             risk_free_rate = YieldTermStructureHandle(FlatForward(0,
>> TARGET(), rf_rate, Actual365Fixed()))
>>             volatility = BlackVolTermStructureHandle(BlackConstantVol(0,
>> TARGET(), annualized_histvol, Actual360()))
>>
>>
>> I **STRONGLY** suspect that the `TARGET()` macro used defaults to the
>> current system date.
>>
>> How may I set up the library to use a specific historic date?
>> --
>> View this message in context: http://old.nabble.com/TARGET%28%29-macro-and-default-calendar-%28RuntimeError%3A-option-expired%29-tp34238686p34238686.html
>> Sent from the quantlib-dev mailing list archive at Nabble.com.
>>
>>
>> ------------------------------------------------------------------------------
>> Live Security Virtual Conference
>> Exclusive live event will cover all the ways today's security and
>> threat landscape has changed and how IT managers can respond. Discussions
>> will include endpoint security, mobile security and the latest in malware
>> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
>> _______________________________________________
>> QuantLib-dev mailing list
>> QuantLib-dev@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/quantlib-dev

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
QuantLib-dev mailing list
QuantLib-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/quantlib-dev