aboutsummaryrefslogtreecommitdiffstats
path: root/R/parse_intex.R
blob: b9c52e07e163eea81ee817fd75281f5e49eedc0d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
root = "//WDSENTINEL/share/CorpCDOs"
source(file.path(root, "R", "intex_deals_functions.R"))
source(file.path(root, "R", "etdb.R"))
dealnames <- c("limes", "stonln1")
cusips <- cusipsfromdealnames(dealnames)

deals.universe <- dbGetQuery(dbCon, "select distinct dealname from clo_universe order by dealname asc")$dealname
cusips.universe <- cusipsfromdealnames(deals.universe)
n.scenarios <- 100
offset <- 2
r <- data.frame()
for(cusip in cusips){
    data <- read.table(paste(cusip, "-PY.txt", sep=""), sep="\t", header=T, nrow=3)
    price <- sum(as.numeric(sub("\\((.*)\\)", "-\\1", data[1,1:n.scenarios+offset])), na.rm=T)/n.scenarios
    wal <- sum(as.numeric(sub("\\((.*)\\)", "-\\1", data[2,1:n.scenarios+offset])), na.rm=T)/n.scenarios
    duration <- sum(as.numeric(sub("\\((.*)\\)", "-\\1", data[3,1:n.scenarios+offset])), na.rm=T)/n.scenarios
    r <- rbind(r, data.frame(cusip, price, wal, duration))
}