Slow impliedVolatility and NPV calculation when using Business252 dayCounter

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

Slow impliedVolatility and NPV calculation when using Business252 dayCounter

aimz
I am having a bit of an issue with the speed of calculation. As I need to recalculate hundreds of options every few hundred milliseconds it generates a problem.

Here is what I do to calculate simple vanilla EuropeanOptions: I use a simple BlackConstantVol, a BlackScholesMertonProcess to calculate NPV and impliedVolatility.

Question: this process is very fast when I use a Actual365Fixed but VERY SLOW when I replace this counter with a Business 252 day counter. Basically the calculation takes many orders of magnitudes more.

Note: in both cases I use the correct respective calendar.

What could be the reason as the only diff is the day counter?
Reply | Threaded
Open this post in threaded view
|

Re: Slow impliedVolatility and NPV calculation when using Business252 dayCounter

Luigi Ballabio
While actual/365 just counts days by taking the difference between the
start and end dates, the business/252 day counter has no choice but to
loop over each day and check whether it's a business day or a holiday.
 The speed is better in version 1.2, since the day counter caches day
counts for months and years (you might want to switch to that version
if you're still using QuantLib 1.1) but there are still quite a few
calculations done at each call.  If that is still too slow, you may
try adding caching results for pairs of dates; that would speed you up
a lot if you're always recalculating the same options.  If you do,
please send the patch here and I'll apply it to the repository.

Later,
    Luigi


On Tue, Sep 18, 2012 at 8:57 AM, aimz <[hidden email]> wrote:

>
> I am having a bit of an issue with the speed of calculation. As I need to
> recalculate hundreds of options every few hundred milliseconds it generates
> a problem.
>
> Here is what I do to calculate simple vanilla EuropeanOptions: I use a
> simple BlackConstantVol, a BlackScholesMertonProcess to calculate NPV and
> impliedVolatility.
>
> Question: this process is very fast when I use a Actual365Fixed but VERY
> SLOW when I replace this counter with a Business 252 day counter. Basically
> the calculation takes many orders of magnitudes more.
>
> Note: in both cases I use the correct respective calendar.
>
> What could be the reason as the only diff is the day counter?
> --
> View this message in context: http://old.nabble.com/Slow-impliedVolatility-and-NPV-calculation-when-using-Business252-dayCounter-tp34446063p34446063.html
> Sent from the quantlib-users 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-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/quantlib-users

------------------------------------------------------------------------------
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-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

R: Slow impliedVolatility and NPV calculation when using Business252 dayCounter

Ballabio Gerardo-4
What about:
- computing the number of non-weekend days (easy, needs only a bit of attention to get the first and last week right)
- counting non-weekend holidays (there are only a few per year) by keeping them in a sorted list and finding (by binary search) the first and last one which fall within the period?

Gerardo


-----Messaggio originale-----
Da: Luigi Ballabio [mailto:[hidden email]]
Inviato: martedì 18 settembre 2012 9.23
A: aimz
Cc: [hidden email]
Oggetto: Re: [Quantlib-users] Slow impliedVolatility and NPV calculation when using Business252 dayCounter

While actual/365 just counts days by taking the difference between the start and end dates, the business/252 day counter has no choice but to loop over each day and check whether it's a business day or a holiday.
 The speed is better in version 1.2, since the day counter caches day counts for months and years (you might want to switch to that version if you're still using QuantLib 1.1) but there are still quite a few calculations done at each call.  If that is still too slow, you may try adding caching results for pairs of dates; that would speed you up a lot if you're always recalculating the same options.  If you do, please send the patch here and I'll apply it to the repository.

Later,
    Luigi


On Tue, Sep 18, 2012 at 8:57 AM, aimz <[hidden email]> wrote:

>
> I am having a bit of an issue with the speed of calculation. As I need
> to recalculate hundreds of options every few hundred milliseconds it
> generates a problem.
>
> Here is what I do to calculate simple vanilla EuropeanOptions: I use a
> simple BlackConstantVol, a BlackScholesMertonProcess to calculate NPV
> and impliedVolatility.
>
> Question: this process is very fast when I use a Actual365Fixed but
> VERY SLOW when I replace this counter with a Business 252 day counter.
> Basically the calculation takes many orders of magnitudes more.
>
> Note: in both cases I use the correct respective calendar.
>
> What could be the reason as the only diff is the day counter?
> --
> View this message in context:
> http://old.nabble.com/Slow-impliedVolatility-and-NPV-calculation-when-
> using-Business252-dayCounter-tp34446063p34446063.html
> Sent from the quantlib-users 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-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/quantlib-users

------------------------------------------------------------------------------
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-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head></head>
<body>
<div style="font-family:Calibri;font-size:10px">
Banca Profilo S.p.A.
Corso Italia, 49 - 20122 Milano - Tel. 02 58408.1, Fax 02 5831 6057
Capitale Sociale Euro 136.794.106,00 i.v.
Iscrizione al Registro Imprese di Milano, C.F. e P.IVA 09108700155 - [hidden email]
Iscritta all’Albo delle Banche e dei Gruppi bancari
Aderente al Fondo Interbancario di Tutela dei depositi
Aderente al Conciliatore Bancario Finanziario e all’Arbitro Bancario Finanziario
Appartenente al Gruppo bancario Banca Profilo e soggetta all’attività di direzione e coordinamento di Arepo BP S.p.A.


DISCLAIMER:
The information transmitted may contain confidential and/or privileged material.
Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon,
this information by persons or entities other than the intended recipient is prohibited.
If you received this in error, please contact the sender and delete the material from any computer.
</div>
</body>
</html>


------------------------------------------------------------------------------
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-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users