Skip to content

中国 Repo 7D 互换的例子

来源:https://uqer.io/community/share/55c177cbf9f06c915418c641

下面的例子给出在量化实验室中如何为一个Repo 7D互换定价的例子

  • swapType:互换类型,Payer代表付固定端利息,收浮动端利息;
  • nominal:互换面值
  • startDate:互换生效日
  • swapTenor:互换期限
  • paymentTenor:付息周期
  • fixedRate:固定端利息
  • rateSpread:浮动端息差
  • repoIndex:浮动端指数

这里我们使用一条平坦的收益率曲线作为远期曲线:

forwardingCurve = FlatForward(Date(2015, 8, 4), 0.05, 'Actual/360') 
from CAL.PyCAL import *

SetEvaluationDate = Date(2015, 8, 4)

swapType = SwapLegType.Payer
nominal = 100000000.
startDate = Date(2015, 8, 7)
swapTenor = Period('10Y')
paymentTenor = Period('3M')
fixedRate = 0.055
rateSpread = 0.0
forwardingCurve = FlatForward(Date(2015, 8, 4), 0.05, 'Actual/360')
repoIndex = RepoChina('7D', yieldCurve)

组装成我们需要的RepoCompoundingSwap

swap = RepoCompoundingSwap(swapType=swapType,
                          nominal=nominal,
                          startDate=startDate,
                          swapTenor=swapTenor,
                          paymentTenor=paymentTenor,
                          fixedRate=fixedRate,
                          rateSpread=rateSpread,
                          repoIndex=repoIndex)

继续的,为了计算swap的现值,我们需要定义DiscountingSwapEngine对象,这里我们同样使用一条平坦的收益率曲线:

discountingCurve = FlatForward(Date(2015, 8, 4), 0.065, 'Actual/360')
pricingEngine = DiscountingSwapEngine(discountingCurve)

swap.setPricingEngine(pricingEngine)

print("NPV: {0:.4f}".format(swap.NPV()))
print("Fair rate: {0:.4f}".format(swap.fairRate()))

NPV: -2282521.8872
Fair rate: 0.0519

下面的是swap每条leg的具体现金流分析:在legAnalysis接受的参数中,0代表固定端,1代表浮动端。

swap.legAnalysis(0).tail()
AMOUNT NOMINAL ACCRUAL_START_DATE ACCRUAL_END_DATE ACCRUAL_DAYS INDEX FIXING_DAYS FIXING_DATES INDEX_FIXING DAY_COUNTER ACCRUAL_PERIOD EFFECTIVE_RATE
PAYMENT_DATE
2024-08-07 1386301 1e+08 2024-05-07 2024-08-07 92 #NA #NA #NA #NA Actual/365 (Fixed) 0.2520548 0.055
2024-11-07 1386301 1e+08 2024-08-07 2024-11-07 92 #NA #NA #NA #NA Actual/365 (Fixed) 0.2520548 0.055
2025-02-07 1386301 1e+08 2024-11-07 2025-02-07 92 #NA #NA #NA #NA Actual/365 (Fixed) 0.2520548 0.055
2025-05-07 1341096 1e+08 2025-02-07 2025-05-07 89 #NA #NA #NA #NA Actual/365 (Fixed) 0.2438356 0.055
2025-08-07 1386301 1e+08 2025-05-07 2025-08-07 92 #NA #NA #NA #NA Actual/365 (Fixed) 0.2520548 0.055
swap.legAnalysis(1).tail()
AMOUNT NOMINAL ACCRUAL_START_DATE ACCRUAL_END_DATE ACCRUAL_DAYS INDEX FIXING_DAYS FIXING_DATES INDEX_FIXING DAY_COUNTER ACCRUAL_PERIOD EFFECTIVE_RATE
PAYMENT_DATE
2024-08-07 1306927 1e+08 2024-05-07 2024-08-07 92 repoChina1W Actual/365 (Fixed) 1 2024-05-06 0.05072614 Actual/360 0.2555556 0.05114062
2024-11-07 1306927 1e+08 2024-08-07 2024-11-07 92 repoChina1W Actual/365 (Fixed) 1 2024-08-06 0.05072614 Actual/360 0.2555556 0.05114062
2025-02-07 1309570 1e+08 2024-11-07 2025-02-07 92 repoChina1W Actual/365 (Fixed) 1 2024-11-06 0.05073319 Actual/360 0.2555556 0.05124405
2025-05-07 1265808 1e+08 2025-02-07 2025-05-07 89 repoChina1W Actual/365 (Fixed) 1 2025-02-06 0.05073319 Actual/360 0.2472222 0.05120122
2025-08-07 1306927 1e+08 2025-05-07 2025-08-07 92 repoChina1W Actual/365 (Fixed) 1 2025-05-06 0.05072614 Actual/360 0.2555556 0.05114062


回到顶部