wilsonfreitas / rbcb

R interface to Brazilian Central Bank web services
https://wilsonfreitas.github.io/rbcb/
Other
91 stars 22 forks source link

Error in 'get_annual_market_expectations' #45

Closed felipebrdesa closed 2 years ago

felipebrdesa commented 2 years ago

Hello!

I'm trying to get market expectations with the rbcb package, but i came across with this message: "Error in .get_series(url) : BCB API Request error cannot open the connection".

Can you help me?

raphaelrrcoelho commented 2 years ago

Same problem here.

wilsonfreitas commented 2 years ago

@raphaelrrcoelho @felipebrdesa please check out the last commit. Let me know if this doesn´t get solved.

felipebrdesa commented 2 years ago

Unfortunately, the issue remains. I'm trying this code: rbcb::get_annual_market_expectations(("Taxa de câmbio"), start_date = '2021-01-01').

wilsonfreitas commented 2 years ago

Please, try

get_annual_market_expectations("Câmbio",
                               start_date = '2021-01-01')

Taxa de câmbio no longer exists, they have changed.

felipebrdesa commented 2 years ago

Still doesn't work... i believe that it's a firewall block.

wilsonfreitas commented 2 years ago

Bad!

Try it

https://olinda.bcb.gov.br/olinda/servico/Expectativas/versao/v1/aplicacao#!/recursos/ExpectativasMercadoAnuais

You can export the results to a file and process the JSON with R.

rmmaf commented 2 years ago

I have the same error, could you fix it?

wilsonfreitas commented 2 years ago

No, I can't, there is nothing to be fixed. You should check your connection.

The last commit is working fine here.

rbcb::get_annual_market_expectations("Câmbio", start_date = '2021-01-01')
#> # A tibble: 1,490 x 11
#>    indic indic_detail date       reference_date  mean median    sd   min
#>    <chr> <lgl>        <date>     <chr>          <dbl>  <dbl> <dbl> <dbl>
#>  1 Câmb~ NA           2021-09-17 2021            5.18   5.2  0.111  4.8 
#>  2 Câmb~ NA           2021-09-17 2022            5.23   5.23 0.244  4.51
#>  3 Câmb~ NA           2021-09-17 2023            5.09   5.1  0.305  4.32
#>  4 Câmb~ NA           2021-09-17 2024            5.05   5.1  0.349  4.11
#>  5 Câmb~ NA           2021-09-17 2025            5.05   5.15 0.431  3.81
#>  6 Câmb~ NA           2021-09-17 2021            5.18   5.2  0.117  4.8 
#>  7 Câmb~ NA           2021-09-17 2022            5.24   5.23 0.230  4.51
#>  8 Câmb~ NA           2021-09-17 2023            5.08   5.1  0.292  4.32
#>  9 Câmb~ NA           2021-09-17 2024            5.06   5.1  0.343  4.11
#> 10 Câmb~ NA           2021-09-17 2025            5.06   5.15 0.434  3.81
#> # ... with 1,480 more rows, and 3 more variables: max <dbl>,
#> #   respondents <int>, base <int>

Created on 2021-09-22 by the reprex package (v0.2.1)

raphaelrrcoelho commented 2 years ago

It works again with the last commit. Thanks.

rmmaf commented 2 years ago

I changed the network connection and I'm still getting the same error Error in .get_series(url) : BCB API Request error cannot open the connection to 'https://olinda.bcb.gov.br/olinda/servico/Expectativas/versao/v1/odata/ExpectativasMercadoAnuais?%24filter=%28Indicador%20eq%20%27C%C3%A2mbio%27%29%20and%20Data%20ge%20%272021-01-01%27&%24format=application%2Fjson&%24orderby=Data%20desc&%24select=Indicador%2CIndicadorDetalhe%2CData%2CDataReferencia%2CMedia%2CMediana%2CDesvioPadrao%2CCoeficienteVariacao%2CMinimo%2CMaximo%2CnumeroRespondentes%2CbaseCalculo'

And when I try to connect to this link above, the error code below appears:

/{ "codigo" : 400, "mensagem" : "The property 'CoeficienteVariacao', used in a query expression, is not defined in type 'ExpectativaMercadoAnual'." }/

OBS: I used the same command as you above

wilsonfreitas commented 2 years ago

@rmmaf have you updated with the last commit? If you updated correctly with the last commit this error should not be appearing.

See e22c5153be80fb891f65145902edac1a935b9357

And try devtools::install_github('wilsonfreitas/rbcb')