# commented-out as it runs longer than CRAN likes
if (FALSE) {
#this follow an example in test-suite/convertiblebond.cpp
params <- list(tradeDate=Sys.Date()-2,
settleDate=Sys.Date(),
dt=.25,
interpWhat="discount",
interpHow="loglinear")
dividendYield <- DiscountCurve(params, list(flat=0.02))
riskFreeRate <- DiscountCurve(params, list(flat=0.05))
dividendSchedule <- data.frame(Type=character(0), Amount=numeric(0),
Rate = numeric(0), Date = as.Date(character(0)))
callabilitySchedule <- data.frame(Price = numeric(0), Type=character(0),
Date = as.Date(character(0)))
process <- list(underlying=50, divYield = dividendYield,
rff = riskFreeRate, volatility=0.15)
today <- Sys.Date()
bondparams <- list(exercise="am", faceAmount=100,
divSch = dividendSchedule,
callSch = callabilitySchedule,
redemption=100,
creditSpread=0.005,
conversionRatio = 0.0000000001,
issueDate=as.Date(today+2),
maturityDate=as.Date(today+3650))
dateparams <- list(settlementDays=3,
dayCounter="ActualActual",
period = "Semiannual", calendar = "UnitedStates/GovernmentBond",
businessDayConvention="Following")
lengths <- c(2,4,6,8,10,12,14,16,18,20,22,24,26,28,30)
coupons <- c( 0.0200, 0.0225, 0.0250, 0.0275, 0.0300,
0.0325, 0.0350, 0.0375, 0.0400, 0.0425,
0.0450, 0.0475, 0.0500, 0.0525, 0.0550 )
marketQuotes <- rep(100, length(lengths))
curvedateparams <- list(settlementDays=0, period="Annual",
dayCounter="ActualActual",
businessDayConvention ="Unadjusted")
curveparams <- list(method="ExponentialSplinesFitting",
origDate = Sys.Date())
curve <- FittedBondCurve(curveparams, lengths, coupons, marketQuotes, curvedateparams)
iborindex <- list(type="USDLibor", length=6,
inTermOf="Month", term=curve)
spreads <- c()
#ConvertibleFloatingCouponBond(bondparams, iborindex, spreads, process, dateparams)
#example using default values
#ConvertibleFloatingCouponBond(bondparams, iborindex,spreads, process)
dateparams <- list(settlementDays=3,
period = "Semiannual",
businessDayConvention="Unadjusted")
bondparams <- list(
creditSpread=0.005, conversionRatio = 0.0000000001,
issueDate=as.Date(today+2),
maturityDate=as.Date(today+3650))
#ConvertibleFloatingCouponBond(bondparams, iborindex,
#spreads, process, dateparams)
#this follow an example in test-suite/convertiblebond.cpp
#for ConvertibleFixedCouponBond
#set up arguments to build a pricing engine.
params <- list(tradeDate=Sys.Date()-2,
settleDate=Sys.Date(),
dt=.25,
interpWhat="discount",
interpHow="loglinear")
times <- seq(0,10,.1)
dividendYield <- DiscountCurve(params, list(flat=0.02), times)
riskFreeRate <- DiscountCurve(params, list(flat=0.05), times)
dividendSchedule <- data.frame(Type=character(0), Amount=numeric(0),
Rate = numeric(0), Date = as.Date(character(0)))
callabilitySchedule <- data.frame(Price = numeric(0), Type=character(0),
Date = as.Date(character(0)))
process <- list(underlying=50, divYield = dividendYield,
rff = riskFreeRate, volatility=0.15)
today <- Sys.Date()
bondparams <- list(exercise="am", faceAmount=100, divSch = dividendSchedule,
callSch = callabilitySchedule, redemption=100,
creditSpread=0.005, conversionRatio = 0.0000000001,
issueDate=as.Date(today+2),
maturityDate=as.Date(today+3650))
dateparams <- list(settlementDays=3,
dayCounter="Actual360",
period = "Once", calendar = "UnitedStates/GovernmentBond",
businessDayConvention="Following"
)
coupon <- c(0.05)
ConvertibleFixedCouponBond(bondparams, coupon, process, dateparams)
#example with default value
ConvertibleFixedCouponBond(bondparams, coupon, process)
dateparams <- list(settlementDays=3,
dayCounter="Actual360")
ConvertibleFixedCouponBond(bondparams, coupon, process, dateparams)
bondparams <- list(creditSpread=0.005, conversionRatio = 0.0000000001,
issueDate=as.Date(today+2),
maturityDate=as.Date(today+3650))
ConvertibleFixedCouponBond(bondparams, coupon, process, dateparams)
#this follow an example in test-suite/convertiblebond.cpp
params <- list(tradeDate=Sys.Date()-2,
settleDate=Sys.Date(),
dt=.25,
interpWhat="discount",
interpHow="loglinear")
times <- seq(0,10,.1)
dividendYield <- DiscountCurve(params, list(flat=0.02), times)
riskFreeRate <- DiscountCurve(params, list(flat=0.05), times)
dividendSchedule <- data.frame(Type=character(0), Amount=numeric(0),
Rate = numeric(0), Date = as.Date(character(0)))
callabilitySchedule <- data.frame(Price = numeric(0), Type=character(0),
Date = as.Date(character(0)))
process <- list(underlying=50, divYield = dividendYield,
rff = riskFreeRate, volatility=0.15)
today <- Sys.Date()
bondparams <- list(exercise="am", faceAmount=100, divSch = dividendSchedule,
callSch = callabilitySchedule, redemption=100,
creditSpread=0.005, conversionRatio = 0.0000000001,
issueDate=as.Date(today+2),
maturityDate=as.Date(today+3650))
dateparams <- list(settlementDays=3,
dayCounter="Actual360",
period = "Once", calendar = "UnitedStates/GovernmentBond",
businessDayConvention="Following"
)
ConvertibleZeroCouponBond(bondparams, process, dateparams)
#example with default values
ConvertibleZeroCouponBond(bondparams, process)
bondparams <- list(creditSpread=0.005,
conversionRatio=0.0000000001,
issueDate=as.Date(today+2),
maturityDate=as.Date(today+3650))
dateparams <- list(settlementDays=3, dayCounter='Actual360')
ConvertibleZeroCouponBond(bondparams, process, dateparams)
ConvertibleZeroCouponBond(bondparams, process)
}
Run the code above in your browser using DataLab