Final code for the trading system