get_ibovespa: Get Ibovespa Index (B3)

View source: R/get_ibovespa.R

get_ibovespaR Documentation

Get Ibovespa Index (B3)

Description

Downloads the daily closing level of the Ibovespa (Índice Bovespa), Brazil's main stock market benchmark, via Yahoo Finance (ticker ⁠^BVSP⁠). Uses the yfR package, the same data source already used in the {brstocks} package, so {brfinance} now covers the equity side alongside its macroeconomic series.

Usage

get_ibovespa(
  start_date = NULL,
  end_date = NULL,
  language = "eng",
  labels = TRUE
)

Arguments

start_date

Start date for the data period. Accepts multiple formats:

  • "YYYY" for year only (e.g., "2020" becomes "2020-01-01")

  • "YYYY-MM" for year and month (e.g., "2020-06" becomes "2020-06-01")

  • "YYYY-MM-DD" for a specific date (e.g., "2020-06-15")

  • NULL defaults to the last 30 days, using today as the end date

end_date

End date for the data period. Accepts the same formats as start_date:

  • "YYYY" (e.g., "2023" becomes "2023-12-31")

  • "YYYY-MM" (e.g., "2023-12" becomes the last day of December 2023)

  • "YYYY-MM-DD" for a specific date

  • NULL defaults to the current date (today)

language

Language for the labelled variable descriptions attached to the returned data.frame ("eng" or "pt"). Column names are always date and value.

labels

Logical indicating whether to add variable labels using the labelled package.

Value

A data.frame with columns:

date

Trading date

value

Ibovespa closing level (index points)

Note

Requires the yfR package (install.packages("yfR")) and an internet connection to Yahoo Finance. Unlike ⁠get_*()⁠ functions backed by BCB/SGS, this one is not subject to the 10-year window limit — yfR handles the full request in one call.

Examples


if (requireNamespace("yfR", quietly = TRUE)) {
  # Default: last 30 days
  df <- get_ibovespa()

  # Specific period
  df2 <- get_ibovespa("2020-01-01", "2023-12-31")

  # Portuguese labels
  df3 <- get_ibovespa(language = "pt")
}



brfinance documentation built on Nov. 14, 2026, 5:09 p.m.