I’d like to calculate the number of periods between two dates. The aim is to calculate a loan amortizing schedule.
The following code arrives up to a certain point, i.e. to calculate the interval in days, but I’d like to convert those days in month, quarters or years as applicable. I’d use yearfrac and multiply it by a factor but I don’t find it easy to vectorize it.
using Dates, DayCounts
start_date = [Date(2022, 1, 1), Date(2021, 1, 1)]
maturity_date = [Date(2023, 1, 1), Date(2022, 12, 1)]
time_period = (Dates.value.(maturity_date) .- Dates.value.(start_date))
# or
time_period = yearfrac(start_date[1,1], maturity_date[1,1], DayCounts.Thirty360())