question

Upvotes
Accepted
39 4 6 7

Datastream API Tenor in Timeseries Response

I'm using datastream to get a time series, but I cannot figure out how to get the tenor in the response.

The Below Returns me (Instrument, Datatype, Value, Currency, Dates).

Ideally I would be able to Extract out a tenor column with values 1M, 3M, 6M, 1Y, 3Y without having to try and break it out of the RIC Code. How can this be achived?

Thanks,


Adam


dateString = "2022-07-14"

market_data_df = ds.get_data(tickers='<USYTFRB1M=RR>,<USYTFRB2M=RR>,<USYTFRB3M=RR>,<USYTFRB6M=RR>,<US1YT=RR>,<US2YT=RR>,<US3YT=RR>,<US5YT=RR>,<US7YT=RR>,<US10YT=RR>,<US20YT=RR>,<US30YT=RR>', fields=['RY'], start=f'{dateString}',end=f'{dateString}', kind=1)

market_data_df


datastream-apidsws-api
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
78.8k 250 52 74

@Archi

I am unable to find a data type that can provide the tenor but I found that the "NAME" data type contains the tenor.

df = ds.get_data(tickers='<USYTFRB1M=RR>,<USYTFRB2M=RR>,<USYTFRB3M=RR>,<USYTFRB6M=RR>,<US1YT=RR>,<US2YT=RR>,<US3YT=RR>,<US5YT=RR>,<US7YT=RR>,<US10YT=RR>,<US20YT=RR>,<US30YT=RR>',  fields= ['NAME'],kind=0)

1657860351663.png

We can extract the tenor from the NAME data type.

df["Tenor"] = df["Value"].str.split().str[-1]

The output is:

1657860462124.png

However, please contact the Datastream Webservice support team directly via MyRefinitiv to confirm this.


1657860351663.png (26.2 KiB)
1657860462124.png (34.4 KiB)
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
39 4 6 7

Pretty good - any way to get that DataType as a column rather than as a set of separate rows.


1657862138945.png



1657862138945.png (43.9 KiB)
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.

@Archi

You can use the pivot method to reformat the result.

dateString = "2022-07-14"

market_data_df = ds.get_data(tickers='<USYTFRB1M=RR>,<USYTFRB2M=RR>,<USYTFRB3M=RR>,<USYTFRB6M=RR>,<US1YT=RR>,<US2YT=RR>,<US3YT=RR>,<US5YT=RR>,<US7YT=RR>,<US10YT=RR>,<US20YT=RR>,<US30YT=RR>', fields=['RY','NAME'], start=f'{dateString}',end=f'{dateString}', kind=0)

market_data_df = market_data_df.pivot(index='Instrument', columns='Datatype')['Value']

market_data_df["Tenor"] = market_data_df["NAME"].str.split().str[-1]

market_data_df

The output is:

1657862514439.png

1657862514439.png (35.1 KiB)

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.