aboutsummaryrefslogtreecommitdiffstats
path: root/R/mlpdb.R
diff options
context:
space:
mode:
Diffstat (limited to 'R/mlpdb.R')
-rw-r--r--R/mlpdb.R11
1 files changed, 8 insertions, 3 deletions
diff --git a/R/mlpdb.R b/R/mlpdb.R
index a3ebd5ec..11c146a5 100644
--- a/R/mlpdb.R
+++ b/R/mlpdb.R
@@ -9,12 +9,17 @@ nameToBasketID <- function(name, date=Sys.Date()){
return(as.integer(r))
}
-load.index <- function(name, date=Sys.Date(), tenor="5yr", Z=Z, w=w, N=Ngrid){
+load.index <- function(name, date=Sys.Date(), tenor="5yr", Z, w, N){
id <- nameToBasketID(name, date)
sqlstr <- "SELECT indexfactor, cumulativeloss, maturity from index_desc where basketid=%s and tenor='%s'"
r <- as.list(dbGetQuery(mlpdbCon, sprintf(sqlstr, id, tenor)))
- return(list(tenor=tenor, factor=r$indexfactor/100, maturity=r$maturity,
- loss=r$cumulativeloss/100, recovery=0.4, name=name, Z=Z, w=w, N=N))
+ if(any(c(missing(Z), missing(w), missing(N)))){
+ return( list(tenor=tenor, factor=r$indexfactor/100, maturity=r$maturity,
+ loss=r$cumulativeloss/100, recovery=0.4))
+ }else{
+ return( list(tenor=tenor, factor=r$indexfactor/100, maturity=r$maturity,
+ loss=r$cumulativeloss/100, recovery=0.4, name=name, Z=Z, w=w, N=N))
+ }
}
cdslist <- function(indexname, date=Sys.Date()){