FX Forward Swap

I would like to be able to download with Python for a specific RIC for example 'EURFWD=' the RICs curve for the different tenors, i.e. get in Python what is obtained when it executes the following function in excel TR(EURFWD=;;"CH=Fd RH=IN";cell), Output --> [EUR=, EURON=, EURTN=.....EUR10Y].

I have tried the next funcion but it doesn't work,

ek.get_data('EURFWD=', fields = 'RIC_NAME')

Could you help me?

Thanks you for you help

Best Answer

  • Jirapongse
    Answer ✓

    @eva_maria.vela.palomino

    You can use the solution mentioned in this thread.

    def getUnderlying(baseRic):
        LONGNEXTLR = baseRic
        #For LONGLING1 to LONGLINK15 and LONGNEXTLR fields
        fields = ['LONGLINK{}'.format(x) for x in range(1, 15)]
        fields.append('LONGNEXTLR')
     
        all_underlying_rics = []
     
        #if LONGNEXTLR is not empty, try to retrieve the data fields
        while LONGNEXTLR!='':
            df,e = ek.get_data(LONGNEXTLR,fields)
            LONGNEXTLR = df.iloc[0]['LONGNEXTLR'] if pd.notnull(df.iloc[0]['LONGNEXTLR']) else ''
            
            #If LONGLINK<x> field is not null, append its value to all_underlying_rics list
            for x in range(1, 15):
                currentField = 'LONGLINK{}'.format(x)
                all_underlying_rics.append(df.iloc[0][currentField]) if pd.notnull(df.iloc[0][currentField]) else None
            #delay between each API call for 1 second
            time.sleep(1)
        return all_underlying_rics

    The output is:

    1646366605543.png