add error handling for trading functions