Refactor stocklearn