quantlib.time.daycounter.DayCounter.year_fraction

DayCounter.year_fraction(self, Date date1, Date date2, Date ref_start=Date(), Date ref_end=Date())

Returns the period between two dates as a fraction of year.