optimizing energy trading