Optimal Mean Reversion Trading: Mathematical Analysis And Practical Applications