new tradehistory analyzation, change "When" command

Now When command uses the socket data for more things. Fixed bugs and
error checking.