Get Data for Brazilian Bonds (Tesouro Direto)

Downloads and aggregates data for Brazilian government issued bonds directly from the website of Tesouro Direto <>.

Information regarding prices and yields of bonds issued by the Brazilian government can be downloaded manually as excel files from the Tesouro Direto website. However, it can be painful to aggregate all of this data into something useful as the files don't have an uniform format and are all divided by year and asset code.

Package GetTDData makes the process of importing data from Tesouro direto much easier. All that you need in order to download the data is the name of the assets (LFT, LTN, NTN-C, NTN-B, NTN-B Principal, NTN-F) and the desired dates of maturity (e.g. 2016-01-01).


# from CRAN

How to use GetTDData

See vignettes at CRAN page.


Version 1.3 (2017-09-14)

  • Added function for downloading current yield curve from Anbima
  • Fixed typos in vignettes
  • dev version now in github
  • fixed bug for names of NTN-Principal

Version 1.2.5 (2016-11-07)

  • Added the maturities of the instruments as an extra column in the dataframe

Version 1.2.4 (2016-08-15)

  • The package CHECK process no longer depends on the avaibility of Tesouro Direto website. All needed files are now local

Version 1.2.3 (2016-05-22)

  • Fixed bug in html download. Now using a new function and a new algorithm to try the download 10 times before throwing an error

Version 1.2.2 (2016-05-22)

  • The html structure of the Tesouro Website has changed and that resulted in CHECK errors in the package. This update fixed it.
  • Fixed TD names in read function (TD website is a mess!)
  • Now also using input in read function

Version 1.2.1 (2016-05-04)

- Fixed bug in (it was not reading data after 2012 because of change of output type given switch from xlsx:read.xlsx to readxl::read_excel)

Version 1.2 (2016-04-29)

- Now using readxl::read_excel, a better excel reader, FASTER and without the java requirements
- Additional error checks

Version 1.1.0 (2016-04-12)

- Added a test for internet connection
- Added a new option for overwriting or not the downloaded excel files (saves a lot of time for large batch downloads!)
- Fixed typos and improved the text in the vignette

Version 1.0.0 - Initial version (2016-02-10)

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.


1.3.1 by Marcelo Perlin, 2 months ago

Report a bug at

Browse source code at

Authors: Marcelo Perlin [aut, cre]

Documentation:   PDF Manual  

Task views: Empirical Finance

GPL-2 license

Imports stringr, stringi, readxl, utils, stats, curl, RCurl, XML, bizdays, tidyr

Suggests knitr, rmarkdown, testthat, ggplot2

See at CRAN