refactor update trades script