Trading by Reinforcement Learning: Mathematical Approach to Market Analysis