Add rolling line balance, remove groupdate dependency and built raw sql grouping