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.
Best Answer
-
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_dfIPODate_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:
0
Answers
-
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.ipynb0 -
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.
0 -
You can find details about the nomeclature of CDS RICs in the Workspace application 'CDS/SINGLE Quote':
0 -
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.
First 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.
I 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.
0 -
Hi @susana.chang, 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':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
0 -
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"]]0 -
@jonathan.legrand - any ideas on how I would reconstruct RICs for sovereign CDS? Thanks!Hi0
Categories
- All Categories
- 3 Polls
- 6 AHS
- 36 Alpha
- 166 App Studio
- 6 Block Chain
- 4 Bot Platform
- 18 Connected Risk APIs
- 47 Data Fusion
- 34 Data Model Discovery
- 685 Datastream
- 1.4K DSS
- 616 Eikon COM
- 5.2K Eikon Data APIs
- 10 Electronic Trading
- Generic FIX
- 7 Local Bank Node API
- 3 Trading API
- 2.9K Elektron
- 1.4K EMA
- 252 ETA
- 557 WebSocket API
- 38 FX Venues
- 14 FX Market Data
- 1 FX Post Trade
- 1 FX Trading - Matching
- 12 FX Trading – RFQ Maker
- 5 Intelligent Tagging
- 2 Legal One
- 23 Messenger Bot
- 3 Messenger Side by Side
- 9 ONESOURCE
- 7 Indirect Tax
- 60 Open Calais
- 275 Open PermID
- 44 Entity Search
- 2 Org ID
- 1 PAM
- PAM - Logging
- 6 Product Insight
- Project Tracking
- ProView
- ProView Internal
- 22 RDMS
- 1.9K Refinitiv Data Platform
- 654 Refinitiv Data Platform Libraries
- 4 LSEG Due Diligence
- LSEG Due Diligence Portal API
- 4 Refinitiv Due Dilligence Centre
- Rose's Space
- 1.2K Screening
- 18 Qual-ID API
- 13 Screening Deployed
- 23 Screening Online
- 12 World-Check Customer Risk Screener
- 1K World-Check One
- 46 World-Check One Zero Footprint
- 45 Side by Side Integration API
- 2 Test Space
- 3 Thomson One Smart
- 10 TR Knowledge Graph
- 151 Transactions
- 143 REDI API
- 1.8K TREP APIs
- 4 CAT
- 27 DACS Station
- 121 Open DACS
- 1.1K RFA
- 104 UPA
- 193 TREP Infrastructure
- 229 TRKD
- 917 TRTH
- 5 Velocity Analytics
- 9 Wealth Management Web Services
- 90 Workspace SDK
- 11 Element Framework
- 5 Grid
- 18 World-Check Data File
- 1 Yield Book Analytics
- 46 中文论坛