aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--R/build_cds_database.R18
1 files changed, 9 insertions, 9 deletions
diff --git a/R/build_cds_database.R b/R/build_cds_database.R
index 2d9e30e9..95696e4e 100644
--- a/R/build_cds_database.R
+++ b/R/build_cds_database.R
@@ -21,10 +21,10 @@ newbasketID <- function(series, offset){
}
}
-ig.indices <- c("19", "21", "22")
-igpattern <- "CDXIG5%s Curncy"
-hy.indices <- c("15", "17", "19", "21", "22")
-hypattern <- "CDXHY5%s Curncy"
+ig.indices <- c("9", "19", "21", "22")
+igpattern <- "CDX IG CDSI S%s 7Y Corp"
+hy.indices <- c("10", "15", "17", "19", "21", "22")
+hypattern <- "CDX HY CDSI S%s 7Y PRC Corp"
itraxx.indices <- c("19", "20", "21")
itraxxpattern <- "ITXEB5%s Curncy"
@@ -34,7 +34,6 @@ itraxxpattern <- "ITXEB5%s Curncy"
for(index in ig.indices){
assign(paste0("IG", index), bds(bbgConn, sprintf(igpattern, index), "INDX_MEMBERS"))
}
-assign("IG9", bds(bbgConn, "IBOXUG09 Curncy", "INDX_MEMBERS"))
for(index in hy.indices){
assign(paste0("HY", index), bds(bbgConn, sprintf(hypattern, index), "INDX_MEMBERS"))
@@ -52,6 +51,7 @@ for(index in all.indices){
}
tickers <- unique(all.names[,5])
+tickers <- tickers[-which(tickers=="")]
data <- bdp(bbgConn, paste(tickers, "Corp"), c("cds_company_id", "cds_restructuring_type", "cds_corp_tkr"))
data <- cbind(tickers, data)
unique.tickers <- aggregate(data, by=list(data$cds_company_id), FUN=function(x)x[1])$tickers
@@ -75,12 +75,12 @@ with(prep.data,
ticker_company <- dbGetQuery(dbCon, "SELECT company_id, unnest(cds_curve) from CDS_Issuers")
for(index in c(paste0("IG", c(9, 19, 21, 22)),
paste0("EU", c(9, 19, 21)),
- paste0("HY", c(15, 17, 19, 21, 22)))){
- indexmatch <- ticker_company[match(get(index)[get(index)[,2]>0,5], ticker_company[,2]),]
+ paste0("HY", c(10, 15, 17, 19, 21, 22)))){
+ indexmatch <- ticker_company[match(get(index)[,5], ticker_company[,2]),]
sqlstr <- "UPDATE CDS_Issuers SET index_list=index_list||%s where company_id='%s'"
- basketid <- nameToBasketID(index)
+ basketids <- allBasketID(index)
for(j in 1:nrow(indexmatch)){
- dbSendQuery(dbCon, sprintf(sqlstr, basketid, indexmatch[j,1]))
+ dbSendQuery(dbCon, sprintf(sqlstr, 182910, indexmatch[j,1]))
}
}