wilsonfreitas / rbcb

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

New interface to access series #17

Open wilsonfreitas opened 6 years ago

wilsonfreitas commented 6 years ago

Currently it has 2 functions

Since it has plans to have new interfaces implemented, a interesting approach is unify all interfaces into one single function

rbcb_get(...)

This function might be a generic and the objects represent the desired data. Example:

rbcb_get(currecy('BRL'), start_date, end_date)              # uses currency API
rbcb_get(series(IBOVESPA = 7), start_date, end_date)  # uses SGS API

If in the future we have a search, the search could return these objects

brl <- rbcb_search('BRL')
rbcb_get(brl, start_date, end_date)
wilsonfreitas commented 2 years ago

rbcb_get implemented for SGS API (see 232ee7ea2dc5a57bc3d9c966d226cda0a602ca4e).

See sgs.R.

wilsonfreitas commented 2 years ago

rbcb_get returns a tidy tibble for SGS data.

It is necessary to create a way to transform this tidy tibble into the other used formats like xts and ts.

x <- sgs(IBOVESPA = 7, USD = 1)
df <- rbcb_get(x, from, to)
rbcb_transform(x, df, to = "xts")