aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--R/calibration.R8
-rw-r--r--R/tranche_functions.R10
-rw-r--r--python/analytics/tranche_functions.py2
3 files changed, 10 insertions, 10 deletions
diff --git a/R/calibration.R b/R/calibration.R
index 11f98c24..68d10573 100644
--- a/R/calibration.R
+++ b/R/calibration.R
@@ -112,14 +112,14 @@ set.tranchedata <- function(index, tradedate){
temp$trancherunningmid[4] <- coupon
}
if(index$type =="EU") {
- if(index$series>=21){
+ if(index$series >= 21) {
coupon <- 100
temp$trancheupfrontmid[3] <- 100 * ( 1 - snacpv(index$cs, temp$trancherunningmid[3]*1e-4,
coupon*1e-4, 0, 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,
@@ -168,8 +168,8 @@ build.skew <- function(index, type="bottomup"){
spread=index$tranches$running[j], complement=FALSE)$minimum
rhovec[j+1] <- rho
}
- }else if(type=="topdown"){
- for(j in length(dK):2){
+ } else if(type == "topdown") {
+ for(j in length(dK):2) {
tranchepv <- BCtranche.legs(index, index$K[j+1], rhovec[j+1], complement=TRUE)
q <- index$tranche.quotes[j] * dK[j] -
tranchepv$pl - tranchepv$cl * index$tranches$running[j]
diff --git a/R/tranche_functions.R b/R/tranche_functions.R
index 99709832..7a89a570 100644
--- a/R/tranche_functions.R
+++ b/R/tranche_functions.R
@@ -119,16 +119,16 @@ adjust.attachments <- function(K, losstodate, factor){
BCtranche.legs <- function(index, K, rho, complement=FALSE){
## computes the protection leg and couponleg of a 0-K tranche
## if complement==TRUE, computes the protection leg and coupon leg of a K-1 tranche
- if((K==0 && !complement) || (K==1 && complement)){
+ if((K==0 && !complement) || (K==1 && complement)) {
return(list(cl=0, pl=0))
- }else if((K==1 && !complement) || (K==0 && complement)){
+ }else if((K==1 && !complement) || (K==0 && complement)) {
return(BCindex.pv(index))
- }else{
+ }else {
dist <- BClossdistC(index$defaultprob, index$issuerweights, index$recov, rho, index$Z, index$w, index$N)
- if(complement){
+ if(complement) {
return(list(cl=tranche.cl(dist$L, dist$R, index$cs, K, 1),
pl=tranche.pl(dist$L, index$cs, K, 1)))
- }else{
+ } else {
return(list(cl=tranche.cl(dist$L, dist$R, index$cs, 0, K),
pl=tranche.pl(dist$L, index$cs, 0, K)))
}
diff --git a/python/analytics/tranche_functions.py b/python/analytics/tranche_functions.py
index 499bbc7e..40ea259d 100644
--- a/python/analytics/tranche_functions.py
+++ b/python/analytics/tranche_functions.py
@@ -258,7 +258,7 @@ def trancheloss(L, K1, K2):
def trancherecov(R, K1, K2):
return np.maximum(R - 1 + K2, 0) - np.maximum(R - 1 + K1, 0)
-def tranche_cl(L, R, cs, K1, K2, scaled = False):
+def tranche_cl(L, R, cs, K1, K2, scaled=False):
if(K1 == K2):
return 0
else: