diff --git a/docs/src/index.md b/docs/src/index.md index 1ad3536..fe6c5b4 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -84,7 +84,7 @@ julia> using BusinessDays, Dates julia> d0 = Date(2015, 06, 29) ; d1 = Date(2100, 12, 20) ; -julia> cal = BusinessDays.Brazil() +julia> cal = BusinessDays.BRSettlement() BusinessDays.BRSettlement() julia> @time BusinessDays.initcache(cal) @@ -180,7 +180,7 @@ See *runtests.jl* for more examples. - **AustraliaASX** : Public holidays for the Australian Stock Exchange (ASX). - **Australia(state)** : Public holidays for the Australian states and territories. Available for each state: `Australia(:ACT)`, `Australia(:NSW)`, `Australia(:NT)`, `Australia(:QLD)`, `Australia(:SA)`, `Australia(:TAS)`, `Australia(:WA)`, `Australia(:VIC)`. - **BRSettlement** or **Brazil** : banking holidays for Brazil (federal holidays plus Carnival). -- **BrazilBMF** or **BrazilExchange** : holidays for BM&FBOVESPA Stock Exchange. +- **BrazilExchange** or **BrazilB3** : holidays for B3 Stock Exchange. - **CanadaSettlement** or **Canada**: holidays for Canada. - **CanadaTSX**: holidays for Toronto Stock Exchange - **CompositeHolidayCalendar** : supports combination of Holiday Calendars. diff --git a/src/calendars/brazil.jl b/src/calendars/brazil.jl index a76c177..ec7522e 100644 --- a/src/calendars/brazil.jl +++ b/src/calendars/brazil.jl @@ -13,7 +13,7 @@ const BrazilBMF = BrazilExchange const BrazilB3 = BrazilExchange # Brazilian Banking Holidays -function isholiday(::Brazil, dt::Dates.Date) +function isholiday(::BRSettlement, dt::Dates.Date) yy = Dates.year(dt) mm = Dates.month(dt) @@ -39,7 +39,7 @@ function isholiday(::Brazil, dt::Dates.Date) ((mm == 12) && (dd == 25)) ) return true - end + end else # mm < 8 # Fixed holidays @@ -91,10 +91,10 @@ function isholiday(::BrazilExchange, dt::Dates.Date) ( mm == 1 && dd == 25 ) || # Revolucão - ( mm == 7 && dd == 9 ) + ( mm == 7 && dd == 9 && yy != 2020 ) || - # Conciência Negra (a partir de 2007) - ( yy >= 2007 && mm == 11 && dd == 20 ) + # Consciência Negra (since 2007) + ( yy >= 2007 && mm == 11 && dd == 20 && yy != 2020 ) # Christmas Eve || ( mm == 12 && dd == 24) diff --git a/test/calendar_tests.jl b/test/calendar_tests.jl index 9052891..d9d2f7f 100644 --- a/test/calendar_tests.jl +++ b/test/calendar_tests.jl @@ -190,20 +190,44 @@ test_bdays(:WeekendsOnly, (2019, 8, 23), (2019, 8, 24), 1) @test isbday("Brazil", Dates.Date(2013, 05, 30)) == false # Corpus Christi @test isbday("Brazil", Dates.Date(2013, 05, 31)) == true # friday -# BrazilBMF holiday calendar tests -@test isbday(hc_brazil_bmf, Dates.Date(2017, 11, 19)) == false # sunday -@test isbday(hc_brazil_bmf, Dates.Date(2017, 11, 20)) == false # Conciência Negra (segunda) -@test isbday(hc_brazil_bmf, Dates.Date(2017, 11, 21)) == true # Terca +# BrazilExchange holiday calendar tests +@test isbday(hc_brazil_exc, Dates.Date(2017, 11, 19)) == false # sunday +@test isbday(hc_brazil_exc, Dates.Date(2017, 11, 20)) == false # Consciência Negra (segunda) +@test isbday(hc_brazil_exc, Dates.Date(2017, 11, 21)) == true # Terca -@test isbday(:BrazilBMF, Dates.Date(2013, 05, 29)) == true # wednesday -@test isbday(:BrazilBMF, Dates.Date(2013, 05, 30)) == false # Corpus Christi (National Holiday) -@test isbday(:BrazilBMF, Dates.Date(2013, 05, 31)) == true # friday +@test isbday(:BrazilExchange, Dates.Date(2013, 05, 29)) == true # wednesday +@test isbday(:BrazilExchange, Dates.Date(2013, 05, 30)) == false # Corpus Christi (National Holiday) +@test isbday(:BrazilExchange, Dates.Date(2013, 05, 31)) == true # friday # BrazilB3 as alias of BrazilExchange @test isbday(:BrazilB3, Dates.Date(2013, 05, 29)) == true # wednesday @test isbday(:BrazilB3, Dates.Date(2013, 05, 30)) == false # Corpus Christi (National Holiday) @test isbday(:BrazilB3, Dates.Date(2013, 05, 31)) == true # friday +# BrazilExchange 2019 calendar +@test isbday(hc_brazil_exc, Dates.Date(2019, 01, 01)) == false # Confraternização Universal +@test isbday(hc_brazil_exc, Dates.Date(2019, 03, 04)) == false # Carnaval +@test isbday(hc_brazil_exc, Dates.Date(2019, 03, 05)) == false # Carnaval +@test isbday(hc_brazil_exc, Dates.Date(2019, 04, 19)) == false # Paixão de Cristo +@test isbday(hc_brazil_exc, Dates.Date(2019, 05, 01)) == false # Dia do Trabalho +@test isbday(hc_brazil_exc, Dates.Date(2019, 06, 20)) == false # Corpus Christi +@test isbday(hc_brazil_exc, Dates.Date(2019, 11, 15)) == false # Proclamação da República +@test isbday(hc_brazil_exc, Dates.Date(2019, 12, 24)) == false # Véspera de Natal +@test isbday(hc_brazil_exc, Dates.Date(2019, 12, 25)) == false # Natal +@test isbday(hc_brazil_exc, Dates.Date(2019, 12, 31)) == false # bank holiday +@test isbday(hc_brazil_exc, Dates.Date(2019, 01, 25)) == false # Aniversário de São Paulo +@test isbday(hc_brazil_exc, Dates.Date(2019, 07, 09)) == false # Revolução Constitucionalista +@test isbday(hc_brazil_exc, Dates.Date(2019, 11, 20)) == false # Dia da Consciência Negra + +# BrazilExchange 2020 calendar +@test isbday(hc_brazil_exc, Dates.Date(2020, 05, 20)) == true +@test isbday(hc_brazil_exc, Dates.Date(2020, 05, 21)) == true +@test isbday(hc_brazil_exc, Dates.Date(2020, 05, 22)) == true +@test isbday(hc_brazil_exc, Dates.Date(2020, 05, 25)) == true +@test isbday(hc_brazil_exc, Dates.Date(2020, 06, 11)) == false +@test isbday(hc_brazil_exc, Dates.Date(2020, 07, 09)) == true # 2020 update by Ofício Circular 072/2020-PRE +@test isbday(hc_brazil_exc, Dates.Date(2020, 11, 20)) == true # 2020 update by Ofício Circular 072/2020-PRE + # USSettlement HolidayCaledar tests # Federal Holidays listed on https://www.opm.gov/policy-data-oversight/snow-dismissal-procedures/federal-holidays/#url=2015 @test isbday(hc_usa, Dates.Date(2014, 12, 31)) == true diff --git a/test/runtests.jl b/test/runtests.jl index d85328a..a36b37a 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -111,8 +111,8 @@ hc_australiasa = BusinessDays.Australia(:SA) hc_australiatas = BusinessDays.Australia(:TAS) hc_australiawa = BusinessDays.Australia(:WA) hc_australiavic = BusinessDays.Australia(:VIC) -hc_brazil = BusinessDays.Brazil() -hc_brazil_bmf = BusinessDays.BrazilBMF() +hc_brazil = BusinessDays.BRSettlement() +hc_brazil_exc = BusinessDays.BrazilExchange() hc_usa = BusinessDays.USSettlement() hc_uk = BusinessDays.UKSettlement() hc_usnyse = BusinessDays.USNYSE()