diff options
Diffstat (limited to 'R')
| -rw-r--r-- | R/build_scenarios.R | 2 | ||||
| -rw-r--r-- | R/cds_functions_generic.R | 2 | ||||
| -rw-r--r-- | R/cds_utils.R | 7 | ||||
| -rw-r--r-- | R/intex_deal_functions.R | 2 | ||||
| -rw-r--r-- | R/yieldcurve.R | 2 |
5 files changed, 8 insertions, 7 deletions
diff --git a/R/build_scenarios.R b/R/build_scenarios.R index 1d7e7caf..7eb12a4d 100644 --- a/R/build_scenarios.R +++ b/R/build_scenarios.R @@ -101,7 +101,7 @@ for(j in seq_along(dealnames)){ if(i==1){ intexrecov[,i] <- recov.adj * (scenariosr[,i]/scenariosd[,1]) }else{ - intexrecov[,i] <- recov.adj * (scenariosr[,i]-scenariosr[,i-1])/(scenariosd[,i]-scenariosd[,i-1]) + intexrecov[,i] <- recov.adj * (scenariosr[,i] - scenariosr[,i-1])/(scenariosd[,i] - scenariosd[,i-1]) } } deal.dates <- getdealschedule(deal.data, "Quarterly") diff --git a/R/cds_functions_generic.R b/R/cds_functions_generic.R index 2cb53efc..9af140f4 100644 --- a/R/cds_functions_generic.R +++ b/R/cds_functions_generic.R @@ -568,7 +568,7 @@ bondhazardrate.shaped <- function(collateral, shape, R=0.4, alpha=0.25, beta=15, sc <- new("shapedcurve", h=0.05, shape=shape, alpha=alpha, beta=beta) eps <- 1e-8 counter <- 0 - if(collateral$price<3){ + if(collateral$price < 3){ cat("price is too low\n") sc <- new("shapedcurve", h=1e6, shape=shape, alpha=alpha, beta=beta) return( shapedtodpc(cs, sc, startdate) ) diff --git a/R/cds_utils.R b/R/cds_utils.R index 2b37788d..7553231a 100644 --- a/R/cds_utils.R +++ b/R/cds_utils.R @@ -36,7 +36,7 @@ addTenor <- function(date, tenor) { couponSchedule <- function(nextpaydate=NULL, maturity,
frequency=c("Quarterly", "Monthly", "Bimonthly", "Semiannual", "Annual"),
- coupontype, currentcoupon,
+ coupontype=c("FLOAT", "FIXED"), currentcoupon,
margin, tradedate=Sys.Date(), prevpaydate=tradedate){
## computes the coupon schedule
## inputs:
@@ -45,6 +45,7 @@ couponSchedule <- function(nextpaydate=NULL, maturity, ## frequency: letter specifying the frequency between "Q", "M", "B", "S" or "A"
## if startdate is provided, we generate the forward coupon schedule starting from that date.
frequency <- match.arg(frequency)
+ coupontype <- if (is.na(coupontype)) "FLOAT" else match.arg(coupontype)
bystring <- switch(frequency,
Quarterly = "3 months",
Monthly = "1 month",
@@ -84,11 +85,11 @@ couponSchedule <- function(nextpaydate=NULL, maturity, Bimonthly = "2m",
Annual = "1y")
forwards <- YC$forwardRate(dates, period)
- if(is.na(coupontype) || (toupper(coupontype)=="FLOAT" && !is.na(margin))){
+ if(coupontype == "FLOAT" && !is.na(margin)) {
## if is.na(margin) probably letter of credit
## we floor the coupon at the current gross rate
coupons <- pmax(currentcoupon, forwards + margin)
- }else{
+ } else {
coupons <- rep(currentcoupon, length(dates))
}
yf <- diff(c(0, yearFrac(prevpaydate, dates, "act/360")))
diff --git a/R/intex_deal_functions.R b/R/intex_deal_functions.R index 6fd34e9e..a1e4626b 100644 --- a/R/intex_deal_functions.R +++ b/R/intex_deal_functions.R @@ -346,7 +346,7 @@ severityfromscenarios <- function(scenariosd, scenariosr){ get.reinvassets <- function(dealname, tradedate){ r <- list() - sqlstr <- "select * from et_historicaldealinfo($1, $2) where ReinvFlag Is true" + sqlstr <- "SELECT * FROM et_historicaldealinfo($1, $2) WHERE ReinvFlag is true" data <- dbGetQuery(etdb, sqlstr, params=list(dealname, tradedate)) if(nrow(data)>0){ for(i in 1:nrow(data)){ diff --git a/R/yieldcurve.R b/R/yieldcurve.R index e8555054..aa76e91c 100644 --- a/R/yieldcurve.R +++ b/R/yieldcurve.R @@ -59,7 +59,7 @@ buildMarkitYC <- function(MarkitData, currency=c("USD", "EUR"), futurequotes){ return( tsQuotes ) } -exportYC <- function(tradedate=Sys.Date(), currency=c("USD", "EUR"), useFutures=FALSE){ +exportYC <- function(tradedate=Sys.Date(), currency=c("USD", "EUR"), useFutures=FALSE) { ## export the Yield Curve into the environment currency <- match.arg(currency) if(useFutures){ |
