_check_regular_swap#

rateslib.scheduling._check_regular_swap(effective, termination, frequency, modifier, eom, roll, calendar)#

Tests whether the given the parameters define a regular leg schedule without stubs.

Parameters:
  • effective (datetime) – The adjusted or unadjusted effective date.

  • termination (datetime) – The adjusted or unadjusted termination date.

  • frequency (str in {}, optional) – The frequency of the schedule.

  • modifier (str,) – The date modification rule in {‘NONE’, ‘F’, ‘MF’, ‘P’, ‘MP’}.

  • eom (bool) – Use an end of month preference for rolls instead of 28, 29, or 30.

  • roll (str, int, optional, set by Default) – The roll day for the schedule in [0, 31] or {“eom”, “som”, “imm”}.

  • calendar (Calendar, optional, set by Default) – The holiday calendar used for adjusting dates.

Notes

This function first assumes that the given effective and termination dates are unadjusted and checks if it is a regular swap. If not the function attempts to reverse-adjust the dates to their possible unadjusted values and re check the validity of a regular swap. This is only possible if a given effective or termination date is surrounded by a holiday which could have been modified to yield the given date.

Priority is always given to test the given dates first and any values close to those. The termination dates are trialed ahead of the effective dates, thus if a roll day is not specified it will likely be inferred from the effective date.

When trading interbank swaps there is an ambiguous situation that can arise in regards to forward starting tenors. For example suppose that the current effective date is Fri 4th March 2022 and a 1Y1Y swap is traded. This can have the following implications:

  • Sat 4th March 2023 (1Y forward) is modified to Mon 6th March effective date and the swap is then defined as 1Y out of 6th March making the termination date Wed 6th March 2024. The swap is defined with a 6th roll as per the effective date.

  • Sat 4th March 2023 is modified to Mon 6th March but the termination date remains as the valid date measured 1Y from 4th March, i.e. Mon 4th March 2024. The swap is set to have 4th rolls. (These 4th rolls would even be valid if the termination date had to be modified to the 5th, or 6th, say).

Although the first bullet is prevalent in the GBP market, other markets such as EUR adopt the second approach, and the second also provides a more consistent framework with which to hedge using par tenors so we adopt the second in this method.