Skip to main content

This packages enables downloading economic and financial time series hosted on Banco de Mexico's Sistema de Informacion Economica (SIE) directly as a time-indexed Pandas DataFrame. Time series metadata is available on English and Spanish.

Project description

Banxico-SIE

This packages enables downloading economic and financial time series hosted on Banco de Mexico's Sistema de Informacion Economica (SIE) directly as a time-indexed Pandas DataFrame. Time series metadata is available on English and Spanish.

Credentials are required by the website to download data. Visit Banxico's Sistema de Informacion Economica API website to request a token.

Disclaimer: This package is not institutionally endorsed by Banco de Mexico and does not constitute an official Python package to access Banco de Mexico's data. Banco de Mexico does not provide any support to this package and is not liable by its use.

Installation

Install Banxico-SIE with pip

  pip install Banxico-SIE

Usage

## Firstly, obtain a token from Banxico's website:
# https://www.banxico.org.mx/SieAPIRest/service/v1/?locale=en
banxico_token = "..."  # 64 characters long

from siebanxico import SIEBanxico

# Choose language of metadata by choosing locale="es" (Spanish) or locale="en" (English).
api_client = SIEBanxico(token=banxico_token, locale="es")

## Get a single time series:
# Visit Banxico's website to find the id of a certain time series. E.g., "SP1" is Monthly CPI.
# https://www.banxico.org.mx/SieInternet/defaultEnglish.do
df = api_client.getSeriesData("SP1")  # Get whole CPI time series
df = api_client.getSeriesData("SP1", startDate="2020-01-01", endDate="2020-12-31")  # Get time series for a date range
# Note: startDate and endDate must be in the format YYYY-MM-DD.

# df is a time-indexed Pandas DataFrame.
# Use Pandas functionalities to manipulate data and perform transformations.
# For example:
df.head()
df.diff()
df.pct_change(12)

## Get multiple time series:

# This list must contain the ids of the time series. Visit Banxico's website to find this.
# https://www.banxico.org.mx/SieInternet/defaultEnglish.do
list_series = ["SP1", "SF311408", "SF311418", "SF311433"]  # CPI, M1, M2, M3 (all in monthly frequency)
# Note: Periodicity of the time series must be identical!

# This function requires a pandas.offsets object for the periodicity argument.
# For monthly data use: pandas.offsets.MonthBegin(1)
# This is important because the library uses this object to create the dataframe's time index.
import pandas as pd

df = api_client.getSeriesDataFrame(list_series, startDate="2000-01-01", endDate="2023-07-31",
                                   periodicity=pd.offsets.MonthBegin(1))
# Note: startDate and endDate must be in the format YYYY-MM-DD.

# df is a time-indexed Pandas DataFrame.
# Use Pandas functionalities to manipulate data and perform transformations.
# For example:
df.head()
df.diff()
df.pct_change(12)

## Get series metadata:
metadata_df = api_client.getSeriesMetaData(list_series)

## Get last values for a list of series:
lastvalues_df = api_client.getSeriesCurrentValue(list_series)

Authors

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Banxico-SIE-1.0.0.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

Banxico_SIE-1.0.0-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file Banxico-SIE-1.0.0.tar.gz.

File metadata

  • Download URL: Banxico-SIE-1.0.0.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.13

File hashes

Hashes for Banxico-SIE-1.0.0.tar.gz
Algorithm Hash digest
SHA256 6fbb0c6324f3c19db9046f0b5c6ec220f76e83a5e95bcca1ddc80887ce187c45
MD5 f5e474d11bfc2dd7d241bb39c322af6b
BLAKE2b-256 67ae9675e525ef93b0c761333005621f8c53f1db23b5e8280bf9909e729e2775

See more details on using hashes here.

File details

Details for the file Banxico_SIE-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: Banxico_SIE-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.13

File hashes

Hashes for Banxico_SIE-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4c92e865edfda0567b1a1f83e45f42d4e720cc15e44935a4066f91f6cc28f7c9
MD5 bb0a1e1200ce0e90617a5c4db31e1997
BLAKE2b-256 975d6cccf635f64184e891d426bfc5f39d81f5979466a11c54410bf87f0c3ecf

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page