aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--R/calibration.R2
-rw-r--r--R/cds_functions_generic.R6
-rw-r--r--R/thetas-durations.R7
-rw-r--r--sql/dawn.sql2
4 files changed, 10 insertions, 7 deletions
diff --git a/R/calibration.R b/R/calibration.R
index 3b1755bb..936e2a2c 100644
--- a/R/calibration.R
+++ b/R/calibration.R
@@ -38,7 +38,7 @@ set.singlenamesdata <- function(index, tradedate, recov=NULL) {
quotes$recovery[i,] <- rep(0.4, 8)
}
quotes$upfront_curve[i, tenor] <- pmax(-yearFrac(tradedate+2, cds.cs$cdsdates)*
- quotes$spread_curve[i, tenor]*1e-2,
+ quotes$spread_curve[i, tenor] * 1e-2,
quotes$upfront_curve[i, tenor])
quote <- list(ticker = quotes$ticker[i],
running = quotes$spread_curve[i, tenor] * 1e-4,
diff --git a/R/cds_functions_generic.R b/R/cds_functions_generic.R
index e8fd569d..2cb53efc 100644
--- a/R/cds_functions_generic.R
+++ b/R/cds_functions_generic.R
@@ -545,14 +545,14 @@ cdshazardrate <- function(quotes, R=0.4, tradedate=Sys.Date(), cs.all){
while(abs(cdspv(cs, sc, R, tradedate) + quotes$upfront[i] - acc) > eps && count < 500) {
dh <- - (quotes$upfront[i] + cdspv(cs, sc, R, tradedate) - acc)/
dcdspv(cs, sc, R, tradedate, index)
- while( (new.h + dh) < 0 ) {
- dh <- dh * 0.8
- }
new.h <- new.h + dh
hvec <- c(previous.hvec, rep(new.h, flength))
sc@hazardrates <- hvec
count <- count + 1
}
+ if (count == 500) {
+ cat(sprintf("could not compute hazard rate for %s\n", quotes$maturity[i]))
+ }
previous.hvec <- hvec
previous.maturity <- maturity
previous.cs <- cs
diff --git a/R/thetas-durations.R b/R/thetas-durations.R
index 90646b06..a9a74b83 100644
--- a/R/thetas-durations.R
+++ b/R/thetas-durations.R
@@ -112,6 +112,9 @@ for(index in c('IG', 'HY', 'EU', 'XO')) {
0, tradedate, IMMDate(tradedate, "prev"))
quotes <- data.frame(upfront=(100-as.numeric(indexquotes[i,maturities$tenor]))/100,
maturities)
+ ## prevent negative hazardrates
+ quotes$upfront <- pmax(yearFrac(tradedate + 1, quotes$maturity, "act/360") *
+ quotes$running + 1e-6, quotes$upfront)
sc <- cdshazardrate(quotes, recov, tradedate, cs)
c(fastduration(sc, cs, tradedate, maturities$maturity),
fasttheta(sc, cs, recov, tradedate, maturities$maturity, quotes$upfront, coupon))
@@ -125,8 +128,8 @@ for(index in c('IG', 'HY', 'EU', 'XO')) {
## 0, tradedate, IMMDate(tradedate, "prev"))
## quotes <- data.frame(upfront=(100-as.numeric(indexquotes[i,maturities$tenor]))/100,
## maturities)
- ## quotes <- data.frame(upfront=(100-as.numeric(indexquotes[i,-1]))/100, maturities) %>%
- ## arrange(maturity)
+ ## quotes$upfront <- pmax(yearFrac(tradedate + 1, quotes$maturity, "act/360") *
+ ## quotes$running + 1e-6, quotes$upfront)
## sc <- cdshazardrate(quotes, recov, tradedate, cs)
## durandthetas <- rbind(durandthetas, c(fastduration(sc, cs, tradedate, maturities$maturity),
## fasttheta(sc, cs, recov, tradedate, maturities$maturity, quotes$upfront, coupon)))
diff --git a/sql/dawn.sql b/sql/dawn.sql
index 597f37a7..1450956e 100644
--- a/sql/dawn.sql
+++ b/sql/dawn.sql
@@ -1037,7 +1037,7 @@ CREATE TYPE strategy AS ENUM('CLOCDSCSH', 'CLO_AAA', 'CLO_BB20', 'CLO_BBB', 'CSH
'MTG_IO', 'MTG_LMG', 'MTG_PR', 'MTG_RW', 'MTG_SD', 'MTG_THRU',
'SERCGLLC__SERCGLLC', 'SERCGLTD__SERCGLTD', 'SERCGLTD__SERLTD_EXP',
'SER_TEST__SER_TEST', 'STR_MAV', 'STR_MEZZ', 'HYOPTDEL', 'HYPAYER', 'HYCDSCSH',
- 'ITRXCURVE')
+ 'ITRXCURVE', 'ITRXCVCSH')
CREATE TABLE valuation_reports(
custacctname text,