aboutsummaryrefslogtreecommitdiffstats
path: root/R/cds_functions_generic.R
diff options
context:
space:
mode:
Diffstat (limited to 'R/cds_functions_generic.R')
-rw-r--r--R/cds_functions_generic.R4
1 files changed, 2 insertions, 2 deletions
diff --git a/R/cds_functions_generic.R b/R/cds_functions_generic.R
index 26037343..064b50eb 100644
--- a/R/cds_functions_generic.R
+++ b/R/cds_functions_generic.R
@@ -553,7 +553,7 @@ indexpv <- function(index, epsilon=0, tradedate=Sys.Date(), clean=TRUE){
startdate <- tradedate + 1
cl.list <- unlist(lapply(portfolio, function(x){couponleg(index$cs, x@curve, startdate)}))
pl.list <- unlist(lapply(portfolio, function(x){defaultleg(index$cs, x@curve, x@recovery, startdate)}))
- accrued <- cdsAccrued(tradedate, index$coupon)
+ accrued <- cdsAccrued(tradedate, index$spreadref)
r <- list(cl = mean(cl.list) - accrued, pl = mean(pl.list), bp = 1+mean(cl.list-pl.list))
if(clean){
r$bp <- r$bp-accrued
@@ -614,7 +614,7 @@ tweakcurves <- function(index, tradedate=Sys.Date()){
## computes the tweaking factor
epsilon <- 0
f <- function(epsilon, ...){
- abs(indexpv(index, epsilon, tradedate)$bp - index$indexref)
+ abs(indexpv(index, epsilon, tradedate)$bp - index$priceref)
}
epsilon <- optimize(f, c(-0.5, 0.5), index, tol=1e-6)$minimum
cat("tweak = ", epsilon, "\n")