Skip to content

Commit

Permalink
BrazilExchange calendar adjustments for 2020.
Browse files Browse the repository at this point in the history
Ref Oficios B3 068/2020-PRE, 072/2020-PRE.
  • Loading branch information
felipenoris committed Jun 8, 2020
1 parent cf60846 commit 78302d9
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 16 deletions.
4 changes: 2 additions & 2 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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.
Expand Down
10 changes: 5 additions & 5 deletions src/calendars/brazil.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -39,7 +39,7 @@ function isholiday(::Brazil, dt::Dates.Date)
((mm == 12) && (dd == 25))
)
return true
end
end
else
# mm < 8
# Fixed holidays
Expand Down Expand Up @@ -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)
Expand Down
38 changes: 31 additions & 7 deletions test/calendar_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 78302d9

Please sign in to comment.