diff options
Diffstat (limited to 'R/load_cf.R')
| -rw-r--r-- | R/load_cf.R | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/R/load_cf.R b/R/load_cf.R index df70e277..26cf22e9 100644 --- a/R/load_cf.R +++ b/R/load_cf.R @@ -283,6 +283,7 @@ getcusipcf <- function(params, cfdata, dist, tradedate=Sys.Date()){ return(cusipdata)
}
+
compute.delta <- function(indexdist, dealdata, cusip.pv, K1=0, K2=1){
dealweight <- dealdata$weight
dealprice <- dealdata$price
@@ -292,7 +293,9 @@ compute.delta <- function(indexdist, dealdata, cusip.pv, K1=0, K2=1){ scenariosr <- matrix(0, length(dealweight), nT)
for(t in 1:nT){
scenariosl[,t] <- interpvalues(indexdist$L[,t], seq(0, 1, length=Ngrid), dealweight)
- scenariosr[,t] <- interpvalues(indexdist$R[,t], seq(0, 1, length=Ngrid), dealweight)
+ ## numerical artefact, but we want scenariosr[i,] + scenariosl[i,] <= 1 at all times
+ scenariosr[,t] <- pmin(interpvalues(indexdist$R[,t], seq(0, 1, length=Ngrid), dealweight),
+ 1-scenariosl[,t])
}
## we assume the index is fully funded - need to be changed depending
## on how we fund the swaps (hence floating coupon instead of fixed)
|
