Re: [QuantLib-svn] SF.net SVN: quantlib: [12585] trunk/QuantLib

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

Re: [QuantLib-svn] SF.net SVN: quantlib: [12585] trunk/QuantLib

Ferdinando M. Ametrano-3
Hi Luigi

the calendar unit test fails after this change. Any idea?

ciao -- Nando

On 9/12/07, [hidden email]
<[hidden email]> wrote:

> Revision: 12585
>           http://quantlib.svn.sourceforge.net/quantlib/?rev=12585&view=rev
> Author:   lballabio
> Date:     2007-09-12 06:01:11 -0700 (Wed, 12 Sep 2007)
>
> Log Message:
> -----------
> Added Brazilian exchange calendar (thanks to Richard Gomes)
>
> Modified Paths:
> --------------
>     trunk/QuantLib/ql/time/calendars/brazil.cpp
>     trunk/QuantLib/ql/time/calendars/brazil.hpp
>     trunk/QuantLib-SWIG/SWIG/calendars.i
>
> Modified: trunk/QuantLib/ql/time/calendars/brazil.cpp
> ===================================================================
> --- trunk/QuantLib/ql/time/calendars/brazil.cpp 2007-09-12 12:40:43 UTC (rev 12584)
> +++ trunk/QuantLib/ql/time/calendars/brazil.cpp 2007-09-12 13:01:11 UTC (rev 12585)
> @@ -2,6 +2,7 @@
>
>  /*
>   Copyright (C) 2005, 2006 Piter Dias
> + Copyright (C) 2007 Richard Gomes
>
>   This file is part of QuantLib, a free-software/open-source library
>   for financial quantitative analysts and developers - http://quantlib.org/
> @@ -26,11 +27,16 @@
>          // all calendar instances on the same market share the same
>          // implementation instance
>          static boost::shared_ptr<Calendar::Impl> settlementImpl(
> -            new Brazil::SettlementImpl);
> +                                                  new Brazil::SettlementImpl);
> +        static boost::shared_ptr<Calendar::Impl> exchangeImpl(
> +                                                    new Brazil::ExchangeImpl);
>          switch (market) {
>            case Settlement:
>              impl_ = settlementImpl;
>              break;
> +          case Exchange:
> +            impl_ = exchangeImpl;
> +            break;
>            default:
>              QL_FAIL("unknown market");
>          }
> @@ -55,10 +61,12 @@
>              || (d == 7 && m == September)
>              // Nossa Sra. Aparecida Day
>              || (d == 12 && m == October)
> -            // Dead Day
> +            // All Souls Day
>              || (d == 2 && m == November)
>              // Republic Day
>              || (d == 15 && m == November)
> +            // Black Consciousness Day
> +            || (d == 20 && m == November && y >= 2004)
>              // Christmas
>              || (d == 25 && m == December)
>              // Passion of Christ
> @@ -72,5 +80,47 @@
>          return true;
>      }
>
> +    bool Brazil::ExchangeImpl::isBusinessDay(const Date& date) const {
> +        Weekday w = date.weekday();
> +        Day d = date.dayOfMonth();
> +        Month m = date.month();
> +        Year y = date.year();
> +        Day dd = date.dayOfYear();
> +        Day em = easterMonday(y);
> +
> +        if (isWeekend(w)
> +            // New Year's Day
> +            || (d == 1 && m == January)
> +            // Sao Paulo City Day
> +            || (d == 25 && m == January)
> +            // Tiradentes Day
> +            || (d == 21 && m == April)
> +            // Labor Day
> +            || (d == 1 && m == May)
> +            // Revolution Day
> +            || (d == 9 && m == July)
> +            // Independence Day
> +            || (d == 7 && m == September)
> +            // Nossa Sra. Aparecida Day
> +            || (d == 12 && m == October)
> +            // All Souls Day
> +            || (d == 2 && m == November)
> +            // Republic Day
> +            || (d == 15 && m == November)
> +            // Black Consciousness Day
> +            || (d == 20 && m == November && y >= 2004)
> +            // Christmas
> +            || (d == 25 && m == December)
> +            // Passion of Christ
> +            || (dd == em-3)
> +            // Carnival
> +            || (dd == em-49 || dd == em-48)
> +            // Corpus Christi
> +            || (dd == em+59)
> +            )
> +            return false;
> +        return true;
> +    }
> +
>  }
>
>
> Modified: trunk/QuantLib/ql/time/calendars/brazil.hpp
> ===================================================================
> --- trunk/QuantLib/ql/time/calendars/brazil.hpp 2007-09-12 12:40:43 UTC (rev 12584)
> +++ trunk/QuantLib/ql/time/calendars/brazil.hpp 2007-09-12 13:01:11 UTC (rev 12585)
> @@ -2,6 +2,7 @@
>
>  /*
>   Copyright (C) 2005, 2006 Piter Dias
> + Copyright (C) 2007 Richard Gomes
>
>   This file is part of QuantLib, a free-software/open-source library
>   for financial quantitative analysts and developers - http://quantlib.org/
> @@ -38,14 +39,35 @@
>          <li>Labour Day, May 1st</li>
>          <li>Independence Day, September 21th</li>
>          <li>Nossa Sra. Aparecida Day, October 12th</li>
> -        <li>Dead Day, October 2nd</li>
> +        <li>All Souls Day, November 2nd</li>
>          <li>Republic Day, November 15th</li>
> +        <li>Black Consciousness Day, November 20th (since 2004)</li>
>          <li>Christmas, December 25th</li>
>          <li>Passion of Christ</li>
>          <li>Carnival</li>
>          <li>Corpus Christi</li>
>          </ul>
>
> +        Holidays for the stock exchange
> +        <ul>
> +        <li>Saturdays</li>
> +        <li>Sundays</li>
> +        <li>New Year's Day, January 1st</li>
> +        <li>Sao Paulo City Day, January 25th</li>
> +        <li>Tiradentes's Day, April 21th</li>
> +        <li>Labour Day, May 1st</li>
> +        <li>Revolution Day, July 9th</li>
> +        <li>Independence Day, September 21th</li>
> +        <li>Nossa Sra. Aparecida Day, October 12th</li>
> +        <li>All Souls Day, November 2nd</li>
> +        <li>Republic Day, November 15th</li>
> +        <li>Black Consciousness Day, November 20th (since 2004)</li>
> +        <li>Christmas, December 25th</li>
> +        <li>Passion of Christ</li>
> +        <li>Carnival</li>
> +        <li>Corpus Christi</li>
> +        </ul>
> +
>          \ingroup calendars
>
>          \test the correctness of the returned results is tested
> @@ -58,9 +80,15 @@
>              std::string name() const { return "Brazil"; }
>              bool isBusinessDay(const Date&) const;
>          };
> +        class ExchangeImpl : public Calendar::WesternImpl {
> +          public:
> +            std::string name() const { return "BOVESPA"; }
> +            bool isBusinessDay(const Date&) const;
> +        };
>        public:
>          //! Brazilian calendars
> -        enum Market { Settlement             //!< generic settlement calendar
> +        enum Market { Settlement,            //!< generic settlement calendar
> +                      Exchange               //!< BOVESPA calendar
>          };
>          Brazil(Market market = Settlement);
>      };
> @@ -69,3 +97,4 @@
>
>
>  #endif
> +
>
> Modified: trunk/QuantLib-SWIG/SWIG/calendars.i
> ===================================================================
> --- trunk/QuantLib-SWIG/SWIG/calendars.i        2007-09-12 12:40:43 UTC (rev 12584)
> +++ trunk/QuantLib-SWIG/SWIG/calendars.i        2007-09-12 13:01:11 UTC (rev 12585)
> @@ -134,7 +134,7 @@
>
>      class Brazil : public Calendar {
>        public:
> -        enum Market { Settlement };
> +        enum Market { Settlement, Exchange };
>          Brazil(Market m = Settlement);
>      };
>
>
>
> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2005.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> QuantLib-cvs mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/quantlib-cvs
>

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev
Reply | Threaded
Open this post in threaded view
|

Re: [QuantLib-svn] SF.net SVN: quantlib: [12585] trunk/QuantLib

Luigi Ballabio
On Fri, 2007-09-14 at 10:16 +0200, Ferdinando Ametrano wrote:
> Hi Luigi
>
> the calendar unit test fails after this change. Any idea?

It does? Shame on me.

There's one new holiday. I've added it to the test now.

Luigi


--

Discontent is the first necessity of progress.
-- Thomas A. Edison



-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev
Reply | Threaded
Open this post in threaded view
|

Re: [QuantLib-svn] SF.net SVN: quantlib: [12585] trunk/QuantLib

Richard Gomes
Luigi Ballabio wrote:

> On Fri, 2007-09-14 at 10:16 +0200, Ferdinando Ametrano wrote:
>> Hi Luigi
>>
>> the calendar unit test fails after this change. Any idea?
>
> It does? Shame on me.
>
> There's one new holiday. I've added it to the test now.
>
> Luigi
>
>

Hi Luigi,

I've compiled before sending you the file and it seemed OK. In spite I'm
using 0.8.1 and not the trunk, I do not expect any problems.

Next time I will send you a patch instead.

Let me know if you need any help.

Kind Regards


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev
Reply | Threaded
Open this post in threaded view
|

Re: [QuantLib-svn] SF.net SVN: quantlib: [12585] trunk/QuantLib

Luigi Ballabio
On Fri, 2007-09-14 at 13:18 +0100, Richard Gomes wrote:
> Luigi Ballabio wrote:
> > On Fri, 2007-09-14 at 10:16 +0200, Ferdinando Ametrano wrote:
> >> Hi Luigi
> >>
> >> the calendar unit test fails after this change. Any idea?
> >
> > It does? Shame on me.

> I've compiled before sending you the file and it seemed OK. In spite I'm
> using 0.8.1 and not the trunk, I do not expect any problems.

It did compile, but a test was failing (it checked the list of holidays,
and there was a new one.) No problem, it's fixed now.

Luigi



--

I'd never join any club that would have the likes of me as a member.
-- Groucho Marx



-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev