Introduction¶
Stochastic optimal control (SOC) is the mathematical theory of making sequential decisions in systems whose state evolves stochastically over time. The agent observes the current state of the system, applies a control, and the system transitions to a new state according to a stochastic law. The goal is to choose a sequence of controls — a policy — that minimises an expected cumulative cost over a finite or infinite horizon. SOC extends classical optimal control theory, which addresses deterministic systems, to the regime where the state dynamics are driven by random processes such as the Wiener process introduced in chapter Stochastic Calculus.
The mathematical tools developed in this chapter provide the foundation for two distinct classes of trading problems addressed later in this book: optimal execution scheduling (chapter Optimal Execution Theory) and optimal market making (chapter Optimal Market Making). In the execution problem, the agent must liquidate an inventory at minimum expected cost while controlling timing risk; the state is the remaining inventory and the control is the trading rate. In the market making problem, the agent must quote bid and ask prices dynamically to maximise expected profit while managing inventory risk; the state is the inventory and the control is the spread quoted around the mid-price. Despite the different economic contexts, both problems share the same mathematical structure: a stochastic dynamical system, a cost functional, and a backward equation — the Bellman equation in discrete time, or the Hamilton–Jacobi–Bellman equation in continuous time — that determines the value of the optimal policy at each state and time.
The chapter is organised as follows. We begin with discrete-time dynamic programming (Dynamic programming in discrete time), which introduces Bellman’s principle of optimality and the backward induction algorithm in the simplest setting. We then extend to continuous-time control (The Hamilton–Jacobi–Bellman equation), where the state follows a stochastic differential equation and the optimal value function satisfies the Hamilton–Jacobi–Bellman (HJB) partial differential equation. We next present the variational approach (The variational approach), which simplifies the optimisation to an ordinary differential equation when the stochastic noise enters the cost functional only through the trajectory of the state — a structure that appears in the Almgren–Chriss model. Finally, we derive the Linear–Quadratic Stochastic Control (LQSC) framework (Linear–Quadratic Stochastic Control), which yields closed-form solutions via Riccati equations and is the method of choice for execution and market making problems with quadratic cost structures.
Dynamic programming in discrete time¶
Problem setup¶
We consider a system evolving over discrete time steps , where is the terminal time. At each step the system is in state and the agent selects a control from a feasible set that may depend on the current state. The state then transitions according to the dynamics
where is an exogenous random disturbance with known distribution that is independent of the past history of states and controls. Applying control in state incurs a running cost , and reaching terminal state incurs a terminal cost . The total cost of a sequence of controls is
This is a random variable because the state trajectory depends on the random disturbances . The objective is to find a policy , where maps states to controls, that minimises the expected total cost:
A policy of this form — mapping the state to a control at each step — is called a feedback or closed-loop policy. The key result of dynamic programming is that the optimal policy has exactly this feedback structure: the optimal action at each step depends only on the current state, not on the full history of states and controls.
Bellman’s principle of optimality¶
The core insight behind dynamic programming is Bellman’s principle of optimality: the tail of an optimal policy is itself optimal. Formally, if is an optimal policy, then for any intermediate time and any state reachable under the optimal policy, is an optimal policy for the sub-problem starting at time in state .
This principle justifies decomposing the global optimisation into a sequence of local optimisations, solved backwards from the terminal time.
The Bellman equation¶
Define the value function as the minimum expected cost achievable from state at time :
The terminal value function is simply the terminal cost: .
By the principle of optimality, applying the optimal first action and then following the optimal policy from the resulting state gives:
with . This is the Bellman equation (or dynamic programming equation). It reduces the optimisation over sequences of controls into a sequence of single-step optimisations, each requiring only the value function at the next step. The optimal policy at step is recovered from the minimiser:
Backward induction algorithm¶
The Bellman equation defines a backward induction algorithm for computing the optimal value function and policy:
Initialise: set for all states .
For :
For each state , compute:
Record the minimiser as .
The algorithm sweeps backwards from the terminal time, propagating value information from the future into the current decision. Once all and are computed, the optimal forward trajectory is obtained by simulating the system under from .
The feasibility of the algorithm depends on the structure of the problem. When is finite and small, the expectation and minimisation can be computed explicitly. When is continuous, the value function is defined over an uncountable domain, and special structure must be exploited to obtain tractable solutions. The LQSC framework in Linear–Quadratic Stochastic Control provides one such tractable case.
Example: discrete inventory liquidation¶
Consider a trader who must sell shares over time periods. Let the state be the remaining inventory and the control be the number of shares sold in period : . The inventory dynamics are (deterministic, no noise). The price in period is and the execution price is (linear temporary impact). Suppose the price evolves as with i.i.d. zero-mean noise.
The total proceeds are , and we impose the constraint (all shares must be sold). The expected total proceeds are:
Since prices follow a martingale () and the inventory is determined by prior decisions, this problem has quadratic structure. Bertsimas and Lo Bertsimas & Lo, 1998 show that the optimal policy under this formulation distributes the remaining inventory equally at each step: , recovering the TWAP schedule. The value function is quadratic in the state, a structure that carries over to the continuous-time case and the LQSC framework.
The Hamilton–Jacobi–Bellman equation¶
From discrete to continuous time¶
The discrete-time Bellman equation can be extended to continuous time by taking the step size . Consider the state dynamics
where is a standard Wiener process (see chapter Stochastic Calculus), and the running cost is incurred continuously. The state is , the control is , and the drift is allowed to depend on the control while the volatility does not (for simplicity; this restriction can be relaxed). The value function is defined as:
and satisfies . We seek the partial differential equation (PDE) that satisfies for .
HJB derivation¶
Applying the Bellman principle over the short interval :
Using Ito’s lemma (chapter Stochastic Calculus, Paragraph) to expand :
Taking expectations and using and :
Substituting back into the Bellman equation and rearranging:
with terminal condition . This is the Hamilton–Jacobi–Bellman (HJB) equation. It is a nonlinear PDE running backwards in time from the terminal condition. The optimal control is the minimiser of the right-hand side at each :
Once the HJB PDE is solved for and the optimal control is obtained in feedback form, the optimal policy generates the optimal state trajectory by forward simulation under .
For multivariate states driven by a multivariate Wiener process , with dynamics , the HJB equation generalises to:
where is the gradient vector and is the Hessian matrix of with respect to .
Terminal conditions and boundary conditions¶
The HJB equation is solved backwards from the terminal condition , which encodes the terminal cost at the end of the horizon. For execution problems, the most common terminal cost is a large penalty for failing to liquidate the full position:
which forces in the limit. The terminal condition thus encodes the hard constraint that the position must be closed at the end of the trading horizon. In practice, a large but finite corresponds to the cost of liquidating any residual at market at time .
Connection to the Feynman–Kac theorem¶
Once the optimal control is substituted back into the HJB equation, the resulting PDE is linear in and takes the form covered by the Feynman–Kac theorem (chapter Stochastic Calculus, section The Feynman - Kac Theorem):
where and are the optimal drift and cost. The Feynman–Kac theorem then identifies with the expected discounted cost under the optimal dynamics:
This confirms the probabilistic interpretation of the value function and provides a Monte Carlo method for computing numerically when the PDE is not analytically tractable.
The variational approach¶
Calculus of variations¶
The calculus of variations studies functionals — real-valued functions whose argument is itself a function — and asks: for what function is a given functional minimised or maximised? In the control problems of interest, the functional is the expected total cost and the unknown is the trajectory of the state variable.
Consider minimising the functional
over smooth trajectories subject to fixed boundary conditions and . The integrand is called the Lagrangian. The trajectory that extremises satisfies the Euler–Lagrange equation:
This is a second-order ordinary differential equation for , solved subject to the two boundary conditions.
The variational approach applies directly to stochastic optimal control problems in which the noise enters the cost functional only through the trajectory of the state — not through the control variable itself. This occurs in the Almgren–Chriss model, where:
the expected implementation shortfall depends deterministically on the trajectory ,
the variance of implementation shortfall depends deterministically on ,
the mean–variance objective is therefore a deterministic functional of the state trajectory.
In such cases, the stochastic optimisation reduces to a deterministic variational problem.
Euler–Lagrange equation for execution¶
In the Almgren–Chriss model (derived in detail in chapter Optimal Execution Theory), the Lagrangian takes the form
where is the temporary market impact coefficient, is the price volatility, and is the risk-aversion parameter. The Euler–Lagrange equation gives:
equivalently,
This is a second-order linear ODE with constant coefficients. The general solution is:
where and are determined by the boundary conditions (initial inventory) and (complete liquidation). This yields the unique optimal trajectory:
The parameter controls the shape of the trajectory: for (risk-neutral, ), the trajectory reduces to a linear decrease — the TWAP schedule. For large (highly risk-averse), the trajectory front-loads aggressively, liquidating most of the position early and leaving only a small residual towards the end.
Hyperbolic solution structure¶
The hyperbolic sine and cosine functions that appear in the solution have a natural interpretation. Define the half-life as the characteristic time over which the optimal strategy departs significantly from the risk-neutral uniform schedule. For (short horizon relative to the risk-aversion scale), the solution is approximately linear: . For , the solution approximates an exponential decay in the early portion, then abruptly falls to zero near .
The trading rate is
This is a decreasing function of time: the optimal strategy sells most aggressively at time and slows down as the horizon approaches — front-loading to reduce exposure to price risk from holding a large unexecuted inventory, at the cost of higher early market impact.
Linear–Quadratic Stochastic Control¶
Problem setup¶
Linear–Quadratic Stochastic Control (LQSC) is a class of stochastic control problems in which:
the state dynamics are linear in the state and control,
the cost functional is quadratic in the state and control,
the noise is Gaussian (additive, independent of state and control).
These three properties together guarantee that the value function is quadratic in the state, the optimal control is affine (linear plus a constant) in the state, and the optimal gains satisfy a backwards Riccati equation — a system of ODEs or recursions that can be solved analytically or efficiently numerically.
In discrete time, the LQSC problem is:
subject to the linear dynamics
where is the state, is the control, is a Gaussian disturbance independent of and , , , , , and .
The quadratic value function ansatz¶
The key observation is that the Bellman equation preserves the quadratic structure of the value function. We postulate:
and verify that this form is consistent with the Bellman equation. Substituting the ansatz into the Bellman equation and minimising over (which is unconstrained for simplicity):
The minimand is:
Taking the derivative with respect to and setting to zero:
Solving for the optimal control:
where
The optimal control is affine in the state: a linear feedback term plus a constant correction . The feedback gain depends only on the matrices of the problem, not on the realisation of noise.
Riccati equations¶
Substituting the optimal control back into the Bellman equation yields recursions for the coefficients , , , which are the matrix Riccati equations:
with terminal conditions and given. The noise term contributes only to the scalar , not to or : this is the certainty equivalence property of LQSC — the optimal feedback gains are identical to those of the deterministic version of the problem (obtained by setting ), and noise only increases the expected cost.
The computational cost of the Riccati recursion is (matrix inversions at each of steps for -dimensional state), which is tractable for the problem sizes arising in execution (state dimension 2–4, horizon = 20–400 time bins).
Scalar LQSC: the Riccati recursion in closed form¶
For the scalar case (, , , , ), the Riccati recursion simplifies to:
This can be written as:
which is a scalar nonlinear recursion that can be evaluated numerically with as the terminal condition. For the stationary case (, , , constant), the recursion converges as to the fixed point of the algebraic Riccati equation .
Continuous-time LQSC¶
In continuous time, the LQSC problem is:
subject to . The HJB equation is:
with terminal condition (matrix-valued). This is the continuous-time matrix Riccati ODE. The optimal control is — a linear feedback policy with time-varying gain . The certainty-equivalence property holds: the Riccati ODE does not depend on the noise covariance , which affects only the expected cost, not the optimal gains.
Structured extensions for execution problems¶
Both the VWAP execution problem and the market making problem introduce additional structure: the state vector includes not only the inventory but also a stochastic auxiliary state (the cumulative market volume for VWAP, or the asset price for market making) that is not directly controlled. The LQSC framework handles this naturally by extending the state vector and setting the corresponding control gain to zero.
More precisely, in the VWAP problem (chapter Optimal Execution Theory), the state is where is the cumulative order executed and is the cumulative market volume. The market volume evolves stochastically and independently of the control (shares executed in bin ). The Riccati recursion then produces gains where governs feedback on the execution shortfall and governs adaptation to observed volume. This adaptive structure is what makes the dynamic VWAP strategy superior to its static counterpart.
Exercises¶
Consider a one-dimensional control problem with dynamics (deterministic), cost , and terminal cost with (complete liquidation). Apply the LQSC backward recursion to find the optimal control for steps and . Verify that the result is the equal-slicing TWAP schedule.
Derive the Euler–Lagrange equation for the Lagrangian , where and are positive functions of time. Show that the resulting ODE reduces to the Almgren–Chriss equation when and are constants.
Consider the HJB equation for a one-dimensional stochastic control problem with , running cost and terminal cost . Postulate and derive the ODEs for and by substituting into the HJB equation. Solve for and identify the optimal feedback control .
In the LQSC framework with scalar state, let , , , , and terminal condition . Write the Riccati recursion and solve it exactly for and . What is the optimal control in each case given ?
Explain why the certainty-equivalence principle holds in LQSC: the optimal feedback gains are the same as in the deterministic version of the problem, regardless of the noise level . What structural property of the problem — linearity of dynamics, quadratic cost, Gaussian noise — is responsible for this? Would certainty equivalence still hold if the cost function were instead of ?
Write the HJB equation for the following problem: a market maker holds inventory and quotes a spread of around the mid-price . Trades arrive from clients at a Poisson rate (decreasing in ), and each trade changes the inventory by . The price follows a Brownian motion with volatility . The market maker maximises expected profit where is an inventory penalty. Identify the state variables, the control, and the structure of the HJB equation, without solving it. (This problem is treated in chapter Optimal Market Making.)
- Bertsimas, D., & Lo, A. W. (1998). Optimal control of execution costs. Journal of Financial Markets, 1(1), 1–50.