aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--R/calibration.R14
-rw-r--r--R/yieldcurve.R18
-rw-r--r--python/yieldcurve.py2
3 files changed, 17 insertions, 17 deletions
diff --git a/R/calibration.R b/R/calibration.R
index 936e2a2c..11f98c24 100644
--- a/R/calibration.R
+++ b/R/calibration.R
@@ -79,12 +79,12 @@ set.tranchedata <- function(index, tradedate){
index$quotes <- data.frame(maturity=index$maturity,
refspread=temp$indexrefspread[1],
refprice=temp$indexrefprice[1])
- index$quotes$spread <- couponfromindex(index$name, index$tenor)*1e-4
+ index$quotes$spread <- couponfromindex(index$name, index$tenor) * 1e-4
index$cs <- couponSchedule(IMMDate(tradedate, noadj=TRUE), index$maturity, "Q", "FIXED", 1,
0, tradedate, IMMDate(tradedate, "prev"))
- if(!is.na(index$quotes$refprice) && index$quotes$refprice != 0){
+ if(!is.na(index$quotes$refprice) && index$quotes$refprice != 0) {
index$quotes$price <- index$quotes$refprice/100
- }else{
+ } else {
index$quotes$price <- snacpv(index$cs, index$quotes$refspread[1]*1e-4, index$quotes$spread,
if (index$type %in% c("IG", "EU")) 0.4 else 0.3, tradedate)
@@ -97,7 +97,7 @@ set.tranchedata <- function(index, tradedate){
index <- c(index, tweak)
index$defaultprob <- 1 - SPmatrix(index$portfolio, index$cs$dates)
negprob <- which(index$defaultprob < 0, arr.ind=T)
- if(nrow(negprob) > 0){
+ if(nrow(negprob) > 0) {
stop(paste(index$portfolio[[negprob[1,1]]]@issuer, "has negative probability, check single names data"))
}
K <- c(0, temp$detach/100)
@@ -105,13 +105,13 @@ set.tranchedata <- function(index, tradedate){
index$K <- adjust.attachments(K, index$loss, index$factor)
## convert snac prices to proper upfront
- if(index$type == "XO"){
+ if(index$type == "XO") {
coupon <- 500
temp$trancheupfrontmid[4] <- 100 * ( 1 - snacpv(index$cs, temp$trancherunningmid[4]*1e-4,
coupon*1e-4, 0.4, tradedate))
temp$trancherunningmid[4] <- coupon
}
- if(index$type =="EU"){
+ if(index$type =="EU") {
if(index$series>=21){
coupon <- 100
temp$trancheupfrontmid[3] <- 100 * ( 1 - snacpv(index$cs, temp$trancherunningmid[3]*1e-4,
@@ -119,7 +119,7 @@ set.tranchedata <- function(index, tradedate){
temp$trancheupfrontmid[4] <- 100 * ( 1 - snacpv(index$cs, temp$trancherunningmid[4]*1e-4,
coupon*1e-4, 0.4, tradedate))
temp$trancherunningmid[3:4] <- coupon
- }else if(index$series == 9){
+ }else if(index$series == 9) {
for(i in 4:5){
coupon <- 100
temp$trancheupfrontmid[i] <- 100 * ( 1 - snacpv(index$cs, temp$trancherunningmid[i]*1e-4,
diff --git a/R/yieldcurve.R b/R/yieldcurve.R
index e53e3f5a..e8555054 100644
--- a/R/yieldcurve.R
+++ b/R/yieldcurve.R
@@ -27,7 +27,7 @@ buildMarkitYC <- function(MarkitData, currency=c("USD", "EUR"), futurequotes){
deposits <- list()
futures <- list()
swaps <- list()
- if(missing(futurequotes)){
+ if(missing(futurequotes)) {
for(k in names(MarkitData[2:7])) {
v <- MarkitData[[k]]
if(is.na(v)) {
@@ -35,8 +35,8 @@ buildMarkitYC <- function(MarkitData, currency=c("USD", "EUR"), futurequotes){
}
deposits[[paste0("d", tolower(k))]] <- v
}
- }else{
- for(i in seq_along(futurequotes)){
+ } else {
+ for(i in seq_along(futurequotes)) {
futures[[paste0("fut",i)]] <- futurequotes[i]
}
## get last imm date
@@ -76,17 +76,17 @@ exportYC <- function(tradedate=Sys.Date(), currency=c("USD", "EUR"), useFutures
settings$EvaluationDate <- tradedate
legparams <- switch(currency,
USD = list(fixFreq="Semiannual",
- floatFreq="Quarterly",
- dayCounter="Thirty360"),
+ floatFreq="Quarterly",
+ dayCounter="Thirty360"),
EUR = list(fixFreq="Annual",
- floatFreq="Semiannual",
- dayCounter="Thirty360"))
+ floatFreq="Semiannual",
+ dayCounter="Thirty360"))
cal <- Calendar$new("WeekendsOnly")
dc <- DayCounter$new("Actual365Fixed")
- if(exists("futurequotes")){
+ if(exists("futurequotes")) {
tsQuotes <- buildMarkitYC(MarkitData, currency, futurequotes[,2])
- }else{
+ } else {
tsQuotes <- buildMarkitYC(MarkitData, currency)
}
YC <<- YieldTermStructure$new("discount", "loglinear", 0L, cal,
diff --git a/python/yieldcurve.py b/python/yieldcurve.py
index 79935991..c02bb054 100644
--- a/python/yieldcurve.py
+++ b/python/yieldcurve.py
@@ -148,7 +148,7 @@ def roll_yc(yc, forward_date):
dfs = np.array([yc.discount_factor(d, forward_date) for d in dates])
return YieldCurve.from_discount_factors(forward_date, dates, dfs, 'ACT/365F')
-def YC(helpers = None, currency="USD", MarkitData=None, evaluation_date=None):
+def YC(helpers=None, currency="USD", MarkitData=None, evaluation_date=None):
if helpers is None:
helpers = rate_helpers(currency, MarkitData, evaluation_date)
calendar = WeekendsOnly()