diff --git a/.Rbuildignore b/.Rbuildignore index 29d98e9..6e3cfbd 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -16,4 +16,6 @@ templates_save.r ^README\.Rmd$ ^codemeta\.json$ Contributing.md -examples \ No newline at end of file +examples +^doc$ +^Meta$ diff --git a/.gitignore b/.gitignore index b02daf0..c83a8c0 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,5 @@ aux.R .lintr inst/doc docs +/doc/ +/Meta/ diff --git a/DESCRIPTION b/DESCRIPTION index e1c846f..fc7ade6 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -59,7 +59,6 @@ Collate: 'download-data.R' 'file.R' 'convert_to.R' - 'scraper-cdi.R' 'scraper-futures.R' 'scraper-yc.R' 'scraper-cotahist.R' @@ -75,6 +74,6 @@ URL: https://github.com/ropensci/rb3, http://ropensci.github.io/rb3/ VignetteBuilder: knitr Roxygen: list(markdown = TRUE) -RoxygenNote: 7.2.3 +RoxygenNote: 7.3.2 Config/testthat/edition: 3 Encoding: UTF-8 diff --git a/NAMESPACE b/NAMESPACE index e6262ce..dd8018c 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,7 +1,6 @@ # Generated by roxygen2: do not edit by hand export(cachedir) -export(cdi_get) export(clearcache) export(code2month) export(company_cash_dividends_get) @@ -28,7 +27,6 @@ export(display_template) export(download_marketdata) export(futures_get) export(futures_mget) -export(idi_get) export(index_by_segment_get) export(index_comp_get) export(index_get) diff --git a/R/downloaders.R b/R/downloaders.R index b03114f..8bb8599 100644 --- a/R/downloaders.R +++ b/R/downloaders.R @@ -26,13 +26,13 @@ settlement_prices_download <- function(., dest, ...) { verifyssl <- if (!is.null(.$verifyssl)) .$verifyssl else TRUE if (verifyssl) { res <- POST(.$downloader$url, - body = list(dData1 = strdate), - encode = "form" + body = list(dData1 = strdate), + encode = "form" ) } else { res <- POST(.$downloader$url, - body = list(dData1 = strdate), - encode = "form", config(ssl_verifypeer = FALSE) + body = list(dData1 = strdate), + encode = "form", config(ssl_verifypeer = FALSE) ) } if (status_code(res) != 200) { @@ -180,7 +180,7 @@ url_encoded_download <- function(., dest, ...) { if (verifyssl) { res <- GET(url) } else { - res <- GET(url, config(ssl_verifypeer = FALSE)) + res <- GET(url, config(ssl_verifypeer = 0L)) } if (status_code(res) != 200) { return(FALSE) diff --git a/R/rb3-package.R b/R/rb3-package.R index 2ddfd3a..8635eaa 100644 --- a/R/rb3-package.R +++ b/R/rb3-package.R @@ -1,6 +1,3 @@ -#' @keywords internal -"_PACKAGE" - #' @title Read files from Brazilian Financial Market #' #' @description @@ -42,7 +39,6 @@ #' } #' #' @name rb3-package -#' @docType package #' #' @importFrom ascii ascii #' @importFrom proto proto @@ -73,4 +69,5 @@ #' @importFrom rvest read_html html_nodes html_text #' @importFrom rvest html_table html_element read_html #' @importFrom XML xmlInternalTreeParse getNodeSet xmlValue -NULL +#' @keywords internal +"_PACKAGE" diff --git a/_pkgdown.yml b/_pkgdown.yml index 69eaa27..6d56c24 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -51,10 +51,6 @@ reference: - maturity2date - code2month - - title: CDI rate and IDI index - contents: - - cdi_get - - title: Super datasets (mix datasets) contents: - yc_superset diff --git a/inst/extdata/templates/CDIIDI.yaml b/examples/CDIIDI.yaml similarity index 100% rename from inst/extdata/templates/CDIIDI.yaml rename to examples/CDIIDI.yaml diff --git a/tests/fixtures/CDIIDI.yml b/examples/CDIIDI.yml similarity index 100% rename from tests/fixtures/CDIIDI.yml rename to examples/CDIIDI.yml diff --git a/examples/cotahist-options-examples.R b/examples/cotahist-options-examples.R index dfb94ad..5e55467 100644 --- a/examples/cotahist-options-examples.R +++ b/examples/cotahist-options-examples.R @@ -1,5 +1,6 @@ - library(tidyverse) +library(bizdays) +library(oplib) refdate <- Sys.Date() - 2 @@ -21,11 +22,11 @@ maturities <- df |> df |> filter(symbol.underlying == "PETR4", maturity_date %in% maturities[1:2]) |> ggplot(aes( - x = strike, y = close, size = volume, + x = strike, y = close, linewidth = volume, group = maturity_date, color = factor(maturity_date) )) + geom_vline( - xintercept = close_underlying[1], size = 1, color = "red", alpha = 0.25 + xintercept = close_underlying[1], linewidth = 1, color = "red", alpha = 0.25 ) + geom_point(alpha = 0.5) + facet_grid(. ~ type) @@ -80,4 +81,4 @@ m1 |> m1 |> ggplot(aes(x = delta, y = sigma, size = volume, color = type)) + - geom_point(alpha = 0.5) \ No newline at end of file + geom_point(alpha = 0.5) diff --git a/examples/debug-rb3.R b/examples/debug-rb3.R new file mode 100644 index 0000000..07dcc12 --- /dev/null +++ b/examples/debug-rb3.R @@ -0,0 +1,3 @@ +devtools::load_all() +debugonce(url_encoded_download) +single_index_get("IBOV", 2024, cachedir(), FALSE) diff --git a/R/scraper-cdi.R b/examples/scraper-cdi.R similarity index 100% rename from R/scraper-cdi.R rename to examples/scraper-cdi.R diff --git a/tests/testthat/test-cdi.R b/examples/test-cdi.R similarity index 100% rename from tests/testthat/test-cdi.R rename to examples/test-cdi.R diff --git a/tests/testthat/test-cdiidi.R b/examples/test-cdiidi.R similarity index 100% rename from tests/testthat/test-cdiidi.R rename to examples/test-cdiidi.R diff --git a/inst/extdata/templates/GetDetailsCompany.yaml b/inst/extdata/templates/GetDetailsCompany.yaml index d227c7f..9a4762b 100644 --- a/inst/extdata/templates/GetDetailsCompany.yaml +++ b/inst/extdata/templates/GetDetailsCompany.yaml @@ -3,6 +3,7 @@ filename: ~ filetype: MCUSTOM description: Informação suplementar das companhias listadas na Bolsa locale: pt +verifyssl: false downloader: function: company_details_download url: https://sistemaswebb3-listados.b3.com.br/listedCompaniesProxy/CompanyCall/GetDetail diff --git a/inst/extdata/templates/GetListedCashDividends.yaml b/inst/extdata/templates/GetListedCashDividends.yaml index 00d48ad..71f47bb 100644 --- a/inst/extdata/templates/GetListedCashDividends.yaml +++ b/inst/extdata/templates/GetListedCashDividends.yaml @@ -3,6 +3,7 @@ filename: ~ filetype: CUSTOM description: Listagem de dividendos em dinheiro locale: pt +verifyssl: false downloader: function: company_cash_dividends_download url: https://sistemaswebb3-listados.b3.com.br/listedCompaniesProxy/CompanyCall/GetListedCashDividends diff --git a/inst/extdata/templates/GetListedSupplementCompany.yaml b/inst/extdata/templates/GetListedSupplementCompany.yaml index a7c40a5..51489c4 100644 --- a/inst/extdata/templates/GetListedSupplementCompany.yaml +++ b/inst/extdata/templates/GetListedSupplementCompany.yaml @@ -3,6 +3,7 @@ filename: ~ filetype: MCUSTOM description: Informação suplementar das companhias listadas na Bolsa locale: pt +verifyssl: false downloader: function: company_listed_supplement_download url: https://sistemaswebb3-listados.b3.com.br/listedCompaniesProxy/CompanyCall/GetListedSupplementCompany diff --git a/inst/extdata/templates/GetPortfolioDay.yaml b/inst/extdata/templates/GetPortfolioDay.yaml index dd51738..c734a01 100644 --- a/inst/extdata/templates/GetPortfolioDay.yaml +++ b/inst/extdata/templates/GetPortfolioDay.yaml @@ -3,6 +3,7 @@ filename: ~ filetype: MCUSTOM description: Carteira Teórica dos índices da B3 com pesos e quantidades por segmentos locale: pt +verifyssl: false downloader: function: stock_indexes_current_portfolio_download url: https://sistemaswebb3-listados.b3.com.br/indexProxy/indexCall/GetPortfolioDay diff --git a/inst/extdata/templates/GetPortfolioDay_IndexStatistics.yaml b/inst/extdata/templates/GetPortfolioDay_IndexStatistics.yaml index 8626873..79bcb55 100644 --- a/inst/extdata/templates/GetPortfolioDay_IndexStatistics.yaml +++ b/inst/extdata/templates/GetPortfolioDay_IndexStatistics.yaml @@ -3,6 +3,7 @@ filename: ~ filetype: MCUSTOM description: Dados históricos de cotação dos índices da Bolsa locale: pt +verifyssl: false downloader: function: stock_indexes_statistics_download url: https://sistemaswebb3-listados.b3.com.br/indexStatisticsProxy/IndexCall/GetPortfolioDay diff --git a/inst/extdata/templates/GetStockIndex.yaml b/inst/extdata/templates/GetStockIndex.yaml index 1c7a751..5b685cf 100644 --- a/inst/extdata/templates/GetStockIndex.yaml +++ b/inst/extdata/templates/GetStockIndex.yaml @@ -3,6 +3,7 @@ filename: ~ filetype: MCUSTOM description: Composição dos índices da B3 locale: pt +verifyssl: false downloader: function: stock_indexes_composition_download url: https://sistemaswebb3-listados.b3.com.br/indexProxy/indexCall/GetStockIndex diff --git a/inst/extdata/templates/GetTheoricalPortfolio.yaml b/inst/extdata/templates/GetTheoricalPortfolio.yaml index 9c1cd27..a5c47d4 100644 --- a/inst/extdata/templates/GetTheoricalPortfolio.yaml +++ b/inst/extdata/templates/GetTheoricalPortfolio.yaml @@ -3,6 +3,7 @@ filename: ~ filetype: MCUSTOM description: Carteira Teórica dos índices da B3 com pesos e posições locale: pt +verifyssl: false downloader: function: stock_indexes_theo_portfolio_download url: https://sistemaswebb3-listados.b3.com.br/indexProxy/indexCall/GetTheoricalPortfolio diff --git a/man/cdi-idi.Rd b/man/cdi-idi.Rd deleted file mode 100644 index c10c63f..0000000 --- a/man/cdi-idi.Rd +++ /dev/null @@ -1,25 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/scraper-cdi.R -\name{cdi-idi} -\alias{cdi-idi} -\alias{cdi_get} -\alias{idi_get} -\title{Get CDI rate and IDI index value from B3 front page} -\usage{ -cdi_get() - -idi_get() -} -\value{ -\code{data.frame} with CDI rate or IDI index values. -} -\description{ -Scrape page \url{https://www.b3.com.br/} to get last available CDI rate and -IDI index values. -} -\examples{ -\dontrun{ -df <- cdi_get() -df <- idi_get() -} -} diff --git a/man/rb3-package.Rd b/man/rb3-package.Rd index 32b0aec..aa0e925 100644 --- a/man/rb3-package.Rd +++ b/man/rb3-package.Rd @@ -4,12 +4,8 @@ \name{rb3-package} \alias{rb3} \alias{rb3-package} -\title{rb3: Download and Parse Public Data Released by B3 Exchange} +\title{Read files from Brazilian Financial Market} \description{ -\if{html}{\figure{logo.png}{options: style='float: right' alt='logo' width='120'}} - -Download and parse public files released by B3 and convert them into useful formats and data structures common to data analysis practitioners. - Read the many files used in Brazilian Financial Market and convert them into useful formats and data structures. } diff --git a/tests/testthat/test-downloaders.R b/tests/testthat/test-downloaders.R index 0e8e3c3..e43f34a 100644 --- a/tests/testthat/test-downloaders.R +++ b/tests/testthat/test-downloaders.R @@ -5,16 +5,6 @@ if (Sys.info()["sysname"] == "Linux") { httr::set_config(httr::config(ssl_verifypeer = FALSE)) } -test_that("it should download a file with a simple downloader", { - tpl <- .retrieve_template(NULL, "CDIIDI") - dest <- tempfile() - vcr::use_cassette("CDIIDI", { - x <- tpl$download_marketdata(dest) - }) - expect_true(x) - expect_true(file.exists(dest)) -}) - test_that("it should download a file with a datetime downloader", { tpl <- .retrieve_template(NULL, "COTAHIST_DAILY") dest <- tempfile()