R में बॉन्ड वैल्यूएशन और विश्लेषण
Clifford Ang
Senior Vice President, Compass Lexecon
bondprc() फंक्शन बनाएँगेp = par valuer = coupon ratettm = time to maturityy = yieldcf <- c(rep(p * r, ttm - 1), p * (1 + r))
rep(x, y) - x के मान को y बार दोहराता हैx = p * r = coupon paymenty = ttm - 1 = bond की maturity तक का समय, एक साल कमp * (1 + r) = principal + अंतिम coupon paymentcf <- data.frame(cf)
cf$t <- as.numeric(rownames(cf))
cf वेक्टर के rownames() 1, 2, 3, 4 होते हैं, bond के ttm तकas.numeric() चाहिएcf$pv_factor <- 1 / (1 + y)^cf$t
cf$pv <- cf$cf * cf$pv_factor
sum(cf$pv)
bondprc() फंक्शन बनाएँp, r, ttm, और ybondprc <- function(p, r, ttm, y){
cf <- c(rep(p * r, ttm - 1), p * (1 + r))
cf <- data.frame(cf)
cf$t <- as.numeric(rownames(cf))
cf$pv_factor <- 1 / (1 + y)^cf$t
cf$pv <- cf$cf * cf$pv_factor
sum(cf$pv)
}
R में बॉन्ड वैल्यूएशन और विश्लेषण