程式

如何在 python quantlib 中製定攤銷債券的時間表?

  • October 12, 2021

我正在嘗試在 quantlib 中製定攤銷債券的時間表,但不知道如何在此時間表中包括攤銷。

我有以下債券:

Maturity Date: 
30.04.2023 
Coupon Frequency: 
300 at
30.04.2018
300 at
30.04.2021
Day Count 
Convention: 30Е/360
Coupon rate: 10

這是python程式碼

faceValue = 100.0
ed = ql.Date(2, ql.December, 2019)
mat_d = ql.Date(30, ql.April, 2023)
coupons = [0.1]

dayCounter = ql.Thirty360(ql.Thirty360.European)

schedule = ql.Schedule(ed, mat_d, ql.Period(ql.Semiannual),
   ql.Russia(),
   ql.Unadjusted, ql.Unadjusted,
   ql.DateGeneration.Backward, False)

建立債券時包括攤銷。

鑑於您提到支付 300,我猜您的面值是 1000,而不是您寫的 100。此外,您提到在 2018 年 4 月 30 日付款,但您的日程安排從 2019 年 12 月 2 日開始。出於範例的目的,我將更早地開始計劃,以便它包括兩次付款。

所以,假設你的日程安排是

start_d = ql.Date(30, ql.April, 2016)
mat_d = ql.Date(30, ql.April, 2023)
schedule = ql.Schedule(
   start_d, mat_d, ql.Period(ql.Semiannual),
   ql.Russia(),
   ql.Unadjusted, ql.Unadjusted,
   ql.DateGeneration.Backward, False)

它給出了日期:

[Date(30,4,2016),
Date(30,10,2016),
Date(30,4,2017),
Date(30,10,2017),
Date(30,4,2018),
Date(30,10,2018),
Date(30,4,2019),
Date(30,10,2019),
Date(30,4,2020),
Date(30,10,2020),
Date(30,4,2021),
Date(30,10,2021),
Date(30,4,2022),
Date(30,10,2022),
Date(30,4,2023)]

要創建攤銷債券,您需要為每張息票指定名義金額。在此範例中,前四張優惠券(2018 年 4 月 30 日之前)以全額名義支付;然後支付 300 的攤銷,接下來的六張息票支付剩餘的名義金額(700);然後另一筆 300 的攤銷付款來了,接下來的四張息票支付剩餘的(400)。所以你會寫:

notionals = [1000, 1000, 1000, 1000,
            700, 700, 700, 700, 700, 700,
            400, 400, 400, 400]

你將創建債券為

settlement_days = 3
coupons = [0.1]
dayCounter = ql.Thirty360(ql.Thirty360.European)

bond = ql.AmortizingFixedRateBond(settlement_days, notionals, schedule, coupons, dayCounter)

現在您可以檢查其現金流量:

for c in bond.cashflows():
   print(f"{str(c.date()):20} => {c.amount():.4}")

這使

October 31st, 2016   => 50.0
May 2nd, 2017        => 50.0
October 30th, 2017   => 50.0
May 3rd, 2018        => 50.0
May 3rd, 2018        => 300.0
October 30th, 2018   => 35.0
April 30th, 2019     => 35.0
October 30th, 2019   => 35.0
April 30th, 2020     => 35.0
October 30th, 2020   => 35.0
April 30th, 2021     => 35.0
April 30th, 2021     => 300.0
November 1st, 2021   => 20.0
May 3rd, 2022        => 20.0
October 31st, 2022   => 20.0
May 2nd, 2023        => 20.0
May 2nd, 2023        => 400.0

引用自:https://quant.stackexchange.com/questions/68160