Foundations of reinforcement learning with applications in finance. (2022)