diff options
Diffstat (limited to 'R')
| -rw-r--r-- | R/cds_functions_generic.R | 6 | ||||
| -rw-r--r-- | R/intex_deal_functions.R | 13 |
2 files changed, 15 insertions, 4 deletions
diff --git a/R/cds_functions_generic.R b/R/cds_functions_generic.R index 3dea5d17..19d27b19 100644 --- a/R/cds_functions_generic.R +++ b/R/cds_functions_generic.R @@ -472,6 +472,12 @@ bondhazardrate.shaped <- function(collateral, shape, R=0.4, alpha=0.25, beta=15) sc <- new("shapedcurve", h=0.05, shape=shape, alpha=alpha, beta=beta)
eps <- 1e-8
counter <- 0
+ if(collateral$price<1){
+ cat("price is too low\n")
+ h <- 1e6
+ return( shapedtodpc(cs, sc) )
+ }
+
while(abs(bondpv(cs, sc, R) - collateral$price/100) > eps){
dh <- (collateral$price/100 - bondpv(cs, sc, R))/dbondpv(cs, sc, R)
while(sc@h+dh<0){
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)
|
