OpenBB icon indicating copy to clipboard operation
OpenBB copied to clipboard

[FR] Integate OECD Database within the `economy` menu

Open JerBouma opened this issue 2 years ago • 1 comments

Basing this of a variety of market reports, I wanted to understand the ease how we can reproduce the results in the OpenBB Terminal. This lead to the suggestion to integrate the OECD Database.

Context

Getting governmental bond data (most easily, the 10 years curve) the fred functionality can be used. However, it is very tricky to get the data and it doesn't look too nice in the graph. For example, what I need to do to get data on United Kingdom, Germany, Greece and Italy is to query fred with freq -q and find the relevant timeseries. This was okay to do, e.g. I now know that the following will provide that data IRLTLT01GBM156N, IRLTLT01DEM156N, IRLTLT01GRM156N and IRLTLT01ITM156N.

Figure_1

However, what the data actually represents is a mystery. I need to do manual research first to come to this page https://data.oecd.org/interest/long-term-interest-rates.htm. Here is where I discovered that OECD has most of the important data that we can use.

Getting the data

You can query OECD relatively easy. All information comes from https://stats.oecd.org/ and as you can see it is incredibly extensive. See for example a Medium article about it here: https://medium.com/@koki_noda/how-to-use-oecd-data-in-python-69a0234c6b27

For example, here is a massive dump of long-term interest rates: https://stats.oecd.org/restsdmx/sdmx.ashx/GetData/KEI/IR+IRLTLT01.AUS+AUT+BEL+CAN+CHL+COL+CRI+CZE+DNK+EST+FIN+FRA+DEU+GRC+HUN+ISL+IRL+ISR+ITA+JPN+KOR+LTU+LVA+LUX+MEX+NLD+NZL+NOR+POL+PRT+SVK+SVN+ESP+SWE+CHE+TUR+GBR+USA+NMEC+ARG+BRA+CHN+IND+IDN+RUS+SAU+ZAF.ST.A+Q+M/all?startTime=2019&endTime=2022

Which corresponds to the (made compact on purpose) table:

image

This link I got from https://stats.oecd.org/Index.aspx?QueryId=21762 --> Export --> SDMX. You should be able to query this data through https://data.oecd.org/api/sdmx-ml-documentation/ to get all long term rates in an instant. A process that is much more clean and complete than you would ever be able to achieve via FRED.

Another example of how to query the data is done here: https://github.com/bdecon/econ_data/blob/master/APIs/OECD.ipynb

Impressive bonus: you can also get a complete overview and future expectations from the OECD for any country with the following query: https://stats.oecd.org/Index.aspx?QueryId=51397

Use case

When it comes to market reports written by Finance Societies, Investment Clubs and Investment Banks, they will often require a hefty amount of macro-economic data. Take the following examples:

Having the OECD source integrated, makes it much easier to collect the relevant data as found in these reports. Therefore, the purpose is to promote adoption within these parties by showing them how easy it is to get a complete market overview through the OpenBB Terminal.

JerBouma avatar Jan 09 '23 15:01 JerBouma

@JerBouma - OECD has a free JSON API

There are some Python Libraries already available to parse it's SDMX format which is also used by a lot of other really interesting sources.

This one seems to not be actively developed: https://pandasdmx.readthedocs.io/en/latest/

But this fork does appear to be actively developed: https://sdmx1.readthedocs.io/en/latest/

https://github.com/khaeru/sdmx

There's a dated by likely still relevant example of use here: http://www.bondeconomics.com/2018/05/loading-oecd-data-with-python.html

Then there's this option which also appears to still be actively developed as well: https://github.com/Meaningful-Data/sdmxthon

joshuabuildsthings avatar Jan 29 '23 07:01 joshuabuildsthings

@JerBouma does your new PR close this :D

jmaslek avatar Mar 18 '23 02:03 jmaslek

@jmaslek Let's close it and I revisit later. There is much more useful stuff we can grab from there but that can be part of 4.0.

JerBouma avatar Mar 19 '23 10:03 JerBouma