trade_closed function added.