DiscountCurve(RQuantLib)
DiscountCurve()所属R语言包:RQuantLib
Returns the discount curve (with zero rates and forwards) given times
返回折现曲线(零利率和远期)给定的时间
译者:生物统计家园网 机器人LoveR
描述----------Description----------
DiscountCurve constructs the spot term structure of interest rates based on input market data including the settlement date, deposit rates, futures prices, FRA rates, or swap rates, in various combinations. It returns the corresponding discount factors, zero rates, and forward rates for a vector of times that is specified as input.
DiscountCurve构造即期利率期限结构利率的基础上投入市场数据,包括结算日,存款利率,期货价格,FRA率,或掉期利率,在不同的组合。它会返回相应的折扣因素,零利率和远期利率的矢量次被指定为输入。
用法----------Usage----------
DiscountCurve(params, tsQuotes, times)
参数----------Arguments----------
参数:params
A list specifying the tradeDate (month/day/year), settleDate, forward rate time span dt, and two curve construction options: interpWhat (with possible values discount, forward, and zero) and interpHow (with possible values linear, loglinear, and spline). spline here means cubic spline interpolation of the interpWhat value.
列表,指定tradeDate(月/日/年),settleDate,远期汇率的时间跨度dt,两条曲线施工方案:interpWhat(可能的值discount,forward和zero)interpHow(可能的值linear,loglinear和spline)。 spline在这里是指interpWhat这个值的三次样条插值。
参数:tsQuotes
Market quotes used to construct the spot term structure of interest rates. Must be a list of name/value pairs, where the currently recognized names are: <table summary="Rd table"> <tr> <td align="left"> flat </td><td align="left"> rate for a flat yield curve</td> </tr> <tr> <td align="left"> d1w </td><td align="left"> 1-week deposit rate</td> </tr> <tr> <td align="left"> d1m </td><td align="left"> 1-month deposit rate</td> </tr> <tr> <td align="left"> d3m </td><td align="left"> 3-month deposit rate</td> </tr> <tr> <td align="left"> d6m </td><td align="left"> 6-month deposit rate</td> </tr> <tr> <td align="left"> d9m </td><td align="left"> 9-month deposit rate</td> </tr> <tr> <td align="left"> d1y </td><td align="left"> 1-year deposit rate</td> </tr> <tr> <td align="left"> s2y </td><td align="left"> 2-year swap rate</td> </tr> <tr> <td align="left"> s3y </td><td align="left"> 3-year swap rate</td> </tr> <tr> <td align="left"> s5y </td><td align="left"> 5-year swap rate</td> </tr> <tr> <td align="left"> s10y </td><td align="left"> 10-year swap rate</td> </tr> <tr> <td align="left"> s15y </td><td align="left"> 15-year swap rate</td> </tr> <tr> <td align="left"> s20y </td><td align="left"> 20-year swap rate</td> </tr> <tr> <td align="left"> s30y </td><td align="left"> 30-year swap rate</td> </tr> <tr> <td align="left"> fut1–fut8 </td><td align="left"> 3-month futures contracts</td> </tr> <tr> <td align="left"> fra3x6 </td><td align="left"> 3x6 FRA</td> </tr> <tr> <td align="left"> fra6x9 </td><td align="left"> 6x9 FRA</td> </tr> <tr> <td align="left"> fra6x12</td><td align="left"> 6x12 FRA </td> </tr> </table> Here rates are expected as fractions (so 5% means .05). If flat is specified it must be the first and only item in the list. The eight futures correspond to the first eight IMM dates. The maturity dates of the instruments specified need not be ordered, but they must be distinct.
市场报价用于构造即期利率期限结构。必须是一个列表的名称/值对,目前公认的名称是:<table summary="Rd table"> <TR> <td ALIGN="LEFT"> flat</ TD> <TD对齐= “左”的速度平坦的收益曲线</ TD> </ TR> <TR> <td ALIGN="LEFT"> d1w</ TD> <TD ALIGN="LEFT"> 1周存款率</ TD> </ TR> <TR> <td ALIGN="LEFT">d1m </ TD> <TD ALIGN="LEFT"> 1个月存款利率</ TD> </ TR> <TR> <td ALIGN="LEFT"> d3m </ TD> <TD ALIGN="LEFT"> 3个月存款利率</ TD> </ TR> <TR> TD对齐=“左边“>d6m </ TD> <TD ALIGN="LEFT"> 6个月存款利率</ TD> </ TR> <TR> <td ALIGN="LEFT">d9m</ TD> <TD ALIGN="LEFT"> 9个月的存款利率</ TD> </ TR> <TR> <td ALIGN="LEFT">d1y </ TD> <TD对齐=“左边” > 1年期存款利率</ TD> </ TR> <TR> <td ALIGN="LEFT">s2y </ TD> <TD ALIGN="LEFT"> 2年期掉期利率</ TD > </ TR> <TR> <td ALIGN="LEFT">s3y </ TD> <TD ALIGN="LEFT"> 3年期掉期利率</ TD> </ TR> <TR> < TD>s5y </ TD> <TD ALIGN="LEFT"> 5年期掉期利率</ TD> </ TR> <TR> <td ALIGN="LEFT">对齐=“左”s10y </ TD> <TD ALIGN="LEFT"> 10年期掉期利率</ TD> </ TR> <TR> <td ALIGN="LEFT"> s15y</ TD> <TD对齐=“左”的15年期掉期率</ TD> </ TR> <TR> <td ALIGN="LEFT">s20y </ TD> <TD ALIGN="LEFT"> 20年交换率</ TD> </ TR> <TR> <td ALIGN="LEFT">s30y </ TD> <TD ALIGN="LEFT"> 30年期掉期利率</ TD> </ TR文章<td ALIGN="LEFT">fut1 - fut8 </ TD> <TD ALIGN="LEFT"> 3个月期货合约</ TD> </ TR> < TR> <td ALIGN="LEFT">fra3x6 </ TD> <TD ALIGN="LEFT"> 3X6 FRA </ TD> </ TR> <TR> <td ALIGN="LEFT"> fra6x9 </ TD> <TD ALIGN="LEFT">×9 FRA </ TD> </ TR> <TR> <td ALIGN="LEFT">fra6x12 </ TD> <TD对齐=“左边的“6X12 FRA </ TD> </ TR> </ TABLE>下面率预计为分数(5%意味着0.05)。如果flat指定,它必须是列表中的第一个也是唯一的项目。的八个的期货对应于第一八IMM日期。指定的工具的到期日,不必进行排序,但他们必须是不同的。
参数:times
A vector of times at which to return the discount factors, forward rates, and zero rates. Times must be specified such that the largest time plus dt does not exceed the longest maturity of the instruments used for calibration (no extrapolation).
在返回的贴现因子,远期利率,零利率时代的矢量。时报必须指定,使得最大的时间加上dt不超过用于校准所用的工具(没有外推)的最长的到期日。
Details
详细信息----------Details----------
This function is based on QuantLib Version 0.3.10. It introduces support for fixed-income instruments in RQuantLib.
此功能是基于QuantLib版本0.3.10。它引入了固定收益工具的支持RQuantLib。
Forward rates and zero rates are computed assuming continuous compounding, so the forward rate f over the period from t1 to t2 is determined by the relation
远期利率和零利率假设连续复利计算的,所以远期汇率f在此期间从t1到t2决定的关系
Curve construction can be a delicate problem and the algorithms may fail for some input data sets and/or some combinations of the values for interpWhat and interpHow. Fortunately, the C++ exception mechanism seems to work well with the R interface, and QuantLib exceptions are propagated back to the R user, usually with a message that indicates what went wrong. (The first part of the message contains technical information about the precise location of the problem in the QuantLib code. Scroll to the end to find information that is meaningful to the R user.)
曲线的构成可以是一个棘手的问题,一些输入数据集和/或为interpWhat和interpHow的值的一些组合的算法可能会失败。幸运的是,C + +异常处理机制似乎运作良好的R接口,QuantLib例外传回的R用户,通常有一条消息,指出什么地方出了错。 (消息的第一部分包含技术信息的问题,在QuantLib代码的确切位置。滚动到结束是有意义的R用户查找信息。)
值----------Value----------
DiscountCurve returns a list containing: <table summary="R valueblock"> <tr valign="top"><td>times</td> <td> Vector of input times</td></tr> <tr valign="top"><td>discounts</td> <td> Corresponding discount factors</td></tr> <tr valign="top"><td>forwards</td> <td> Corresponding forward rates with time span dt</td></tr> <tr valign="top"><td>zerorates</td> <td> Corresponding zero coupon rates</td></tr> <tr valign="top"><td>flatQuotes</td> <td> True if a flat quote was used, False otherwise</td></tr> <tr valign="top"><td>params</td> <td> The input parameter list</td></tr> </table>
DiscountCurve返回一个列表,其中包含:<table summary="R valueblock"> <tr valign="top"> <TD>times </ TD> <TD>向量的输入次数</ TD> </ TR> <tr valign="top"> <TD> discounts </ TD> <TD>相应的折扣因素</ TD> </ TR> <tr valign="top"> <TD> forwards </ TD> <TD>通讯远期汇率与时间跨度dt</ TD> </ TR> <tr valign="top"> <TD> zerorates </ TD> <TD>相应的零票息率</ TD> </ TR> <tr valign="top"> <TD>flatQuotes </ TD> <TD> True,如果一个单位的报价,否则返回False </ TD> </ TR> <tr valign="top"> <TD>params </ TD> <TD>的输入参数列表</ TD> </ TR> </ TABLE>
(作者)----------Author(s)----------
Dominick Samperi
参考文献----------References----------
Brigo, D. and Mercurio, F. (2001) Interest Rate Models: Theory and Practice, Springer-Verlag, New York.
For information about <code>QuantLib</code> see http://quantlib.org.
For information about <code>RQuantLib</code> see http://dirk.eddelbuettel.com/code/rquantlib.html.
参见----------See Also----------
BermudanSwaption
BermudanSwaption
实例----------Examples----------
savepar <- par(mfrow=c(3,3), mar=c(4,4,2,0.5))
## This data is taken from sample code shipped with QuantLib 0.9.7[#此数据是从QuantLib 0.9.7附带的示例代码]
## from the file Examples/Swap/swapvaluation[#从文件的例子/交换/ swapvaluation的]
params <- list(tradeDate=as.Date('2004-09-20'),
settleDate=as.Date('2004-09-22'),
dt=.25,
interpWhat="discount",
interpHow="loglinear")
setEvaluationDate(as.Date("2004-11-22"))
## We get numerical issue for the spline interpolation if we add[#我们得到的数值问题,如果我们添加的样条插值]
## any on of these three extra futures -- the original example[#这三个额外期货 - 最初的例子]
## creates different curves based on different deposit, fra, futures[#创建不同的曲线,根据不同的押金,法国,期货]
## and swap data[#和交换数据]
tsQuotes <- list(d1w = 0.0382,
d1m = 0.0372,
d3m = 0.0363,
d6m = 0.0353,
d9m = 0.0348,
d1y = 0.0345,
# fut1=96.2875,[FUT1 = 96.2875,]
# fut2=96.7875,[FUT2 = 96.7875,]
# fut3=96.9875,[FUT3 = 96.9875,]
# fut4=96.6875,[FUT4 = 96.6875,]
# fut5=96.4875,[fut5 = 96.4875,]
# fut6=96.3875,[fut6 = 96.3875,]
# fut7=96.2875,[FUT7 = 96.2875,]
# fut8=96.0875,[FUT8 = 96.0875,]
s2y = 0.037125,
s3y = 0.0398,
s5y = 0.0443,
s10y = 0.05165,
s15y = 0.055175)
times <- seq(0,10,.1)
# Loglinear interpolation of discount factors[对数线性插值的折扣因素]
curves <- DiscountCurve(params, tsQuotes, times)
plot(curves,setpar=FALSE)
# Linear interpolation of discount factors[线性插值折扣因素]
params$interpHow="linear"
curves <- DiscountCurve(params, tsQuotes, times)
plot(curves,setpar=FALSE)
# Spline interpolation of discount factors[样条插值的贴现因子]
params$interpHow="spline"
## NB Commented out for numerical issues under current parameterisation[#NB注释掉数值的问题,根据目前的参数化]
#curves <- DiscountCurve(params, tsQuotes, times)[曲线< - DiscountCurve(PARAMS,tsQuotes,时间)]
plot(curves,setpar=FALSE)
par(savepar)
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|