Upgrade from Eikon -> Workspace. Learn about programming differences.

For a deeper look into our Eikon Data API, look into:

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
3 0 1 4

Historical CDS Data for a certain time range

Hey I used the __Examples__/03. Quantitative Analytics/03.05. Credit Derivatives/CDS.ipynb codebook in the Workspace for some information's on CDS Data. What I need is the historical CDS Spreads from Single Name CDS that were traded by non-sovereign from the time range 01.01.2006 until 31.12.2010. How do I get this data could someone please help me out what line of codes I have to write in order to get this data ? All the codes I saw in this forum did not work on my case and I also need the code for a specific time range.

#technologydatapython apihistorical
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.

Hi @sahin.yigit , Could you let me know of an example CDS Spread you're after; specifically, I'm looking for a RIC, e.g.: VOD.L or ARGV5YUSAC=MP.
Also: would you mind letting me know if the Search API fullfill your need? There's an example of its use in CodeBook under:
__Examples__/01. Data Retrieval and Discovery/01.01. Refinitiv Data Library/Content__Search.ipynb

Hello @jonathan.legrand,


sure I can provide you the information. For example the CDS Spreads of the RIC: AMZN5YUSAX=MG for a past time range. As I said in my case it would be 01.01.2006-31.12.2010.

Yes the Search API fulfills my needs since it provides me the Ask and Bid Spreads of every Single Name CDS and it also has the option of showing the start and the end date. I would like to set a fix start and end date of the CDS´s and have as an output every CDS and its spread that has been traded in this time rage. I would be really thankful if you could help me out with this.

1 Answer

· Write an Answer
Upvotes
Accepted
5.8k 21 2 6

Hi @sahin.yigit,

Is this what you're after?

import pandas as pd
from datetime import datetime
import refinitiv.data as rd
rd.open_session()


# Find info on the fields we can use in `select` & `filter`:
response: rd.delivery._data._response.Response = rd.content.search.metadata.Definition(
    view = rd.content.search.Views.CDS_INSTRUMENTS).get_data()
# Export metadata to a spreadsheet for easy viewing:
response.data.df.to_excel("CDS_INSTRUMENTS.xlsx")


I looked in the outputed excel doc to find the fields I thought would be interesting.

Note that all the fields in that show up in that Excel Workbook are not nessesrily useful for CDSs; I used a lot of them in search requests (below) and found the ones returning data through quick trial and error proccesses.


srch_resp: rd.delivery._data._response.Response  = rd.content.search.Definition(
    view = rd.content.search.Views.CDS_QUOTES,  # for info on `SearchViews`, you can use `help(rd.content.search.SearchViews)`
    query="GE5YUSAX*", # Search all CDS that start with AMZN, which is Amazon's RIC
    filter="IsSovereign eq false", # "((AcquirerCompanyName ne 'Creditors' and AcquirerCompanyName ne 'Shareholder') and (TargetCountry eq 'US' or TargetCountry eq 'UK') and TransactionValueIncludingNetDebtOfTarget ge 100 and TargetPublicStatus eq 'Public') and (TransactionStatus eq 'Completed' or TransactionStatus eq 'Pending' or TransactionStatus eq 'Withdrawn')" # and InsertDateTime lt 2010-12-31
    select="RIC, IsSovereign, BuildDateTime, InsertDateTime,ContractCdsRicRoot,IntradayConstituentRICExists,IsBenchmarkRic,IsContractTrancheRic,IsPrimaryRIC,IssuerEquityPrimaryRIC,LiquidityRIC,PriceSource,RefEntityFamilyValuationRic,RefEntityImmediateParentIssueValuationRic,RefEntityIssueValuationRic,RICLength,RicRoot,RICUsageCount",
    top = 100, # max is 10000
    order_by = 'InsertDateTime asc').get_data()
srch_resp_df: pd.DataFrame = srch_resp.data.df
srch_resp_df


1699549331773.png


IPODate_df: pd.DataFrame = rd.get_data(
    universe=srch_resp_df.IssuerEquityPrimaryRIC.iloc[0],
    fields=["TR.IPODate"])
IPODate_df["IPO Date"][0]

Timestamp('1892-06-23 00:00:00')

if IPODate_df["IPO Date"][0] < datetime.strptime("2006-01-01", "%Y-%m-%d"):
    df: pd.DataFrame = rd.get_history(
        universe=srch_resp_df.RIC.iloc[5],
        start="2006-01-01",
        end="2010-12-31",
        fields=["TR.PARMIDSPREAD",
            "BID", "ASK", "TR.ASKSPREAD", "TR.BIDSPREAD",
                "TR.ASSETSWAPSPREAD", "TR.BENCHMARKSPREAD",
                "ASK_SPREAD", "MID_SPREAD"]) # You can find the `fields`` you are after in the DIB: https://developers.lseg.com/en/video-catalog/data-item-browser
_df: pd.DataFrame = df[["Ask Spread", "Bid Spread"]]


df["Par Mid Spread"].dropna()


Date

2007-10-17 27.802

2007-10-18 29.111

...

2010-12-30 112.256

2010-12-31 112.881

Name: Par Mid Spread, Length: 574, dtype: Float64



I found the `fields` in the `get_history` call as below:

1699549252880.png



1699549331773.png (44.2 KiB)
1699549252880.png (113.6 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.

You can find details about the nomeclature of CDS RICs in the Workspace application 'CDS/SINGLE Quote':


1699551819117.png

1699551819117.png (98.9 KiB)
Hi @jonathan.legrand - any ideas on how I would reconstruct RICs for sovereign CDS? Thanks!

Hey @jonathan.legrand first of all thanks for your detailed answer.

I tried everything you provided and it worked well but still gives me some issues.
screenshot-2023-11-13-173645.jpgFirst of all if I use the filter InsertDateTime lt 2010-12-31 i get no output at all even if I set the query to "*" in order to search for all CDS there are. Also I tried to set several filters at the same time and if I do so I get no output at all as well. But the idea is great I want to look for every CDS Spread that existed during 2006-01-01 and 2010-12-31 under certain filters.

Further I tried the codes you provided. If I let the filter "IsSovereign eq false" as you provided it I get the following results if I display df in the last code.screenshot-577.pngI can not find where you defined which CDS should be displayed here.Right now the RIC AXP1YUSAC=R is displayed, but I would rather see all different RIC´s during the specific time range. Also how can I get the rows that are hidden in the output due to space it would consume. I hope I could explained well enough what I am looking for. Anyway thank you very much for your help so far hopefully we can figure out the last problems as well.

Hi @sahin.yigit, I tested the above with `InsertDateTime gt 2010-12-31`, which came up with results; it's looking like expired CDSs are not indexed, meaning that they can't be found in Search like this. I know that we are looking at proccesses to index them, internally, allowing users to find them in Search, in the future.
What this means is that you may have to have two workflows: one using Search to find non-expired assets, and another for expired ones.
To find the RICs of expired options, please use the details about the nomeclature of CDS RICs in the Workspace application 'CDS/SINGLE Quote':


1699551819117.png


You can see how my coleague did similar work in his article:

Reconstructing RICs for expired futures contracts

Finding Expired Options and Backtesting a Short Iron Condor Strategy

Python Type Hint Finance Use Case: Implied Volatility and Greeks of Index 'At The Money' Options: Part 2

When it comes to the `srch_resp_df.RIC.iloc[5]`, you can look for any other RIC of interest changing the `5`, e.g.: to `0`, `1`, ...


if IPODate_df["IPO Date"][0] < datetime.strptime("2006-01-01", "%Y-%m-%d"):
    df: pd.DataFrame = rd.get_history(
        universe=srch_resp_df.RIC.iloc[0],
        start="2006-01-01",
        end="2010-12-31",
        fields=["TR.PARMIDSPREAD",
            "BID", "ASK", "TR.ASKSPREAD", "TR.BIDSPREAD",
                "TR.ASSETSWAPSPREAD", "TR.BENCHMARKSPREAD",
                "ASK_SPREAD", "MID_SPREAD"]) # You can find the `fields`` you are after in the DIB: https://developers.lseg.com/en/video-catalog/data-item-browser
_df: pd.DataFrame = df[["Ask Spread", "Bid Spread"]]


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.