question

Upvotes
Accepted
8 1 0 5

How to use RICs under a chain in a code without typing all underlying rics of a chain?


Is there a way to pull the cop xccy basis data for the whole curve in codebook without pulling each individual tenor ric? Example below, I have to enter all the RICs under COPCBS=TRNY. Can we just use COPCBS=TRNY and pull all necessary data like Bid and Ask across all tenors?


Currently i am using: df_cop_xccy_curve = ek.get_timeseries(['COPCBS3M=TRNY','COPCBS6M=TRNY','COPCBS3M=TRNY','COPCBS9M=TRNY','COPCBS1Y=TRNY','COPCBS18M=TRNY','COPCBS2Y=TRNY','COPCBS3Y=TRNY','COPCBS4Y=TRNY', 'COPCBS5Y=TRNY',,'COPCBS6Y=TRNY','COPCBS7Y=TRNY']) df_cop_xccy_curve


but this is quite long. I need to do this for every currency so would appreciate a way to speed this up basically im trying to pull the cross currency curves into python for all currencies so wondering if there's a way to do this quickly

eikon-data-api#technology#productpython apiricschain-ric
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvote
Accepted
86k 292 53 78

@HannaCP

Thank you for reaching out to us.

Please try this code:

LONGNEXTLR = 'COPCBS=TRNY'
fields = ['LONGLINK{}'.format(x) for x in range(1, 15)]
fields.append('LONGNEXTLR')
all_components = []
while LONGNEXTLR!='':
    df,e = ek.get_data(LONGNEXTLR,fields)
    LONGNEXTLR = df.iloc[0]['LONGNEXTLR'] if pd.notnull(df.iloc[0]['LONGNEXTLR']) else ''
    for x in range(1, 15):
        currentField = 'LONGLINK{}'.format(x)
        all_components.append(df.iloc[0][currentField]) if pd.notnull(df.iloc[0][currentField]) else None
        
ts = ek.get_timeseries(all_components[1:])
ts

The code gets the underlying RICs from this chain by accessing the LONGLINK fields directly. Then, it passes the list of underlying RICs to the get_timeseries method.



icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
8 1 0 5

thank you!

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.