http://quantlib.414.s1.nabble.com/Re-QuantLib-svn-SF-net-SVN-quantlib-12585-trunk-QuantLib-tp9767.html
the calendar unit test fails after this change. Any idea?
> 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>
Defy all challenges. Microsoft(R) Visual Studio 2005.