  Optimal execution is an important problem faced by any trader. Most solutions
are based on the assumption of constant market impact, while liquidity is known
to be dynamic. Moreover, models with time-varying liquidity typically assume
that it is observable, despite the fact that, in reality, it is latent and hard
to measure in real time. In this paper we show that the use of Double Deep
Q-learning, a form of Reinforcement Learning based on neural networks, is able
to learn optimal trading policies when liquidity is time-varying. Specifically,
we consider an Almgren-Chriss framework with temporary and permanent impact
parameters following several deterministic and stochastic dynamics. Using
extensive numerical experiments, we show that the trained algorithm learns the
optimal policy when the analytical solution is available, and overcomes
benchmarks and approximated solutions when the solution is not available.
