Ternary trades and their codes