2017-02-28 1 views
0

나는 바닐라 금리 스왑을 2017 년 1 월 31 일 (평가 일)과 같이 평가하지만 바닐라 금리 스왑의 발효 일은 2016 년 12 월 31 일 (시작일)입니다. 첫째, 아래 코드에서 어떻게 평가 일과 시작일을 조정할 수 있는지 알고 싶습니다.QuantLib을 사용하는 Python의 바닐라 금리 스왑 평가

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) 

둘째, 나는 내 할인 요인을 사용하는 방법을 다른 interestRateSwap =ql.VanillaSwap()jibarIndex을 통합하거나하는 방법을 가장 잘 알고 싶습니다 및 할인은 금리 스왑

답변

1

QL의 값을 계산하는 날짜 .Settings.instance(). setEvaluationDate (오늘)

은 평가 날짜 또는 평가 날짜를 설정합니다.

바닐라 스왑 코드의 jibarIndex 색인에 문제가 표시되지 않습니다. 객체를 QuantLib에 주었을 때, 라이브러리는이 객체를 앞으로의 커브로 사용하여 부동 다리와 가격을 매길 수 있습니다.

관련 문제