简体   繁体   English

使用QuantLib在Python中进行香草利率掉期评估

[英]Vanilla Interest Rate Swap Valuation in Python using QuantLib

I am valuing a Vanilla Interest Rate Swap as at 31 January 2017 (Valuation Date) but the effective date of the Vanilla Interest Rate Swap is 31 December 2016 (Start Date). 我对截至2017年1月31日(评估日期)的香草利率掉期进行评估,但香草利率掉期的生效日期为2016年12月31日(开始日期)。 Firstly, I would like to know how I can adjust for my valuation date and start date in the code below; 首先,我想知道如何在下面的代码中调整我的估值日期和开始日期;

import QuantLib as ql
startDate = ql.Date(31,12,2016)
valuationDate = ql.Date(31,1,2017)
maturityDate = ql.Date(30,9,2019)
calendar = ql.SouthAfrica()
bussiness_convention = ql.Unadjusted
swapT = ql.VanillaSwap.Payer
nominal = 144000000
fixedLegTenor = ql.Period(3, ql.Months)
fixedSchedule = ql.Schedule(startDate, maturityDate, 
                             fixedLegTenor, calendar,
                             ql.ModifiedFollowing, ql.ModifiedFollowing,
                             ql.DateGeneration.Forward, False)
fixedRate = 0.077
fixedLegDayCount = ql.Actual365Fixed()
spread = 0
floatLegTenor = ql.Period(3, ql.Months)
floatSchedule = ql.Schedule(startDate, maturityDate, 
                              floatLegTenor, calendar,
                              ql.ModifiedFollowing, ql.ModifiedFollowing,
                              ql.DateGeneration.Forward, False)
floatLegDayCount = ql.Actual365Fixed()
discountDates = [ql.Date(31,1,2017),ql.Date(7,2,2017),ql.Date(28,2,2017),
                ql.Date(31,3,2017),ql.Date(28,4,2017),ql.Date(31,7,2017),
                ql.Date(31,10,2017),ql.Date(31,1,2018),ql.Date(31,1,2019),
                ql.Date(31,1,2020),ql.Date(29,1,2021),ql.Date(31,1,2022),
                ql.Date(31,1,2023),ql.Date(31,1,2024),ql.Date(31,1,2025),
                ql.Date(30,1,2026),ql.Date(29,1,2027),ql.Date(31,1,2029),
                ql.Date(30,1,2032),ql.Date(30,1,2037),ql.Date(31,1,2042),
                ql.Date(31,1,2047)]
discountRates = [1,0.9986796,0.99457,0.9884423,0.9827433,0.9620352,0.9420467,0.9218714,
                 0.863127,0.7993626,0.7384982,0.6796581,0.6244735,0.5722537,0.5236629,
                 0.4779477,0.4362076,0.3619845,0.2795902,0.1886847,0.1352048,0.1062697]

jibarTermStructure = ql.RelinkableYieldTermStructureHandle()
jibarIndex = ql.Jibar(ql.Period(3,ql.Months), jibarTermStructure)
jibarIndex.addFixings(dtes, fixings)
discountCurve = ql.DiscountCurve(discountDates,discountRates,ql.Actual365Fixed())
swapEngine = ql.DiscountingSwapEngine(discountCurve)
interestRateSwap = ql.VanillaSwap(swapT, nominal, fixedSchedule, 
               fixedRate,fixedLegDayCount,jibarIndex,spread,floatSchedule,
               floatLegDayCount,swapEngine,floatSchedule.convention)

Secondly, I would like to know how best I can incorporate jibarIndex in interestRateSwap =ql.VanillaSwap() or else how can I use my Discount Factors and Discount Dates to calculate the value of the Interest Rate Swap 其次,我想知道如何最好地将jibarIndex合并到interestRateSwap =ql.VanillaSwap() ,否则我该如何使用我的折扣因子和折扣日期来计算利率掉期的价值

ql.Settings.instance().setEvaluationDate(today) ql.Settings.instance()。setEvaluationDate(今天)

sets the evaluation date or valuation date. 设置评估日期或评估日期。

I don't see a problem with your jibarIndex index in the VanillaSwap code. 我在VanillaSwap代码jibarIndex不到您的jibarIndex索引有问题。 You've given the object to QuantLib, the library will use it as a forward curve to price your floating leg and thus the swap. 您已将对象提供给QuantLib,库将使用它作为前向曲线来为浮动腿定价,从而为交换定价。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM