main logic for the trading
add events and resolve the trading bug