diff options
Diffstat (limited to 'R')
| -rw-r--r-- | R/cds_functions_generic.R | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/R/cds_functions_generic.R b/R/cds_functions_generic.R index 2fc967e3..3ea19b14 100644 --- a/R/cds_functions_generic.R +++ b/R/cds_functions_generic.R @@ -570,7 +570,7 @@ indexduration <- function(index){ return( mean(durations) )
}
-indexspread <- function(index){
+indexspread <- function(index, tradedate=Sys.Date()){
## computes the spread of a portfolio of survival curves
## S <- 0
## d <- rep(0, length(portfolio))
@@ -578,15 +578,17 @@ indexspread <- function(index){ ## d[i] <- cdsduration(portfolio[[i]]@curve, index$maturity)
## S <- S + d[i] * cdsspread(portfolio[[i]]@curve, index$maturity, portfolio[[i]]@recovery)
## }
- S <- index$spreadref-(indexpv(index)$bp-1)/indexduration(index)
+ temp <- indexpv(index, tradedate=tradedate)
+ S <- index$quotes$spread*(1-(temp$bp-1)/temp$cl)
return(S)
}
indextheta <- function(index, tradedate=Sys.Date()){
current.pv <- indexpv(index, tradedate=tradedate)$bp
- newmaturity <- index$cs$dates[nrow(orig.cs)-4]
+ newmaturity <- index$cs$dates[nrow(index$cs)-4]
+ index$quotes$maturity <- newmaturity
forward.pv <- indexpv(index, tradedate=tradedate, maturity=newmaturity)$bp
- theta <- forward.pv-current.pv+index$spreadref
+ theta <- forward.pv-current.pv+index$quotes$spread
return( theta )
}
|
