{"id":13741219,"url":"https://github.com/msperlin/GetTDData","last_synced_at":"2025-05-08T21:32:51.000Z","repository":{"id":25247051,"uuid":"103310882","full_name":"msperlin/GetTDData","owner":"msperlin","description":null,"archived":false,"fork":false,"pushed_at":"2024-04-11T17:37:32.000Z","size":4424,"stargazers_count":20,"open_issues_count":2,"forks_count":6,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-05-01T14:25:16.617Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://msperlin.github.io/GetTDData/","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/msperlin.png","metadata":{"files":{"readme":"README.Rmd","changelog":"NEWS.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":"codemeta.json"}},"created_at":"2017-09-12T19:14:52.000Z","updated_at":"2024-07-29T10:33:40.811Z","dependencies_parsed_at":"2024-04-11T18:34:25.384Z","dependency_job_id":"0e506512-b183-43ce-b681-1fc4a36750e8","html_url":"https://github.com/msperlin/GetTDData","commit_stats":{"total_commits":53,"total_committers":3,"mean_commits":"17.666666666666668","dds":"0.16981132075471694","last_synced_commit":"9172e34d2f2548f56985b8342894e559d50f9894"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msperlin%2FGetTDData","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msperlin%2FGetTDData/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msperlin%2FGetTDData/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msperlin%2FGetTDData/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/msperlin","download_url":"https://codeload.github.com/msperlin/GetTDData/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224774694,"owners_count":17367778,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T04:00:56.936Z","updated_at":"2024-11-15T11:31:00.811Z","avatar_url":"https://github.com/msperlin.png","language":"R","funding_links":[],"categories":["R"],"sub_categories":["Data Sources"],"readme":"---\noutput: github_document\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r, include = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\",\n  out.width = \"100%\"\n)\n```\n\n\u003c!-- badges: start --\u003e\n  [![Codecov test coverage](https://codecov.io/gh/msperlin/GetTDData/branch/master/graph/badge.svg)](https://app.codecov.io/gh/msperlin/GetTDData?branch=master)\n[![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)\n[![R build (rcmdcheck)](https://github.com/msperlin/GetTDData/workflows/R-CMD-check/badge.svg)](https://github.com/msperlin/GetTDData/actions)\n\n  \u003c!-- badges: end --\u003e\n\n# Package `GetTDData`\n\nInformation regarding prices and  yields of bonds issued by the Brazilian government can be downloaded manually as excel files from the [Tesouro Direto website](https://www.tesourodireto.com.br/). However, it is painful to aggregate all of this data into something useful as the several files don't have an uniform format.\n\nPackage `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). \n\n\n## Installation\n\n```\n# from CRAN (stable version)\ninstall.package('GetTDData')\n\n# from github (development version)\ndevtools::install_github('msperlin/GetTDData')\n```\n\n## How to use GetTDData\n\nSuppose you need financial data (prices and yields) for a bond of type LTN with a maturity (end of contract) at 2023-01-01. This bullet bond is the most basic debt contract the Brazilian government issues. It does not pay any value (coupon) during its lifetime and will pay 1000 R$ at maturity.\n\nIn order to get the data, all you need to do is to run the following code in R:\n\n```{r example1}\nlibrary(GetTDData)\n\nassets \u003c- 'LTN'   # Identifier of assets \nfirst_year \u003c- 2020\nlast_year \u003c- 2022\n\ndf_td \u003c- td_get(assets,\n                first_year,\n                last_year)\n```\n\nLet's plot the prices to check if the code worked: \n\n```{r plot.prices, fig.width=7, fig.height=2.5}\nlibrary(ggplot2)\nlibrary(dplyr)\n\n# filter  LTN \nmy_asset_code \u003c- \"LTN 010123\"\n\nLTN \u003c- df_td %\u003e%\n  filter(asset_code  ==  my_asset_code)\n\np \u003c- ggplot(data = LTN, \n            aes(x = as.Date(ref_date), \n                y = price_bid, \n                color = asset_code)) + \n  geom_line(size = 1) + scale_x_date() + labs(title = '', x = 'Dates')\n\nprint(p)\n```\n\n\n## Downloading the Brazilian Yield Curve\n\nThe latest version of `GetTDData` offers function `get.yield.curve` to download the current Brazilian yield curve directly from Anbima. The yield curve is a tool of financial analysts that show, based on current prices of fixed income instruments, how the market perceives the future real, nominal and inflation returns. You can find more details regarding the use and definition of a yield curve in [Investopedia][https://www.investopedia.com/terms/y/yieldcurve.asp].\n\n```{r, eval=FALSE}\nlibrary(GetTDData)\n\ndf.yield \u003c- get.yield.curve()  \nstr(df.yield)\n```\n\nAnd we can plot it for the derised result:\n\n```{r, eval=FALSE}\nlibrary(ggplot2)\n\np \u003c- ggplot(df.yield, aes(x=ref.date, y = value) ) +\n  geom_line(size=1) + geom_point() + facet_grid(~type, scales = 'free') + \n  labs(title = paste0('The current Brazilian Yield Curve '),\n       subtitle = paste0('Date: ', df.yield$current.date[1]))     \n\nprint(p)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmsperlin%2FGetTDData","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmsperlin%2FGetTDData","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmsperlin%2FGetTDData/lists"}