diff options
Diffstat (limited to 'R/cds_functions_generic.R')
| -rw-r--r-- | R/cds_functions_generic.R | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/R/cds_functions_generic.R b/R/cds_functions_generic.R index bf43bcd0..5407ccaa 100644 --- a/R/cds_functions_generic.R +++ b/R/cds_functions_generic.R @@ -596,13 +596,13 @@ tweakportfolio <- function(portfolio, epsilon, multiplicative=TRUE, forward.twea }
indexpv <- function(index, epsilon=0, tradedate=Sys.Date(), clean=TRUE,
- maturity=index$maturity, forward.tweak=1, check=FALSE){
+ maturity=index$maturity, forward.tweak=1, check=FALSE) {
## computes the intrinsic price of a portfolio of cds
## If maturity is provided, only computes the pv up to that point
## (Say we compute the 3 year pv based on 5 year curves
## forward.tweak only makes sense if epsilon is non zero
## and will teak the curves starting from forward.index
- if(epsilon!=0){
+ if(epsilon != 0){
portfolio <- tweakportfolio(index$portfolio, epsilon, forward.tweak=forward.tweak)
}else{
portfolio <- index$portfolio
@@ -624,8 +624,9 @@ indexpv <- function(index, epsilon=0, tradedate=Sys.Date(), clean=TRUE, return(NA)
}
}
- spread <- index$quotes$spread[index$quotes$maturity==maturity]
- r <- list(cl = spread * mean(cl.list), pl = mean(pl.list), bp = 1+mean(spread*cl.list-pl.list))
+ spread <- index$quotes$spread[index$quotes$maturity == index$maturity]
+ r <- list(cl = spread * mean(cl.list), pl = mean(pl.list),
+ bp = 1+mean(spread*cl.list-pl.list))
if(clean){
accrued <- cdsAccrued(tradedate, spread)
r$bp <- r$bp-accrued
|
