ENH: use array and pandas operations to speed up risk computations