bizdays - Business day calculations with the Brazilian ANBIMA calendar

Hi everyone! I just published bizdays, a library for business day calculations in Elixir, shipping with the Brazilian ANBIMA calendar.

Why? In the Brazilian financial market almost everything is counted in business days: fixed income accrual, CDI-indexed investments, settlement dates, and the 252-business-day year convention. The market standard calendar is published by ANBIMA (the Brazilian financial markets association). Python and R have had bizdays by Wilson Freitas for years, and this library brings the same idea to Elixir.

What it does (v0.1.0):

  • Built-in ANBIMA calendar for 2001–2099
  • business_day?, count, add, following, preceding, modified_following, modified_preceding, range, holidays
  • count/3 uses the market convention (from, to]: start excluded, end included
  • Custom calendars with your own holidays, weekend days and date boundaries
  • Pure functions over an immutable struct, zero runtime dependencies
cal = Bizdays.anbima()

Bizdays.business_day?(cal, ~D[2026-02-16])
# => false (Carnival)

Bizdays.add(cal, ~D[2026-02-13], 1)
# => ~D[2026-02-18]

Bizdays.count(cal, ~D[2026-02-13], ~D[2026-02-24])
# => 5

How holidays are built: there is no data file. Holidays are calculated from rules (fixed dates, plus Carnival, Good Friday and Corpus Christi relative to Easter, plus November 20 from 2024, when it became a national holiday) and stored in a MapSet at compile time. When the law changes, it is one rule with a starting year.

How it is tested: the test suite compares all 1,263 dates against a snapshot of ANBIMA’s official holiday spreadsheet (2001–2099). Business day counts were also cross-checked against python-bizdays over thousands of random intervals.

Out of scope for now: the B3 (stock exchange) trading calendar, state and municipal holidays, and CDI/Selic accrual helpers on top of the calendar. Ideas and feedback on these are very welcome, especially from anyone doing financial calculations in Elixir.

Hex: bizdays | Hex
Docs: bizdays v0.1.0 — Documentation

1 Like