code: def xnpv(rate, values, dates, lim_rate = True):  # Excel reference: https://support.office.com/en-us/article/XNPV-function-1b42bbf6-370f-4532-a0eb-d67c16b664b7
      
      if isinstance(values, Range):
          values = values.values
  
      if isinstance(dates, Range):
          dates = dates.values
  
      if len(values) != len(dates):
          return ExcelError('#NUM!', '`values` range must be the same length as `dates` range in XNPV, %s != %s' % (len(values), len(dates)))
  
      if lim_rate and rate < 0:
          return ExcelError('#NUM!', '`excel cannot handle a negative `rate`' % (len(values), len(dates)))
  
      xnpv = 0
      for v, d in zip(values, dates):
          xnpv += v / np.power(1.0 + rate, (d - dates[0]) / 365)
  
      return xnpv
docs: Function to calculate the net present value (NPV) using payments and non-periodic dates. It resembles the excel function XPNV().
  
      :param rate: the discount rate.
      :param values: the payments of which at least one has to be negative.
      :param dates: the dates as excel dates (e.g. 43571 for 16/04/2019).
      :return: a float being the NPV.