QuantLib icon indicating copy to clipboard operation
QuantLib copied to clipboard

Jump in OAS on callable bond with ex coupon date

Open HristoRaykov opened this issue 1 year ago • 3 comments

I notice OAS jumps on callable fixed rate bond with ex coupon when call date is between ex coupon date and payment date. For simplicity will use only one call date which will move forward from one week before ex coupon date to one week after payment date. All calculations are made using the same valuation date and price. I am on Windows 11, Python 3.11.5, QuantLib==1.38.

import QuantLib as ql
import pandas as pd

val_date = ql.Date(31, 1, 2024)
ql.Settings.instance().evaluationDate = val_date

settlement_days = 0
calendar = ql.UnitedStates(ql.UnitedStates.NYSE)
compounding = ql.Compounded
dc = ql.Thirty360(ql.Thirty360.BondBasis)
bdc = ql.Unadjusted
frequency = ql.Quarterly
ex_cpn_period = ql.Period(14, ql.Days)

issue_date = ql.Date(31, 1, 2024)
maturity_date = ql.Date(31, 1, 2029)
coupon = 0.06
clean_price = 100.00
redemption_price = 100.00

schedule = ql.Schedule(issue_date, maturity_date, ql.Period(frequency), calendar, bdc, bdc,
                       ql.DateGeneration.Backward, True)
call_price = ql.BondPrice(redemption_price, ql.BondPrice.Clean)

ts = ql.FlatForward(val_date, 0.04, dc)
ts_handle = ql.YieldTermStructureHandle(ts)

model = ql.HullWhite(ts_handle)
engine = ql.TreeCallableFixedRateBondEngine(model, 100, ts_handle)

start_date = schedule[1] - ex_cpn_period - ql.Period(7, ql.Days)
end_date = schedule[1] + ql.Period(7, ql.Days)
dates = []
date = start_date
while date <= end_date:
    dates.append(date)
    date += ql.Period(1, ql.Days)

df = pd.DataFrame()
for idx, date in enumerate(dates):
    call_schedule = ql.CallabilitySchedule()
    call_schedule.append(ql.Callability(call_price, ql.Callability.Call, date))
    bond = ql.CallableFixedRateBond(settlement_days, 100, schedule, [coupon], dc, bdc, 100, issue_date, call_schedule,
                                    ex_cpn_period, ql.NullCalendar())
    bond.setPricingEngine(engine)

    oas = bond.OAS(clean_price, ts_handle, dc, compounding, frequency) * 10000
    accrued_amt = bond.accruedAmount(date)
    df.loc[idx, 'call_date'] = date.ISO()
    df.loc[idx, 'oas'] = oas
    df.loc[idx, 'accrued_amount'] = accrued_amt
    df.loc[idx, 'dirty_price'] = clean_price + accrued_amt
    df.loc[idx, 'days_from_call_to_next_paym_date'] = schedule.nextDate(date) - date

Ex coupon date is 2024-04-16, payment date is 2024-04-30.

call_date oas accrued_amount dirty_price days_from_call_to_next_paym_date
2024-04-09 154.53 1.15 101.15 21
2024-04-10 154.43 1.17 101.17 20
2024-04-11 154.34 1.18 101.18 19
2024-04-12 154.25 1.20 101.20 18
2024-04-13 154.16 1.22 101.22 17
2024-04-14 154.07 1.23 101.23 16
2024-04-15 153.99 1.25 101.25 15
2024-04-16 -512.51 -0.23 99.77 14
2024-04-17 -503.29 -0.22 99.78 13
2024-04-18 -494.30 -0.20 99.80 12
2024-04-19 -485.54 -0.18 99.82 11
2024-04-20 -477.00 -0.17 99.83 10
2024-04-21 -468.67 -0.15 99.85 9
2024-04-22 -460.54 -0.13 99.87 8
2024-04-23 -452.61 -0.12 99.88 7
2024-04-24 -444.86 -0.10 99.90 6
2024-04-25 -437.30 -0.08 99.92 5
2024-04-26 -429.91 -0.07 99.93 4
2024-04-27 -422.70 -0.05 99.95 3
2024-04-28 -415.64 -0.03 99.97 2
2024-04-29 -408.75 -0.02 99.98 1
2024-04-30 152.05 0.00 100.00 0
2024-05-01 152.26 0.02 100.02 91
2024-05-02 152.47 0.03 100.03 90
2024-05-03 152.67 0.05 100.05 89
2024-05-04 152.85 0.07 100.07 88
2024-05-05 152.34 0.08 100.08 87
2024-05-06 152.26 0.10 100.10 86
2024-05-07 152.39 0.12 100.12 85

HristoRaykov avatar May 29 '25 11:05 HristoRaykov

Thanks for the heads-up

lballabio avatar Jul 25 '25 09:07 lballabio

I've been investigating this and can confirm the root cause. Here's a summary.

Root cause

There's an inconsistency in setupArguments() between how the tree values the bond and how the call price is computed when a call date falls in the ex-coupon window.

Coupon filtering (callablebond.cpp:425-431): coupons are included/excluded from the tree based on tradingExCoupon(settlement). Since the settlement date (Jan 31) is well before the ex-coupon date (April 16), the upcoming coupon at April 30 is included in the tree's cashflows.

Call price (callablebond.cpp:447-453): the clean call price is converted to dirty by adding this->accrued(callDate). When the call date is in the ex-coupon period, FixedRateCoupon::accruedAmount() returns negative accrued, so the dirty call price drops to ~99.77.

Exercise decision (discretizedcallablefixedratebond.cpp:173): min(99.77, ~101.5) = 99.77 — the holder loses the coupon value at the call node.

The withinNextWeek() snapping from PR #1142 doesn't help here because the ex-coupon period (14 days) is longer than the 7-day snapping window.

Fix

The call price should use positive (non-ex-coupon) accrued because the call is an issuer action governed by the indenture — the holder receives the call price plus full accrued from the last payment date. In setupArguments(), when the call date falls in an ex-coupon window, I compute coupon->amount() + coupon->accruedAmount(callDate) instead of just coupon->accruedAmount(callDate). This recovers the positive accrued without changing the behavior for non-ex-coupon bonds.

Before/after for the reporter's scenario (OAS in bps, call date sweep):

Call date      Before fix    After fix
2024-04-15       153.99       153.99     (before ex-coupon)
2024-04-16      -512.51       153.91     (ex-coupon starts)
2024-04-20      -477.00       153.61
2024-04-25      -437.30       151.32
2024-04-29      -408.75       151.91
2024-04-30       152.05       152.05     (payment date)

All 12 existing CallableBondTests pass without changes.

Happy to open a PR if this approach looks right.

pandashark avatar Feb 13 '26 18:02 pandashark

Thanks—I think that's correct, please go ahead and open a PR.

lballabio avatar Feb 23 '26 09:02 lballabio