pandas-datareader icon indicating copy to clipboard operation
pandas-datareader copied to clipboard

Add the European Central Bank's Statistical Data Warehouse as a Datasource

Open amaralvieira opened this issue 5 years ago • 1 comments

I've been testing a connection to the Statistical Data Warehouse in my fork of the pandas-datareader. It works much in the same way as the oecd and eurostat readers, as the SDMX schema only has slight differences: ECB SDMX 2.1 RESTful web service

Anyway, it is working for me, so I'm a bit optimistic that this could be useful for more people :)

For example, one can easily query the Euro short-term rate (€STR): df = web.DataReader('EST.B.EU000A2X2A25.WT','sdw',start='2020-02-21',end='2020-02-21')

Now, any tips on what I should do next even before starting to think about a pull request?

Thanks!

amaralvieira avatar Feb 24 '20 18:02 amaralvieira

If anyone finds this (like me) looking for a quick way to download yield curve data (so interest rates), save yourselves some trouble and know, that amaralvieira's code assumes the response schema to correlate with the series code. So for the example above it's "EST" In general, it does not, and you need to supply something called DSD (DataStructureDefinition). After painstaking research, it turns out for yield curve data (YC) the DSD is not called "YC" but... "FMD". And the number (version) changes, too.

So in amaralvieiras fork's code in sdw.py do this:

@property
 def dsd_url(self):
     """API DSD URL"""
     if not isinstance(self.symbols, string_types):
         raise ValueError("data name must be string")
     dataset, keys = self.symbols.split('.', 1)
     # url = "{0}/datastructure/ECB/ECB_{1}1?references=codelist"
     url = "{0}/datastructure/ECB/ECB_FMD2?references=codelist"
     # return url.format(self._URL, dataset)
     return url.format(self._URL)

and the yield curve data like this https://data.ecb.europa.eu/data/datasets/YC will work.

mkeds avatar Nov 08 '23 17:11 mkeds