Pular para conteúdo

Calendário COPOM

copom — COPOM meeting calendar.

Past meetings sourced from the BCB public API (atas endpoint). Future meetings for the current cycle are hardcoded from the official BCB public note and must be updated each January.

BCB API field mapping

nroReuniao     → MeetingNumber  (sequential BCB number)
dataReferencia → EndDate        (last day of the 2-day meeting)
StartDate      derived as EndDate − 1 calendar day (always 2-day meetings)

calendar(start=None, end=None)

Return the full COPOM meeting calendar (past + future).

Past meetings are fetched live from the BCB API. Future meetings come from the hardcoded annual constant. Duplicates between the two sources are removed by deduplication on EndDate, so there is no need to manually keep the lists in sync.

Parameters

start, end : DateLike | None Optional inclusive date range filter applied to EndDate. None means no bound.

Returns

pl.DataFrame Columns: MeetingNumber : Int32 BCB sequential number (null for future) StartDate : Date first day of the 2-day meeting EndDate : Date last day of the 2-day meeting ExpiryDate : Date next Brazilian business day after EndDate (= B3 CPM contract settlement/expiry date) Rows are sorted by EndDate ascending.

Notes

ExpiryDate is computed with bday.offset_expr("EndDate", 1), using the Brazilian holiday calendar already embedded in pyield.bday.

Examples

import pyield as yd cal = yd.bc.copom.calendar() "ExpiryDate" in cal.columns True cal["EndDate"].is_sorted() True

Source code in pyield/bc/copom.py
def calendar(
    start: DateLike | None = None,
    end: DateLike | None = None,
) -> pl.DataFrame:
    """
    Return the full COPOM meeting calendar (past + future).

    Past meetings are fetched live from the BCB API.
    Future meetings come from the hardcoded annual constant.
    Duplicates between the two sources are removed by deduplication
    on EndDate, so there is no need to manually keep the lists in sync.

    Parameters
    ----------
    start, end : DateLike | None
        Optional inclusive date range filter applied to EndDate.
        None means no bound.

    Returns
    -------
    pl.DataFrame
        Columns:
            MeetingNumber : Int32   BCB sequential number (null for future)
            StartDate     : Date    first day of the 2-day meeting
            EndDate       : Date    last day of the 2-day meeting
            ExpiryDate    : Date    next Brazilian business day after EndDate
                                    (= B3 CPM contract settlement/expiry date)
        Rows are sorted by EndDate ascending.

    Notes
    -----
    ExpiryDate is computed with ``bday.offset_expr("EndDate", 1)``, using
    the Brazilian holiday calendar already embedded in ``pyield.bday``.

    Examples
    --------
    >>> import pyield as yd
    >>> cal = yd.bc.copom.calendar()
    >>> "ExpiryDate" in cal.columns
    True
    >>> cal["EndDate"].is_sorted()
    True
    """
    past = _fetch_past_meetings()
    future = _build_future_meetings()

    df = (
        pl.concat([past, future], how="diagonal")
        .unique(subset=["EndDate"])
        .sort("EndDate")
    )

    # ExpiryDate: next business day after the meeting ends.
    # Vectorized via offset_expr — consistent with the rest of the codebase.
    df = df.with_columns(ExpiryDate=bday.offset_expr("EndDate", 1))

    # Optional date-range filter on EndDate
    if start is not None:
        start_date = converter_datas(start)
        if start_date is not None:
            df = df.filter(pl.col("EndDate") >= start_date)
    if end is not None:
        end_date = converter_datas(end)
        if end_date is not None:
            df = df.filter(pl.col("EndDate") <= end_date)

    return df

next_meeting(reference=None)

Return the single next COPOM meeting on or after reference.

If reference is None, today's date (Brazil timezone) is used. Returns a one-row DataFrame with the same schema as :func:calendar.

Examples

import pyield as yd row = yd.bc.copom.next_meeting() len(row) 1

Source code in pyield/bc/copom.py
def next_meeting(reference: DateLike | None = None) -> pl.DataFrame:
    """
    Return the single next COPOM meeting on or after ``reference``.

    If ``reference`` is None, today's date (Brazil timezone) is used.
    Returns a one-row DataFrame with the same schema as :func:`calendar`.

    Examples
    --------
    >>> import pyield as yd
    >>> row = yd.bc.copom.next_meeting()
    >>> len(row)
    1
    """
    ref = clock.today() if reference is None else converter_datas(reference)
    cal = calendar()
    return cal.filter(pl.col("EndDate") >= ref).head(1)