From c86cd40561ecc5a02bf0917d1b04b65a76d46186 Mon Sep 17 00:00:00 2001 From: Felipe Noronha Date: Mon, 24 Jan 2022 23:05:58 -0300 Subject: [PATCH] update BrazilExchange calendar: B3 no longer follows local holidays in Sao Paulo --- Project.toml | 2 +- src/calendars/brazil.jl | 6 +++--- test/calendar_tests.jl | 29 +++++++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 4 deletions(-) diff --git a/Project.toml b/Project.toml index 99cdee0..37abaa0 100644 --- a/Project.toml +++ b/Project.toml @@ -3,7 +3,7 @@ uuid = "4f18b42c-503e-5345-9536-bb0f25fc7038" license = "MIT" authors = ["Felipe Noronha "] repo = "https://github.com/JuliaFinance/BusinessDays.jl.git" -version = "0.9.14" +version = "0.9.15" [deps] Dates = "ade2ca70-3891-5945-98fb-dc099432e06a" diff --git a/src/calendars/brazil.jl b/src/calendars/brazil.jl index c202c49..9ab208f 100644 --- a/src/calendars/brazil.jl +++ b/src/calendars/brazil.jl @@ -88,13 +88,13 @@ function isholiday(::BrazilExchange, dt::Dates.Date) if ( # Aniversário de São Paulo - ( mm == 1 && dd == 25 && yy != 2022 ) + ( mm == 1 && dd == 25 && yy < 2022 ) || # Revolucão - ( mm == 7 && dd == 9 && yy != 2020 ) + ( mm == 7 && dd == 9 && yy != 2020 && yy < 2022 ) || # Consciência Negra (since 2007) - ( yy >= 2007 && mm == 11 && dd == 20 && yy != 2020 ) + ( yy >= 2007 && mm == 11 && dd == 20 && yy != 2020 && yy < 2022 ) # Christmas Eve || ( mm == 12 && dd == 24) diff --git a/test/calendar_tests.jl b/test/calendar_tests.jl index 122abc3..49a2db6 100644 --- a/test/calendar_tests.jl +++ b/test/calendar_tests.jl @@ -234,6 +234,35 @@ test_bdays(:WeekendsOnly, (2019, 8, 23), (2019, 8, 24), 1) # BrazilExchange 2022 calendar @test isholiday(hc_brazil_exc, Dates.Date(2022, 1, 25)) == false # updated by Ofício Circular 150/2020-PRE +@test isholiday(hc_brazil_exc, Dates.Date(2022, 7, 9)) == false +@test isholiday(hc_brazil_exc, Dates.Date(2022, 11, 20)) == false +@test isholiday(hc_brazil_exc, Dates.Date(2022, 2, 28)) == true +@test isholiday(hc_brazil_exc, Dates.Date(2022, 3, 1)) == true +@test isholiday(hc_brazil_exc, Dates.Date(2022, 4, 15)) == true +@test isholiday(hc_brazil_exc, Dates.Date(2022, 4, 21)) == true +@test isholiday(hc_brazil_exc, Dates.Date(2022, 6, 16)) == true +@test isholiday(hc_brazil_exc, Dates.Date(2022, 9, 7)) == true +@test isholiday(hc_brazil_exc, Dates.Date(2022, 10, 12)) == true +@test isholiday(hc_brazil_exc, Dates.Date(2022, 11, 2)) == true +@test isholiday(hc_brazil_exc, Dates.Date(2022, 11, 15)) == true + +@test BusinessDays.listholidays(hc_brazil_exc, Dates.Date(2022, 1, 1), Dates.Date(2022, 12, 31)) == [ + Dates.Date("2022-01-01"), # Confraternização Universal (Sábado) + Dates.Date("2022-02-28"), # Carnaval (segunda) + Dates.Date("2022-03-01"), # Carnaval (Terça) + Dates.Date("2022-04-15"), # Paixão de Cristo + Dates.Date("2022-04-21"), # Tiradentes + Dates.Date("2022-05-01"), # Dia do Trabalho (Domingo) + Dates.Date("2022-06-16"), # Corpus Christi + Dates.Date("2022-09-07"), # Independência do Brasil + Dates.Date("2022-10-12"), # Nossa Senhora Aparecida + Dates.Date("2022-11-02"), # Finados + Dates.Date("2022-11-15"), # Proclamação da República + Dates.Date("2022-12-24"), # Véspera de Natal (sábado) + Dates.Date("2022-12-25"), # Natal (Domingo) + Dates.Date("2022-12-30"), # Véspera do ano novo + Dates.Date("2022-12-31") # Ano novo (Sábado) +] # USSettlement HolidayCaledar tests # Federal Holidays listed on https://www.opm.gov/policy-data-oversight/snow-dismissal-procedures/federal-holidays/#url=2015