A fast algorithm for computing integrals in function spaces: Financial applications