RIC under Future chain with Expiry Date using python refinitiv dataplatform

Hi

Need help to get underlying RICs under Futures chain with expiry date of each underlying RICs via python refinitiv dataplatform

I tried below script facing issue, plz help me

input_excel = "chain_list.xlsx"
sheet_name="Sheet1"
column_name = "Chain RIC"

df_chains = pd.read_excel(input_excel, sheet_name="Sheet1")
chain_rics = df_chains['Chain RIC'].dropna().tolist()

def get_chain_expiry(chain_ric):
try:
chain_df = rdp.get_data(universe=chain_ric, fields=['LINK_CHAIN'])
if chain_df.empty or 'LINK_CHAIN' not in chain_df:
return pd.DataFrame()

    child_rics=chain_df['LINK_CHAIN'].dropna().tolist()

expiry_data = rdp.get_data(universe=child_rics, fields=['EXPIR_DATE'])
expiry_df['ParentChain']= chain_ric
return expiry_df

except Exception as e:
print(f"Error for {chain_ric}: {e}")
return pd.DataFrame()
all_expiry_data = pd.DataFrame()

for chain in chain_rics:
expiry_data = get_chain_expiry(chain)
all_expiry_data = pd.concat([all_expiry_data, expiry_data], ignore_index=True)
output_csv = "out_chain_list_1.csv"
all_expiry_data.to_csv(output_csv,index=False)
print(f"Saved expiry data to:{output_csv}")

Answers

  • Jirapongse
    Jirapongse ✭✭✭✭✭
    edited May 13

    @V1k

    Thank you for reaching out to us.

    Typically, the data retrieved by the library is similar to the data retrieved by the Workspace Excel via the =RDP.Data method.

    Please contact the helpdesk team via MyAccount to verify the =RDP.Data formula which can be used to retrieve the required data. Then, we can use the same RICs, fields, and parameters with the rdp.get_data method.

    Moreover, the RDP library is quite old so please use the new LSEG Data Library for Python instead. The LD Lib examples are available on GitHub.