Foundations Of Reinforcement Learning With Applications In Finance