irSingleCurrencyCurveBuilder
语法
irSingleCurrencyCurveBuilder(referenceDate, currency,
instNames, instTypes, terms, quotes, dayCountConvention, [discountCurve],
[compounding='Continuous'], [frequency='Annual'], [curveName])
详情
构建单货币利率互换收益率曲线。目前仅支持 CNY_FR_007 和 CNY_SHIBOR_3M 两条曲线构建。
返回值:MKTDATA 类型对象。
参数
referenceDate DATE 类型标量,收益率曲线的参考日期。
currency STRING 类型标量,表示曲线定义的货币,目前仅支持 "CNY"。
instNames STRING 类型向量,表示金融工具名称。
instTypes STRING 类型向量,表示金融工具类型。暂时仅支持 "Deposit" 和 "IrVanillaSwap"。
terms DURATION 类型向量,表示合约剩余期限,例如 "1M"。
quotes 数值向量,表示构建曲线所需的市场报价。
dayCountConvention STRING 类型标量,表示计息日数规则,可选值为:
-
"Actual360": 实际/360
-
"Actual365": 实际/365
-
"ActualActualISMA": 实际/实际,遵循 ISMA(International Securities Market Association,国际证券市场协会)规则
-
"ActualActualISDA":实际/实际,遵循 ISDA(International Swaps and Derivatives Association,国际掉期及衍生工具协会)规则。
discountCurve 可选参数,MKTDATA 类型对象(IrYieldCurve),表示贴现曲线。当构建目标曲线的市场工具在自身定价时需要外部贴现曲线,则通过该参数指定。若不传入,则默认不使用外部贴现曲线。曲线所需包含的关键字段见曲线字段要求。
compounding 可选参数,STRING 类型标量,表示利率复利方式。可选值为:
-
"Compounded":离散复利。
-
"Simple":单利。
-
"Continuous":默认值,连续复利。
frequency 可选参数,STRING 类型标量,表示计算贴现因子的频率。可选值为:
-
"NoFrequency":无计息频率
-
"Annual":默认值,每年付息一次
-
"Semiannual":每半年付息一次
-
"EveryFourthMonth":每四个月付息一次
-
"Quarterly":每季度付息一次
-
"BiMonthly":每两月付息一次
-
"Monthly":每月付息一次
-
"EveryFourthWeek":每四周付息一次
-
"BiWeekly":每两周付息一次
-
"Weekly":每周付息一次
-
"Daily":每日付息一次
-
"Other":其他计息频率
curveName 可选参数,STRING 类型标量,表示生成的曲线名称,默认为空。
例子
例1. 构建一条以人民币计价、参考 FR007 浮动利率的利率互换曲线。
referenceDate = 2021.05.26
currency = "CNY"
terms = [7d, 1M, 3M, 6M, 9M, 1y, 2y, 3y, 4y, 5y, 7y, 10y]
instNames = take("CNY_FR_007", size(terms))
instNames[0] = "FR_007"
instTypes = take("IrVanillaSwap", size(terms))
instTypes[0] = "Deposit"
quotes = [2.3500, 2.3396, 2.3125, 2.3613, 2.4075, 2.4513, 2.5750, 2.6763, 2.7650, 2.8463, 2.9841, 3.1350]\100
dayCountConvention = "Actual365"
curve = irSingleCurrencyCurveBuilder(referenceDate, currency, instNames, instTypes, terms, quotes, dayCountConvention, curveName="CNY_FR_007")
curveDict = extractMktData(curve)
print(curveDict)
例2. 根据短期存款和利率互换市场报价,构建人民币利率互换收益率曲线。
referenceDate = 2021.05.26
currency = "CNY"
terms = [1w, 2w, 1M, 3M, 6M, 9M, 1y, 2y, 3y, 4y, 5y, 7y, 10y]
instNames = take("CNY_SHIBOR_3M", size(terms))
instNames[0] = "SHIBOR_1W"
instNames[1] = "SHIBOR_2W"
instNames[2] = "SHIBOR_1M"
instNames[3] = "SHIBOR_3M"
instTypes = take("IrVanillaSwap", size(terms))
instTypes[0] = "Deposit"
instTypes[1] = "Deposit"
instTypes[2] = "Deposit"
instTypes[3] = "Deposit"
quotes = [2.269,
2.311,
2.405,
2.479,
2.6013,
2.7038,
2.7725,
2.9625,
3.11,
3.24,
3.3513,
3.5313,
3.7125]/100
dayCountConvention = "Actual365"
curve = irSingleCurrencyCurveBuilder(referenceDate, currency, instNames, instTypes, terms, quotes, dayCountConvention)
curveDict = extractMktData(curve)
print(curveDict)
例3. 构建一个双曲线利率互换收益率曲线(CNY_SHIBOR_3M)。
referenceDate = 2021.05.26
currency = "CNY"
curveName = "CNY_SHIBOR_3M"
discountCurve = {
"mktDataType": "Curve",
"curveType": "IrYieldCurve",
"curveName": "CNY_FR_007",
"referenceDate": referenceDate,
"currency": "CNY",
"dayCountConvention": "Actual365",
"compounding": "Continuous",
"interpMethod": "Linear",
"extrapMethod": "Flat",
"dates":[2021.06.02,2021.06.28,2021.08.27,2021.11.29,2022.02.28,2022.05.27,2023.05.29,2024.05.27,2025.05.27,2026.05.27,2028.05.29,2031.05.27],
"values": [2.3495, 2.3376, 2.3063, 2.3543, 2.4004, 2.4442, 2.5686, 2.6715, 2.7625, 2.8468, 2.9922, 3.1559] / 100.0
}
discountCurve = parseMktData(discountCurve)
terms = [1w, 2w, 1M, 3M, 6M, 9M, 1y, 2y, 3y, 4y, 5y, 7y, 10y]
instNames = take("CNY_SHIBOR_3M", size(terms))
instNames[0] = "SHIBOR_1W"
instNames[1] = "SHIBOR_2W"
instNames[2] = "SHIBOR_1M"
instNames[3] = "SHIBOR_3M"
instTypes = take("IrVanillaSwap", size(terms))
instTypes[0] = "Deposit"
instTypes[1] = "Deposit"
instTypes[2] = "Deposit"
instTypes[3] = "Deposit"
quotes = [2.269,
2.311,
2.405,
2.479,
2.6013,
2.7038,
2.7725,
2.9625,
3.11,
3.24,
3.3513,
3.5313,
3.7125]/100
dayCountConvention = "Actual365"
curve = irSingleCurrencyCurveBuilder(referenceDate, currency, instNames, instTypes, terms, quotes, dayCountConvention, discountCurve)
curveDict = extractMktData(curve)
print(curveDict)
相关函数:bondYieldCurveBuilder, extractMktData, irCrossCurrencyCurveBuilder,parseMktData
曲线字段要求
字段名 | 类型 | 描述 | 是否必填 |
---|---|---|---|
mktDataType | STRING | 固定填 "Curve" | 是 |
referenceDate | DATE | 参考日期 | 是 |
version | INT | 版本号,默认值 0 | 否 |
curveType | STRING | 固定填 "IrYieldCurve" | 是 |
dayCountConvention | STRING |
曲线的日期计数惯例,可选值为:
|
是 |
interpMethod | STRING |
内插方法,可选值为:
|
是 |
extrapMethod | STRING |
外插方法,可选值为:
|
是 |
dates | DATE 向量 | 数据点的日期 | 是 |
values | DOUBLE 向量 | 数据点的值,与 dates 中的元素一一对应 | 是 |
curveName | STRING | 曲线名称 | 否 |
currency | STRING | 货币,可选值为"CNY", "USD", "EUR", "GBP", "JPY", "HKD" | 是 |
compounding | STRING |
复利类型,可选值为:
|
是 |
settlement | DATE | 结算日,如果指定了结算日,则后续期限间隔的计算都将从 settlement 开始,而不是 referenceDate | 否 |
frequency | INTEGRAL或 STRING |
计息频率,可选值为:
|
否 |
curveModel | STRING | 曲线构建模型,目前仅支持 "Bootstrap"。 | 否 |
curveParams | DICT | 模型的参数。 | 否 |