Period Counter


Function Period Counter within
IRS with keys IRS Period Counter keysreturns an integer that equals the index of the accrual period of the specified leg of the referenced swap that contains a supplied date D
The leg's first period is associated with the index 1.

All accrual periods in the leg are assumed to be consecutive - i.e. without gaps or overlaps - and defined by the N + 1 dates:
T⁰, T¹, T², ..., Tᴺ
which are the final accrual dates that include the effect of any potential adjustment defined in the swap contract.
So, there exist N periods, denoted as:
[T⁰,T¹) , [T¹,T²) , ..., [Tᴺ⁻¹,Tᴺ)

Note that the iᵗʰ accrual period [[Tᵢ₋₁,Tᵢ)), where i = 1, 2, ..., N, is an interval that is closed at the left and open at the right.

If the iᵗʰ accrual period [[Tᵢ₋₁,Tᵢ)) happens to contain the supplied date D, the function here returns the integer i

An error is issued if no such period is found.