Reinforcement learning (RL) has led to several breakthroughs in AI. The use of the Q-learning (DQL) algorithm alone has helped people develop agents that play arcade games and board games at a superhuman level. More recently, RL, DQL, and similar methods have gained popularity in publications related to financial research. This book is among the first to explore the use of reinforcement learning methods in finance. Author Yves Hilpisch, founder and CEO of The Python Quants, provides the background you need in concise fashion. ML practitioners, financial traders, portfolio managers, strategists, and analysts will focus on the implementation of these algorithms in the form of self-contained Python code and the application to important financial problems. This book covers: * Reinforcement learning * Deep Q-learning * Python implementations of these algorithms * How to apply the algorithms to financial problems such as algorithmic trading, dynamic hedging, and dynamic asset allocation This book is the ideal reference on this topic. You'll read it once, change the examples according to your needs or ideas, and refer to it whenever you work with RL for finance. Dr. Yves Hilpisch is founder and CEO of The Python Quants, a group that focuses on the use of open source technologies for financial data science, AI, asset management, algorithmic trading, and computational finance.

Browse the chapters to quickly get to know the structure and content of the book.
By browsing the chapters of this book you can quickly see what each part teaches, how the whole is structured and where to start. Each chapter focuses on one concept or skill, and you see its main topics so your choice is more informed. Whether you follow the whole book or just one part, this view helps you find your way.
The first part of the book covers the basics of reinforcement learning and provides background information. It consists of three chapters:
Chapter 1 focuses on learning through interaction with four major examples: probability matching, Bayesian updating, reinforcement learning (RL), and deep Q-learning (DQL).
Chapter 2 introduces concepts from dynamic programming (DP) and discusses DQL as an approach to approximate solutions to DP problems. The major theme is the derivation of optimal policies to maximize a given objective function through taking a sequence of actions and updating the optimal policy iteratively. DQL is illustrated based on the CartPole game from the Gymnasium Python package.
Chapter 3 develops a first Finance environment that allows the DQL agent from Chapter 2 to learn a financial prediction game. Although the environment formally replicates the API of the CartPole, it misses some important characteristics that are needed to apply RL successfully.

1. Learning Through Interaction

2. Deep Q-Learning

3. Financial Q-Learning
The second part of the book covers concepts about and approaches to generating data for financial deep Q-learning:
Chapter 4 implements data generation approaches based on Monte Carlo simulation (MCS). One approach is to add white noise to an existing financial time series. Another one is to simulate financial time series data based on a financial model (a stochastic differential equation).
Chapter 5 shows how to use generative adversarial networks (GANs) from AI, or more specifically, from deep learning (DL), to generate financial time series data that is consistent with and statistically indistinguishable from the target financial time series. Such a target time series can be the historical return series for a share of a company stock (think Apple shares) or historical foreign exchange quotes (think the EUR/USD exchange rate).

4. Simulated Data

5. Generated Data
The third part of the book applies the algorithms and techniques introduced in the first two parts to classical financial problems:
Chapter 6 applies deep Q-learning (DQL) to the algorithmic trading of a single financial instrument. It builds on the prediction game discussed in Chapter 3. The chapter uses Monte Carlo simulated data to train a financial Q-learning (FQL) agent called TradingAgent. The goal of the FQL agent is to maximize the profit from going long and short on a single financial instrument.
Chapter 7 uses DQL to learn how to hedge, or rather replicate, a European call option in the seminal model by Black-Scholes-Merton (1973) for option pricing. The HedgingAgent is able to learn appropriate hedging strategies by working with market-observable data only. For example, the agent knows the current price of the underlying asset, the time to maturity, and the current option price.
Chapter 8 applies reinforcement learning (RL) to three classical problems in investment management. The first problem is determining the optimal allocation between a risky asset and a risk-free asset, commonly referred to as two-fund separation. The second problem focuses on finding the optimal allocation between two risky, negatively correlated assets. The third problem extends this to the optimal allocation among three risky assets. The InvestingAgent developed in this chapter generates Sharpe ratios that consistently surpass those of individual risky ...

6. Algorithmic Trading

7. Dynamic Hedging

8. Dynamic Asset Allocation

9. Optimal Execution

10. Concluding Remarks
Published
Reading time
05:04
Book type
Subscription
Participants
1 readers
Last updated
Oct 14, 2026