Added more code to the trade logic.