How do we get the historical credit spread for 0#AAGBPBMK=?

"Invalid RIC" error in Eikon Phython API RIC: 0#AAGBPBMK= RIC = "0#AAGBPBMK=" ek.get_timeseries([RIC], fields = "TR.CREDITSPREAD", start_date = start_date, end_date = end_date, interval="daily")

Best Answer

  • @Rachiel Angiela Barbosa Is this what you are looking for:

    rics, err = ek.get_data('0#AAGBPBMK=','CF_NAME')
    rics


    This will give you a list of RICs for which you can then request spread data - in this case there are two chain entries that are not instruments so I exclude these by checking the last character of the RIC:

    data = pd.DataFrame()

    for ric in rics['Instrument'].astype(str).values.tolist():
        if ric[-1] == '=':
            df,err = ek.get_data([ric], fields=["TR.BENCHMARKSPREAD.date","TR.BENCHMARKSPREAD"], parameters={'SDate' : '2021-08-07', 'EDate': '2021-05-07', 'Frq':"D"})
            if len(data):
                data = pd.concat([data, df], axis=0)        
            else:
                data = df
    data.reset_index(inplace=True)
    data

    Screenshot 2021-09-20 at 11.51.44.png

    I hope this can help.