Skip to content

Bureau-for-Economic-Research/quantec-python

Repository files navigation

quantec

Lifecycle: experimental

The quantec library is a basic wrapper around the EasyData data portal API from Quantec maintained by the Bureau for Economic Research.

This is the homepage for the {quantec} Python package https://github.com/Bureau-for-Economic-Research/quantec-python.

For the R package, go to https://github.com/Bureau-for-Economic-Research/quantec.

NOTE: The API is currently in BETA testing.

💡 Please be a good digital citizen when interacting with an API - restrict parallel implementation and institute sleeps between calling data.

Disclaimer

This package is no way endorsed by Quantec and was developed at the Bureau for Economic Research in order to streamline research process.

About Qauntec

From the Quantec Website

Quantec is a consultancy providing economic and financial data, country intelligence and quantitative analytical software.

Please reach out to Quantec via their Contact Page https://www.quantec.co.za/contact/ to receive an API key.

Create an environment

mkdir ~/venv && cd ~/venv
python3 -m venv quantec
source ~/venv/quantec/bin/activate

Installation from Github

Clone the repo from Github:

pip install git+https://github.com/Bureau-for-Economic-Research/quantec-python

Usage

Set API Key

To access the API you’ll need to first specify an API key in your .env as provided to you by Quantec.

  • .env
QUANTEC_API=place_your_key_here

The API interface

The package currently provides an interface to the Quantec data API. The package is designed around the QuantecClient class:

  • apikey to return csv or json

The main method get_data has the following options:

  • time_series_code time series code to return, NMS-EC_BUS,NMS-GA_BUS
  • freq frequency to return M, Q or A
  • start_year year to start (OPTIONAL)
  • end_year year to end (OPTIONAL)
import logging
from decouple import config
import pandas as pd
from quantec import QuantecClient
from pkg_resources import get_distribution


def setup_logger():
    # create logger
    logger = logging.getLogger("quantec")
    logger.setLevel(logging.DEBUG)
    # logger.setLevel(logging.INFO)

    # create console handler and set level to debug
    ch = logging.StreamHandler()
    ch.setLevel(logging.DEBUG)

    # create formatter
    formatter = logging.Formatter("%(asctime)s [%(levelname)s] %(name)s: %(message)s")

    # add formatter to ch
    ch.setFormatter(formatter)

    # add ch to logger
    logger.addHandler(ch)


def main():
    setup_logger()
    print(get_distribution("quantec").version)

    client = QuantecClient(apikey=config("QUANTEC_API"))

    out = client.get_data("NMS-EC_BUS")

    return out


if __name__ == "__main__" and __package__ is None:
    print(f"Main name is {__name__}")
    main()

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published