aboutsummaryrefslogtreecommitdiffstats
path: root/R/intex_deal_functions.R
diff options
context:
space:
mode:
Diffstat (limited to 'R/intex_deal_functions.R')
-rw-r--r--R/intex_deal_functions.R27
1 files changed, 13 insertions, 14 deletions
diff --git a/R/intex_deal_functions.R b/R/intex_deal_functions.R
index 17750244..824e0710 100644
--- a/R/intex_deal_functions.R
+++ b/R/intex_deal_functions.R
@@ -47,16 +47,16 @@ listdealnames <- function() {
return( dbGetQuery(etdb, sqlstring))
}
-cusip.data <- function(workdate = Sys.Date()) {
- sqlstring <- "SELECT DISTINCT ON (cusip) cusip, maturity, coupon AS grosscoupon,
+tranche.data <- function(workdate = Sys.Date()) {
+ sqlstring <- "SELECT DISTINCT ON (figi) figi, maturity, coupon AS grosscoupon,
spread, CASE WHEN floater_index like 'LIBOR%' THEN 'FLOAT' ELSE 'FIXED' END
- AS fixedorfloat, orig_moody FROM cusip_universe JOIN clo_universe
- ON clo_universe.\"Latest Update\" = cusip_universe.updatedate
- AND clo_universe.dealname = cusip_universe.dealname
-WHERE updatedate<=$1 ORDER BY cusip, updatedate DESC"
+ AS fixedorfloat, orig_moody FROM tranche_universe JOIN clo_universe
+ ON clo_universe.\"Latest Update\" = tranche_universe.updatedate
+ AND clo_universe.dealname = tranche_universe.dealname
+WHERE updatedate<=$1 ORDER BY figi, updatedate DESC"
data <- dbGetQuery(etdb, sqlstring, workdate)
data <- data.table(data)
- setkey(data, "cusip")
+ setkey(data, "figi")
return( data )
}
@@ -80,10 +80,10 @@ recovery <- function(collateral) {
return(recovery)
}
-dealnamefromcusip <- function(cusips){
+dealnamefromfigi <- function(figiss){
## wrapper around the sql function
- sqlstr <- sprintf("select * from dealname_from_cusip('%s')",
- paste(cusips, collapse="','"))
+ sqlstr <- sprintf("select * from dealname_from_figi('%s')",
+ paste(figiss, collapse="','"))
r <- dbGetQuery(etdb, sqlstr)
return( r$p_dealname )
}
@@ -248,15 +248,14 @@ buildSC <- function(line.item, reinvdate, dealmaturity, global.params, startdate
return( list(SC=SC, notional=line.item$currentbalance, price = line.item$price, beta = beta) )
}
-buildSC.portfolio <- function(dealname, dealdata, cusipdata, global.params, startdate = Sys.Date()) {
+buildSC.portfolio <- function(dealname, dealdata, tranchedata, global.params, startdate = Sys.Date()) {
collatdata <- data.table(getcollateral(dealname, startdate))
- setkey(collatdata, "cusip")
+ setkey(collatdata, "figi")
## replace the cdo fields by bloomberg data
- collatdata[cusipdata,
+ collatdata[tranchedata,
`:=`(maturity=i.maturity, fixedorfloat=i.fixedorfloat,
spread=i.spread, grosscoupon=i.grosscoupon, orig_moody=i.orig_moody, iscdo=TRUE),
allow.cartesian=TRUE]
-
portfolio <- foreach(line.item = iter(collatdata, by='row')) %:% {
when( !is.na(line.item$maturity) && !is.na(line.item$currentbalance) &&
line.item$currentbalance > 1 &&