rate: effective annual interest rate
values: cash flow
dates: dates of cash flow
XNPV calculates the net present value of a cash flow at irregular times
If type is 0, the default, payment is at the end of each period. If type is 1, payment is at the beginning of each period.