Retrieve Historical Economic Data With Release Date Python API

Hi,

I'm trying to replicate the following table using Eikon Python API:

1645195824808.png

When I download it, in addition to reference point time series (first column above), I also get a worksheet with First Release Data (second column):

1645195896569.png

It is very important when performing backtests to avoid look-ahead bias, which is almost always the case when dealing with monthly economic data.

How am I able to replicate the table in the first image for not only this specific Brazil CPI series, but any economic data (=ECI) using Python API?

Thanks in advance,

Best Answer

  • Hi @tiago.marchiore,


    Would you happen to have Datastream DSWS? If so, does the below provide you with the nessesary data?


    df1 = ds.get_data(tickers="<BRCPIY=ECI>", # Datastream Mnemonic "BRCPW.%YR",
    fields=["DS.NDOR1", "DS.NDOR2", "DS.NDOR3", "DS.NDOR4", "DS.NDOR5", "DS.NDOR6", "DS.NDOR7", "DS.NDOR8", "DS.NDOR9", "DS.NDOR10", "DS.NDOR11", "DS.NDOR12"],
    kind=0) # ' kind=0 ' is needed here as we are looking for static data that doesn't change with time.


    1645468821865.png


Answers

  • hi @tiago.marchiore ,

    The code below can be used to retrieve the first release data.

    However, refer to the answer in this thread, the original release date cannot be retrieved using Eikon Data API but it could be retrieved using Datastream DSWS as mentioned by Jonathan in the comment above.

    import eikon as ek
    ek.set_app_key('#### YOUR VALID APP KEY ####')

    df=ek.get_timeseries(['BRCPIY=ECI'],start_date='2019-03-01',end_date='2022-02-20',interval='monthly')
    df

    1645545954572.png

    I hope this could help

  • DATASTREAM indeed solved my problem. You can access PIT (point in time) series for economic data, using the fields "REL1" for first release value and "DREL1" for first release date. Thanks!