| Title: | Get Data for Brazilian Bonds (Tesouro Direto) |
|---|---|
| Description: | Downloads and aggregates data for Brazilian government issued bonds directly from the website of Tesouro Direto <https://www.tesourodireto.com.br/>. |
| Authors: | Marcelo Perlin [aut, cre] |
| Maintainer: | Marcelo Perlin <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 1.6.0 |
| Built: | 2026-06-04 16:57:29 UTC |
| Source: | https://github.com/msperlin/gettddata |
Returns the cache directory path
get_cache_folder()get_cache_folder()
A character string representing the folder path.
get_cache_folder()get_cache_folder()
Returns the available asset names at the Tesouro Direto (TD) website
get_td_names()get_td_names()
A character vector of names.
get_td_names()get_td_names()
Downloads and parses information about the current Brazilian yield curve from Anbima.
get_yield_curve() get.yield.curve()get_yield_curve() get.yield.curve()
A data frame with information about the yield curve.
## Not run: df_yield <- get_yield_curve() str(df_yield) ## End(Not run)## Not run: df_yield <- get_yield_curve() str(df_yield) ## End(Not run)
This function looks into the Tesouro Direto website (<https://www.tesourodireto.com.br/>) and downloads all files containing prices and yields of government bonds. You can use the input 'asset_codes' to restrict the downloads to specific bonds.
td_get( asset_codes = "LTN", first_year = 2005, last_year = as.numeric(format(Sys.Date(), "%Y")), dl_folder = get_cache_folder() )td_get( asset_codes = "LTN", first_year = 2005, last_year = as.numeric(format(Sys.Date(), "%Y")), dl_folder = get_cache_folder() )
asset_codes |
A character vector identifying the assets (one or more) in the names of the Excel files (e.g., 'LTN'). If 'NULL', downloads all available assets. |
first_year |
The first year of data (minimum of 2005). |
last_year |
The last year of data. |
dl_folder |
Path of the folder to save Excel files from Tesouro Direto (will create if it does not exist). Defaults to a session-temporary directory. To avoid redownloading files across different R sessions, you can pass a persistent path (e.g., a local folder path, or using tools::R_user_dir("GetTDData", which = "cache")). |
A data frame containing the asset data (prices and yields).
## Not run: df_td <- td_get("LTN", 2020, 2022) ## End(Not run)## Not run: df_td <- td_get("LTN", 2020, 2022) ## End(Not run)
Fetches current prices of Tesouro Direto (TD) assets from the website's JSON API at <https://www.tesourodireto.com.br/titulos/precos-e-taxas.htm>.
td_get_current()td_get_current()
A data frame with prices.
## Not run: df_current <- td_get_current() ## End(Not run)## Not run: df_current <- td_get_current() ## End(Not run)