Error pulling RIC

I am geetting an error pulling the RIC HOSURF1.


TYpeError: get_data() missing 1 required positional argument: 'fields'


What other API fields do I need?

Tagged:

Best Answer

  • Jirapongse
    Jirapongse ✭✭✭✭✭
    Answer ✓

    @richard.willingham01

    The get_data method requires the fields parameter as the second parameter. If you run the command without it, you will get the following error.

    df, err = ek.get_data(['HOSURF1'])
    get_data() missing 1 required positional argument: 'fields'

    Therefore, you need to specify fields in the second parameter.

    HOSURF1 is a chain RIC that contains child RICs.

    First, you need to use the following code to gel all child RICs in HOSURF1.

    #Define getUnderlying() function
    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


    rics = getUnderlying('HOSURF1')

    I defined the getUnderlying method to get all child RICs and called the method with HOSURF1. The function returns a list of child RICs.

    Then, I called the get_data method with the list of child RICs and fields.

    df, err = ek.get_data(rics, ["GV4_DATE","GV4_TEXT","GEN_VAL1","PRIMACT_1"]);
    df

    The output is:

    91976-1.png

    You can use Eikon Quote to see available fields.

    91976-2.png

    You may need to refer to the Instrument Pricing Analytics - Volatility Surfaces and Curves article that shows how to use RDP to get Volatility Surfaces and Curves.

Answers