Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

COTAHIST_YEARLY wrongly uses cache #44

Closed
wilsonfreitas opened this issue Jul 2, 2022 · 1 comment
Closed

COTAHIST_YEARLY wrongly uses cache #44

wilsonfreitas opened this issue Jul 2, 2022 · 1 comment
Labels

Comments

@wilsonfreitas
Copy link
Collaborator

For years lower than 2000, a wrong use of cache is happening.

When the download and read is executed for the specific year of 1999, it works fine.

library(rb3)
f <- download_marketdata("COTAHIST_YEARLY", refdate = as.Date("1999-01-01"))
ch <- read_marketdata(f, "COTAHIST_YEARLY")
ch$Header
#> # A tibble: 1 x 5
#>   tipo_registro nome_arquivo  cod_origem data_geracao_arquivo reserva
#>           <int> <chr>         <chr>      <date>               <chr>  
#> 1             0 COTAHIST.1999 BOVESPA    2000-01-03           ""

When the download and read is executed for the specific year of for 2000 and 1999, the read of 1999 file is wrong and returns the cached version that refers to 2000 file.

library(rb3)
f <- download_marketdata("COTAHIST_YEARLY", refdate = as.Date("2000-01-01"))
ch <- read_marketdata(f, "COTAHIST_YEARLY")
#> Warning in rule$handler(.data, str_match(.data, rule$regex)): NAs introduced by
#> coercion
ch$Header
#> # A tibble: 1 x 5
#>   tipo_registro nome_arquivo  cod_origem data_geracao_arquivo reserva
#>           <int> <chr>         <chr>      <date>               <chr>  
#> 1             0 COTAHIST.2000 BOVESPA    2001-05-02           ""
f <- download_marketdata("COTAHIST_YEARLY", refdate = as.Date("1999-01-01"))
ch <- read_marketdata(f, "COTAHIST_YEARLY")
ch$Header
#> # A tibble: 1 x 5
#>   tipo_registro nome_arquivo  cod_origem data_geracao_arquivo reserva
#>           <int> <chr>         <chr>      <date>               <chr>  
#> 1             0 COTAHIST.2000 BOVESPA    2001-05-02           ""

Created on 2022-07-02 by the reprex package (v2.0.1)

@wilsonfreitas
Copy link
Collaborator Author

This happens because the file name changes for files of the years of 2000, 1999, 1998 and so on.

For 2000 it returns the file name COTAHIST.A2000, for 2001 it is COTAHIST_A2001.

Since the regex to get the basename is \.\w+$, the basename is COTAHIST for all years lower than 2000.

wilsonfreitas added a commit that referenced this issue Jul 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant