σμimplied vol · KKmax(S−K,0)udβρᵢⱼfat tailsPnL · drawdownyield · TdSₜ = μSₜ dt + σSₜ dWₜC = S·N(d₁) − K·e⁻ʳᵀ·N(d₂)σₚ² = wᵀΣwd₁ = [ln(S/K) + (r + σ²⁄2)T] ⁄ σ√T∂V/∂t + ½σ²S²·∂²V/∂S² + rS·∂V/∂S − rV = 0Sharpe = (Rₚ − R_f) ⁄ σₚVaR₉₉ = μ − 2.33σρ = Cov(X,Y) ⁄ σₓσᵧE[Rₚ] = Σ wᵢ·E[Rᵢ]φ(x) = e^(−x²/2) ⁄ √2πE[Rᵢ] = R_f + βᵢ(E[Rₘ] − R_f)dXₜ = θ(μ − Xₜ)dt + σ dWₜσ²ₜ = ω + α·ε²ₜ₋₁ + β·σ²ₜ₋₁C − P = S − K·e⁻ʳᵀΔ = ∂V/∂S Γ = ∂²V/∂S²p = (e^(rΔt) − d) ⁄ (u − d)rₜ = ln(Pₜ ⁄ Pₜ₋₁)E[Xₜ₊₁ | ℱₜ] = Xₜf* = (bp − q) ⁄ bz = (x − μ) ⁄ σP(N=k) = λᵏe^(−λ) ⁄ k!Θ = −∂V/∂Tν = S·φ(d₁)·√Tmin wᵀΣw s.t. wᵀμ = μ*∫Σ∂∞λ
uantCraft AcademyRoadmapsSkills
Ctrl K
AO
+1.2k Learners
LoginJoin ↗
RoadmapsSkills
AO
+1.2k Learners
Login
  • English
  • Français
  • Español
  • العربية
  • Português
  • Deutsch
  • 日本語
  • 中文
σμimplied vol · KKmax(S−K,0)udβρᵢⱼfat tailsPnL · drawdownyield · TdSₜ = μSₜ dt + σSₜ dWₜC = S·N(d₁) − K·e⁻ʳᵀ·N(d₂)σₚ² = wᵀΣwd₁ = [ln(S/K) + (r + σ²⁄2)T] ⁄ σ√T∂V/∂t + ½σ²S²·∂²V/∂S² + rS·∂V/∂S − rV = 0Sharpe = (Rₚ − R_f) ⁄ σₚVaR₉₉ = μ − 2.33σρ = Cov(X,Y) ⁄ σₓσᵧE[Rₚ] = Σ wᵢ·E[Rᵢ]φ(x) = e^(−x²/2) ⁄ √2πE[Rᵢ] = R_f + βᵢ(E[Rₘ] − R_f)dXₜ = θ(μ − Xₜ)dt + σ dWₜσ²ₜ = ω + α·ε²ₜ₋₁ + β·σ²ₜ₋₁C − P = S − K·e⁻ʳᵀΔ = ∂V/∂S Γ = ∂²V/∂S²p = (e^(rΔt) − d) ⁄ (u − d)rₜ = ln(Pₜ ⁄ Pₜ₋₁)E[Xₜ₊₁ | ℱₜ] = Xₜf* = (bp − q) ⁄ bz = (x − μ) ⁄ σP(N=k) = λᵏe^(−λ) ⁄ k!Θ = −∂V/∂Tν = S·φ(d₁)·√Tmin wᵀΣw s.t. wᵀμ = μ*∫Σ∂∞λ
uantCraft AcademyRoadmapsSkills
Ctrl K
AO
+1.2k Learners
LoginJoin ↗
RoadmapsSkills
AO
+1.2k Learners
Login
  • English
  • Français
  • Español
  • العربية
  • Português
  • Deutsch
  • 日本語
  • 中文
QuantLib skill›Module 1 · Dates and schedules›Topic 1.2·~50 minIntermediate

Schedules and business-day conventions

Skill positionModule 1 of 5 · Topic 2 of 2
1.2 Schedules and business-day conventions
—Lab score— / 100Total XP—Streak—
Lecture0% read

9 min readCode examples: 4

  1. 01Moving a date off a holiday
  2. 02Generating the dates
  3. 03From dates to cash flows
  4. 04Five-year notes on real yields
  5. 05What you will build

A five-year Treasury note issued on 29 February 2024 with a 4.25% coupon pays 10 times, from 30 August 2024 to 28 February 2029, and 4 of its 10 dates fall on a weekend or a holiday and have to be moved. Together the payments add up to 212,402.33 dollars on a face value of a million. This topic turns the calendar of the last one into the thing a bond needs from it: a list of payment dates, and the amount of each payment.

01

Moving a date off a holiday

Where we are. The calendar of the last topic tells you whether a day is open. A bond contract, though, is written with plain calendar dates such as "the 30th of June and the 30th of December", and some of those dates will be a Saturday. The contract therefore also states a business-day convention: the rule that moves a payment off a closed day. There are four ways to move, and a fifth choice, not to move at all.

Following moves to the next business day. Preceding moves to the previous one. Each has a modified version that avoids crossing into another month: modified following moves forward, but if that lands in the next month it goes backward instead; modified preceding moves backward, but if that lands in the previous month it goes forward instead. The modified following rule is the most common for bonds and swaps, because a payment for a month should not be made in the next month. Unadjusted leaves the date as it is.

Worked example 1. *Problem:* move Saturday 30 March 2024 (the day after Good Friday), Saturday 31 August 2024 (the Monday after it is Labor Day) and Saturday 1 May 2021 by each of the five conventions. *Plan:* use adjust. *Steps:* below.

main.pyPython
for convention in BUSINESS_CONVENTIONS:    print(convention, adjust(date(2024, 3, 30), convention), adjust(date(2024, 8, 31), convention), adjust(date(2021, 5, 1), convention))1
unadjusted 2024-03-30 2024-08-31 2021-05-01
following 2024-04-01 2024-09-03 2021-05-03
modified_following 2024-03-28 2024-08-30 2021-05-03
preceding 2024-03-28 2024-08-30 2021-04-30
modified_preceding 2024-03-28 2024-08-30 2021-05-03
  1. 1Three Saturdays, five rules.

*Check:* 30 March 2024 becomes 2024-04-01 under following, but 2024-03-28 under modified following, preceding and modified preceding: April is another month, and Good Friday, the 29th, is closed. 31 August 2024 becomes 2024-09-03 under following (the Monday is Labor Day) but 2024-08-30 under modified following, preceding and modified preceding. 1 May 2021 becomes 2021-05-03 under following, modified following and modified preceding, but 2021-04-30 under preceding. *What to notice:* the modified rules differ from the plain ones only at the end or the start of a month, and that is where they matter: a payment for April would be made in May.

02

Generating the dates

Before any adjustment, a schedule is a list of regular dates: every 6 months, every 3 months. The simple way to build it is to start from the first date and add a multiple of the step each time: the start, then the start plus one step, then plus two steps. Do not add a step to the previous date. A schedule that starts on 31 January and goes up by 3 months should read 31 January, 30 April, 31 July: the month arithmetic of the last topic cuts the day to 30 in April, but the next date goes back to 31 because it is counted from the start.

Real bonds rarely last a whole number of steps. If the dates run forward from the start, the last period is shorter than the rest, and if they run backward from the end, the first period is shorter. The short period is called a stub. A last rule concerns the end of the month: a bond issued on the last day of a month should pay on the last day of every month, even when the month arithmetic would give the 28th or the 29th. That is the end-of-month rule: every date in the middle of the schedule is moved to the last day of its month.

Worked example 2. *Problem:* list the dates from 31 January 2024 to 31 January 2025 every 3 months; from 15 January to 20 November 2024 every 3 months, forward and backward; and from 29 February 2024 to 28 February 2026 every 6 months, with and without the end-of-month rule. *Plan:* use unadjusted_dates. *Steps:* below.

main.pyPython
print([str(d) for d in unadjusted_dates(date(2024, 1, 31), date(2025, 1, 31), 3)])1print([str(d) for d in unadjusted_dates(date(2024, 1, 15), date(2024, 11, 20), 3)])2print([str(d) for d in unadjusted_dates(date(2024, 1, 15), date(2024, 11, 20), 3, backward=True)])3print([str(d) for d in unadjusted_dates(date(2024, 2, 29), date(2026, 2, 28), 6)])print([str(d) for d in unadjusted_dates(date(2024, 2, 29), date(2026, 2, 28), 6, eom=True)])4
['2024-01-31', '2024-04-30', '2024-07-31', '2024-10-31', '2025-01-31']
['2024-01-15', '2024-04-15', '2024-07-15', '2024-10-15', '2024-11-20']
['2024-01-15', '2024-02-20', '2024-05-20', '2024-08-20', '2024-11-20']
['2024-02-29', '2024-08-29', '2025-02-28', '2025-08-29', '2026-02-28']
['2024-02-29', '2024-08-31', '2025-02-28', '2025-08-31', '2026-02-28']
  1. 1Counted from the start, the third date is back to the 31st.
  2. 2A short last period of 36 days.
  3. 3Backward: the short period comes first.
  4. 4End of month: 31 August, not 29 August.

*Check:* the first list is 2024-01-31, 2024-04-30, 2024-07-31, 2024-10-31 and 2025-01-31. The forward list from 15 January ends with a short period, 2024-10-15 to 2024-11-20, and the backward list starts with one, 2024-01-15 to 2024-02-20. From 29 February 2024, six-month steps give 2024-08-29, 2025-02-28 and 2025-08-29, but with the end-of-month rule they give 2024-08-31, 2025-02-28 and 2025-08-31. *What to notice:* without the rule, the schedule drifts away from the end of the month and never comes back; with it, a note issued on the last day of February pays on the last day of August.

03

From dates to cash flows

A schedule is the unadjusted dates, each moved by the business-day convention. A coupon is the interest a bond pays at the end of one period. Two things are easy to mix up, and the market keeps them apart. The payment date is the adjusted date, because money moves only on an open day. The amount uses the unadjusted dates of the period, because the interest depends on the period the contract describes, and not on the day the payment falls. Moving a payment from a Saturday to a Monday does not change what the bond pays.

amount = notional × rate × year fraction( period start, period end, day count ), payment date = adjust( period end, convention )(1)the period dates are the unadjusted dates; the year fraction is the one of the previous topic

Worked example 3. *Problem:* adjust the dates from 29 February 2024 to 28 February 2026 every 6 months, with the end-of-month rule and modified following. Then find the payments of a 5% bond on a million dollars from 30 June 2024 to 30 June 2025 every 6 months, under Actual/360 with the following convention, and under the default Actual/Actual with modified following. *Plan:* use schedule and coupons. *Steps:* below.

main.pyPython
print([str(d) for d in schedule(date(2024, 2, 29), date(2026, 2, 28), 6, "modified_following", False, True)])1for flow in coupons(date(2024, 6, 30), date(2025, 6, 30), 6, 0.05, 1_000_000, "act/360", "following"):    print(flow[0], round(flow[1], 2))2for flow in coupons(date(2024, 6, 30), date(2025, 6, 30), 6, 0.05, 1_000_000):    print(flow[0], round(flow[1], 2))3
['2024-02-29', '2024-08-30', '2025-02-28', '2025-08-29', '2026-02-27']
2024-12-30 25416.67
2025-06-30 25277.78
2024-12-30 25000.0
2025-06-30 24930.76
  1. 1The last date is a Saturday, so it moves back.
  2. 2Actual/360: 183 and 182 days over 360.
  3. 3Actual/Actual: exactly half a year for the first period.

*Check:* the adjusted schedule is 2024-02-29, 2024-08-30, 2025-02-28, 2025-08-29 and 2026-02-27: 31 August 2024, 31 August 2025 and 28 February 2026 are all weekend days and move back to the Friday. Under Actual/360 the payments are 25416.67 on 2024-12-30 and 25277.78 on 2025-06-30: 183 and 182 days of interest at 5% on a million, over 360. Under Actual/Actual they are 25000.00 and 24930.76. *What to notice:* the first period lies inside 2024, a leap year, and is 183 days of 366, so it pays exactly half a coupon. The second is 2 days of 2024 plus 180 days of 2025, a little less than half a year. The convention changes the amounts by hundreds of dollars on a million.

04

Five-year notes on real yields

Worked example 4. *Problem:* build the cash flows of three real five-year Treasury notes, issued on 31 May 2020, 31 August 2022 and 29 February 2024, each with a face value of one million dollars. The Treasury sets the coupon at the 5-year yield of the day rounded down to a multiple of one eighth of a percent. The note pays every 6 months, with the end-of-month rule, modified following, and Actual/Actual. For each note, find the coupon, the number of payments, the first and last payment dates, how many dates the convention moved, and the total interest. *Plan:* study takes the yield from the table and builds the dates and the cash flows. *Steps:* below.

main.pyPython
out = study(load_data())for issue, row in out.items():    print(issue, row["coupon"], row["payments"], row["first"], row["last"], row["moved"], round(row["first_amount"], 2), round(row["total"], 2))1
2020-05-31 0.0025 10 2020-11-30 2025-05-30 3 1250.0 12495.98
2022-08-31 0.0325 10 2023-02-28 2027-08-31 4 16116.44 162500.0
2024-02-29 0.0425 10 2024-08-30 2029-02-28 4 21366.12 212402.33
  1. 1One line per note.

*Check:* the coupons are 0.0025 (a quarter of a percent, in the low rates of May 2020), 0.0325 and 0.0425, and each note has 10 payments. The first note pays from 2020-11-30 to 2025-05-30, with 3 dates moved, and its total interest is 12495.98. The second pays from 2023-02-28 to 2027-08-31, with 4 moved and a total of exactly 162500.00; its first payment is 16116.44, not half a coupon, 16250. The third pays from 2024-08-30 to 2029-02-28 and its total is 212402.33. *What to notice:* with Actual/Actual (ISDA) the half-year payment is not always exactly half a coupon: 181 days over 365 give 16116.44. The Treasury itself pays exactly half a coupon, which is the ICMA version of the convention, and a later topic comes back to the difference.

In QuantLib

A schedule is an object: ql.Schedule(start, end, ql.Period(ql.Semiannual), calendar, ql.ModifiedFollowing, ql.ModifiedFollowing, ql.DateGeneration.Forward, endOfMonth). The two conventions are the one for the dates in the middle and the one for the termination date, and ql.DateGeneration.Backward gives the other direction. A coupon leg is built from a schedule with ql.FixedRateLeg.

  • FunctionQuestion it answers
  • adjust(d, convention)Where does a closed day move to?uses is_business_dayQuantLib: calendar.adjust
  • unadjusted_dates(start, end, months, backward, eom)Which regular dates does the schedule have?uses add_monthsQuantLib: DateGeneration
  • schedule(start, end, months, convention, backward, eom)On which days are the payments made?uses the two functions aboveQuantLib: Schedule
  • coupons(start, end, months, rate, notional, daycount, ...)How much is paid, and when?uses year_fractionQuantLib: FixedRateLeg
What the real data saysThree five-year Treasury notes issued at the end of a month, with the coupon set from the 5-year yield of the day
Coupon of the note issued 31 May 20200.25%the 5-year yield was just above it
Coupon of the note issued 31 Aug 20223.25%total interest 162,500.00
Coupon of the note issued 29 Feb 20244.25%total interest 212,402.33
Dates moved by modified following3 / 4 / 4of 10 dates in each note
First payment of the leap-day note30 Aug 202431 August was a Saturday

Key takeaways

  • The contract names the rule. A business-day convention says where a payment on a closed day goes; modified following never leaves the month.
  • Count from the start. Add a multiple of the step to the first date, never a step to the previous date, or the day of the month drifts.
  • Stubs and the end of the month are rules too. Forward and backward generation decide which period is short, and the end-of-month rule keeps a month-end bond on month-ends.
  • Dates and amounts use different dates. The payment date is adjusted, because money moves on open days; the amount uses the unadjusted period, because the contract describes it.
Quick check
Your turn. A payment is due on Saturday 31 August 2024, and the next Monday is a holiday. Which date does the modified following convention give?
Pick an answer.
05

What you will build

The lab follows the lecture. Task 1 moves a date by a business-day convention. Task 2 generates the unadjusted dates, forward or backward and with the end-of-month rule, and task 3 adjusts them. Task 4 turns the dates into payments, and task 5 builds the payments of three real Treasury notes. The calendar of the last topic is given to you, so you can use is_business_day, add_months and year_fraction.

Next topic: Interest rates and compounding. You now have the amounts and the dates of a bond. To say what it is worth you must say what one dollar on one date is worth on another, and that depends on how a rate is quoted: simple, compounded every year, or compounded all the time. The next topic turns a rate into a discount factor, and ends by asking what to do when there is not one rate but many.

Lab · what's graded

5 tasks · 100 pts
  • Business-day conventions20 pts
  • The regular dates22 pts
  • The adjusted schedule10 pts
  • The coupons22 pts
  • Three Treasury notes26 pts
Explorer · lab-sqt-02
▾ lab-sqt-02
▾ data
…
bash · in-browser
learner@quantcraft:~/lab-sqt-02$
Python not loaded yetPythonLn 1, Col 1Spaces: 4UTF-8

Reset this topic?

Everything in lab-sqt-02 goes back to the starter files and the terminal is cleared. Your current solution will be lost — this can't be undone.

Will be reset
  • main.py → starter code
  • Terminal history and test output
  • Unsubmitted changes
Will be kept
  • Best lab score
  • Your XP and streak
  • Lecture progress and notes