Package 'siebanxicor'

Title: Query Data Series from Bank of Mexico
Description: Allows to retrieve time series of all indicators available in the Bank of Mexico's Economic Information System (<http://www.banxico.org.mx/SieInternet/>).
Authors: DGIE - Banco de México
Maintainer: Noé Palmerin <[email protected]>
License: MIT + file LICENSE
Version: 1.0.0
Built: 2024-12-03 06:32:12 UTC
Source: CRAN

Help Index


Get a data.frame from an series Vector

Description

This is an utility function, it allows to obtain a data.frame from the vector returned by getSeriesData.

Usage

getSerieDataFrame(series, idSerie)

Arguments

series

A vector containing data series. This is the vector returned by getSeriesData.

idSerie

A string intentifying the series required, it can only be one.

Value

A data.frame containing the required data series.

Examples

## Not run: 
## You need a valid token to run the example
setToken("token")

series <- getSeriesMetadata(c("SF43718","SF46410","SF46407"))

serie <- getSerieDataFrame(series, "SF43718")

## End(Not run)

Time series current value

Description

Recovers last value of the indicated time series (up to 100) from SIE.

Usage

getSeriesCurrentValue(series)

Arguments

series

A vector containing idSeries

Details

This function queries the last value of each series requested. This value corresponds to the last one published by Banco de México.

The data series are queried throught the SIE API. This API requieres that every request is identified by a token. The token can be requested here. Once the query token has been obtained and prior to use any function from this Package, the token must be set in the current query session, using the function setToken.

Value

A data.frame containing the data series requested.

Examples

## Not run: 
## You need a valid token to run the example
setToken(token)
idSeries <- c("SF43718","SF46410","SF46407")
seriesDataFrame <- getSeriesCurrentValue(idSeries)

serieDataFrame <- getSeriesCurrentValue("SF43718")

## End(Not run)

Query time series

Description

Recovers data of the indicated time series (up to 100) from SIE.

Usage

getSeriesData(series, startDate = NULL, endDate = NULL)

Arguments

series

A vector containing idSeries

startDate

A string with "yyyy-MM-dd" format. Defines the date on which the period of obtained data starts.

endDate

A string with "yyyy-MM-dd" format. Defines the date on which the period of obtained data concludes.

Details

The data series are queried throught the SIE API. This API requieres that every request is identified by a token. The token can be requested here. Once the query token has been obtained and prior to use any function from this Package, the token must be set in the current query session, using the function setToken.

To get a data.frame representing one data series use getSerieDataFrame.

Value

A vector containing the data series requested.

Examples

## Not run: 
## You need a valid token to run the example
setToken("token")
idSeries <- c("SF43718","SF46410","SF46407")
series <- getSeriesData(idSeries, '2016-01-01','2018-07-12')

serie <- getSeriesData("SF43718")

## End(Not run)

Query time series metadata

Description

Recovers metadata of the indicated time series (up to 100) from SIE.

Usage

getSeriesMetadata(series, locale = "en")

Arguments

series

A vector containing idSeries.

locale

A string defining the language of the metadata. It can be obtained either in English ("en") or Spanish ("es").

Details

The series metadata are queried throught the SIE API. This API requieres that every request is identified by a token. The token can be requested here. Once the query token has been obtained and prior to use any function from this Package, the token must be set in the current query session, using the function setToken.

The information can be obtained either in English ("en") or Spanish ("es"), defining the parameter locale. By default the metadata are retrieved in English.

Value

A data.frame containing the required metadata.

Examples

## Not run: 
## You need a valid token to run the example
setToken(token)
series <- getSeriesMetadata(c("SF43718","SF46410","SF46407"))

serie <- getSeriesMetadata("SF43718")

## End(Not run)

Set the query token

Description

Set the token required to query series from SIE.

Usage

setToken(token)

Arguments

token

A string that corresponds to the query token obtained.

Details

This configuration is required prior to any function call pertaining to this package. The API used by siebanxicor requires that every request made, be identified by a token. Otherwise the query will be rejected. In order to work properly with this package is necessary to get a token here.

Before any request can be made with other functions, the obtained token must be set.

Examples

# an own token must be obtained
token <- "d4b584b43a1413f56e5abdcc0f9e74db112ce9bb2f1580c80cb252f5a18b30a21"
setToken(token)

Economic information of Banco de México

Description

This package is aimed at querying data series from Banco de México.

Details

siebanxicor allows to retrieve the time series of all indicators available in SIE. This tool aims at developers and analysts who seek to make automatic the retrieval of the economic information published by Banco de México.

This package uses the SIE API to obtain the data series published. This API requires that every request be identified by a token. This query token can be obtained here. The query token can be used in multiple requests, as long as the query limits are respected (more information).

To start using the functions included in this package, is mandatory first to set the token using setToken:

token <- "d4b584b43a1413f56e5abdcc0f9e74db112ce9bb2f1580c80cb252f5a18b30a21"
setToken(token)

The string token is only an example, an own token must be generated in the aforementioned link.

Once the token has been set, the data series can be retrieved using getSeriesData:

idSeries <- c("SF43718","SF46410","SF46407")
series <- getSeriesData(idSeries)

The time period retrieved can be limited using the parameters startDate and endDate. These parameters are strings that represent a date in the format "yyyy-MM-dd". If one of these dates is omitted the entire data are returned.

idSeries <- c("SF43718","SF46410","SF46407")
series <- getSeriesData(idSeries, startDate='2016-01-01',endDate='2018-07-12')

It is also possible to query only the current value of certain time series. The function getSeriesCurrentValue accomplishes this task:

idSeries <- c("SF43718","SF46410","SF46407")
seriesDataFrame <- getSeriesCurrentValue(idSeries)

serieDataFrame <- getSeriesCurrentValue("SF43718")

The value returned is the last one published in SIE.

The series metadata can be queried with the function getSeriesMetadata:

series <- getSeriesMetadata(c("SF43718","SF46410","SF46407"))

The idSeries requiered to use this package can be found in SIE and in the "Series catalogue"