aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--R/load_cds_data.R30
1 files changed, 30 insertions, 0 deletions
diff --git a/R/load_cds_data.R b/R/load_cds_data.R
new file mode 100644
index 00000000..4a687cc5
--- /dev/null
+++ b/R/load_cds_data.R
@@ -0,0 +1,30 @@
+library(Rbbg)
+setwd("/home/share/CorpCDOs/data/bloomberg/CDS")
+bbgConn <- blpConnect(host='192.168.1.108', port='8194')
+ig.indices <- c("21", "22", "19")
+hy.indices <- c("21", "22", "19")
+allnames <- c()
+for(index in ig.indices){
+ allnames <- rbind(allnames, bds(bbgConn, sprintf("CDXIG5%s Curncy", index), "INDX_MEMBERS"))
+}
+for(index in hy.indices){
+ allnames <- rbind(allnames, bds(bbgConn, sprintf("CDXHY5%s Curncy", index), "INDX_MEMBERS"))
+}
+allnames <- unique(allnames)
+rownames(allnames) <- NULL
+cdscurves <- bds(bbgConn, paste(allnames[,5], "Curncy"), "CDS_CURVE_INFO")
+cdscurves <- cdscurves[,-c(1,8)]
+write.csv(cdscurves, file=paste0("single_names_", Sys.Date(), ".csv"), row.names=FALSE)
+
+data <- c()
+for(index in c("ig21", "ig19", "hy21", "hy19")){
+ df <- read.csv(paste0(index, "_tranches_bbgid.csv"), check.names=FALSE)
+ for(tenor in c("3Y", "5Y", "7Y")){
+ if(tenor %in% names(df)){
+ data <- rbind(data, bdp(bbgConn, paste(df[[tenor]], "Corp"), c("px_last", "tranche_delta", "underlying_reference_px_rt")))
+ }
+ }
+}
+
+write.csv(data, file=paste0("tranche_data_", Sys.Date(), ".csv"), row.names=TRUE)
+blpDisconnect(bbgConn)