中国 Repo 7D 互换的例子

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

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

  • swapType:互换类型,Payer代表付固定端利息,收浮动端利息;
  • nominal:互换面值
  • startDate:互换生效日
  • swapTenor:互换期限
  • paymentTenor:付息周期
  • fixedRate:固定端利息
  • rateSpread:浮动端息差
  • repoIndex:浮动端指数 这里我们使用一条平坦的收益率曲线作为远期曲线:
  1. forwardingCurve = FlatForward(Date(2015, 8, 4), 0.05, 'Actual/360')
  1. from CAL.PyCAL import *
  2. SetEvaluationDate = Date(2015, 8, 4)
  3. swapType = SwapLegType.Payer
  4. nominal = 100000000.
  5. startDate = Date(2015, 8, 7)
  6. swapTenor = Period('10Y')
  7. paymentTenor = Period('3M')
  8. fixedRate = 0.055
  9. rateSpread = 0.0
  10. forwardingCurve = FlatForward(Date(2015, 8, 4), 0.05, 'Actual/360')
  11. repoIndex = RepoChina('7D', yieldCurve)

组装成我们需要的RepoCompoundingSwap

  1. swap = RepoCompoundingSwap(swapType=swapType,
  2. nominal=nominal,
  3. startDate=startDate,
  4. swapTenor=swapTenor,
  5. paymentTenor=paymentTenor,
  6. fixedRate=fixedRate,
  7. rateSpread=rateSpread,
  8. repoIndex=repoIndex)

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

  1. discountingCurve = FlatForward(Date(2015, 8, 4), 0.065, 'Actual/360')
  2. pricingEngine = DiscountingSwapEngine(discountingCurve)
  3. swap.setPricingEngine(pricingEngine)
  4. print("NPV: {0:.4f}".format(swap.NPV()))
  5. print("Fair rate: {0:.4f}".format(swap.fairRate()))
  6. NPV: -2282521.8872
  7. Fair rate: 0.0519

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

  1. swap.legAnalysis(0).tail()
AMOUNTNOMINALACCRUAL_START_DATEACCRUAL_END_DATEACCRUAL_DAYSINDEXFIXING_DAYSFIXING_DATESINDEX_FIXINGDAY_COUNTERACCRUAL_PERIODEFFECTIVE_RATE
PAYMENT_DATE
2024-08-0713863011e+082024-05-072024-08-0792#NA#NA#NA#NAActual/365 (Fixed)0.25205480.055
2024-11-0713863011e+082024-08-072024-11-0792#NA#NA#NA#NAActual/365 (Fixed)0.25205480.055
2025-02-0713863011e+082024-11-072025-02-0792#NA#NA#NA#NAActual/365 (Fixed)0.25205480.055
2025-05-0713410961e+082025-02-072025-05-0789#NA#NA#NA#NAActual/365 (Fixed)0.24383560.055
2025-08-0713863011e+082025-05-072025-08-0792#NA#NA#NA#NAActual/365 (Fixed)0.25205480.055
  1. swap.legAnalysis(1).tail()
AMOUNTNOMINALACCRUAL_START_DATEACCRUAL_END_DATEACCRUAL_DAYSINDEXFIXING_DAYSFIXING_DATESINDEX_FIXINGDAY_COUNTERACCRUAL_PERIODEFFECTIVE_RATE
PAYMENT_DATE
2024-08-0713069271e+082024-05-072024-08-0792repoChina1W Actual/365 (Fixed)12024-05-060.05072614Actual/3600.25555560.05114062
2024-11-0713069271e+082024-08-072024-11-0792repoChina1W Actual/365 (Fixed)12024-08-060.05072614Actual/3600.25555560.05114062
2025-02-0713095701e+082024-11-072025-02-0792repoChina1W Actual/365 (Fixed)12024-11-060.05073319Actual/3600.25555560.05124405
2025-05-0712658081e+082025-02-072025-05-0789repoChina1W Actual/365 (Fixed)12025-02-060.05073319Actual/3600.24722220.05120122
2025-08-0713069271e+082025-05-072025-08-0792repoChina1W Actual/365 (Fixed)12025-05-060.05072614Actual/3600.25555560.05114062