Refactor tradings page code