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.R13
1 files changed, 9 insertions, 4 deletions
diff --git a/R/intex_deal_functions.R b/R/intex_deal_functions.R
index d2897119..8f844598 100644
--- a/R/intex_deal_functions.R
+++ b/R/intex_deal_functions.R
@@ -159,7 +159,7 @@ stackcurve <- function(SC, line.item, global.params, startdate){
}
buildSC.matured <- function(SC, line.item, reinvdate, dealmaturity, global.params, startdate){
- if(startdate<=reinvdate){ #reinvest
+ if(!is.na(reinvdate) && startdate<=reinvdate){ #reinvest
line.item$maturity <- min(dealmaturity, startdate + global.params$rollingmaturity)
SC <- stackcurve(SC, line.item, global.params, startdate)
}else{ #no reinvestment
@@ -237,13 +237,18 @@ buildSC.portfolio <- function(dealname, dealdata, cusipdata, global.params, star
stop("empty maturity")
}
##most likely equity, doesn't impact the risk anyway
- if(line.item$currentbalance < 1){
+ if(line.item$currentbalance < 1 || line.item$assettype=="Equity"){
next
}
- ## overwrite the data with cusipdata info, because it should be higher quality
+ ## overwrite the data with cusipdata info if not NA,
+ ## because it should be higher quality
## e.g all cdos in acacl061 had wrong maturity
if(has.key(line.item$cusip, index)){
- line.item[,fields] <- cusipdata[index[[line.item$cusip]],fields]
+ for(field in fields){
+ if(!is.na(cusipdata[index[[line.item$cusip]],field])){
+ line.item[field] <- cusipdata[index[[line.item$cusip]],field]
+ }
+ }
}
temp <- buildSC(line.item, dealdata$"Reinv End Date", dealdata$maturity, global.params, startdate)
notionalvec <- c(notionalvec, temp$notional)