FDM.3:4.2.2 - Construct enough state and preserve the different dates
Work backward from the next calculation to determine what must be carried forward. Simple interest on unpaid principal needs that principal, the rate and the beginning of the unaccrued interval. Interest already accrued but not paid needs its own amount. An exercised option may change which later events are possible. A more complex instrument can require other state; an unused field need not be invented.
Initialize those values for the requested starting time from supported history or a qualified existing account. Starting halfway through a loan with its original principal can produce a wrong forecast after a repayment. Estimating prior interest from today’s principal or rate can also be wrong after a change. Recover the intervening event or the adequate opening value. If it is unavailable, identify which later quantities remain conditional.
Generate recurring dates from the specified anchor, interval and end condition. Preserve a short final period or end-of-month rule where the agreement requires it. Then determine which dates the business-day convention changes. The date used to calculate interest, the date on which payment is due and the date on which a transfer actually settles can differ. Notice and observation dates can add further relevant boundaries.
At a rate or principal change, split the accrual interval at the effective boundary and apply each value only to its interval. When events coincide, obtain the order from the terms or their qualified interpretation. Calculate on the state that the event’s rule actually consumes. A convenient spreadsheet row order supplies no financial reason for that choice.