Skip to content
Prev 174382 / 398506 Next

How to use termstrc functions?

There is probably a greater density of potential users on the SIG- 
Finance mailing list.

I still think you attribute special powers to that function that the  
authors never build into it. It does not predict the future. It  
doesn't even simulate the future. It just reformats into a matrix the  
data it is given in the form of a list. It does no calculations:

 > create_cashflows_matrix
function (group, include_price = FALSE)
{
     n_of_cf <- summary(factor(group$CASHFLOWS$ISIN, levels = group 
$ISIN))
     n_of_bonds <- length(n_of_cf)
     max_cf <- max(n_of_cf)
     pos_cf <- c(0, cumsum(n_of_cf))
     CASHFLOWMATRIX <- mapply(function(i) c(group$CASHFLOWS 
$CF[(pos_cf[i] +
         1):pos_cf[i + 1]], rep(0, max_cf - n_of_cf[i])), 1:n_of_bonds)
     if (include_price == TRUE) {
         CASHFLOWMATRIX <- rbind(-(group[["PRICE"]] +  
group[["ACCRUED"]]),
             CASHFLOWMATRIX)
     }
     colnames(CASHFLOWMATRIX) <- group$ISIN
     CASHFLOWMATRIX
}