# Optimal stopping

In mathematics, the theory of optimal stopping or early stopping is concerned with the problem of choosing a time to take a particular action, in order to maximise an expected reward or minimise an expected cost. Optimal stopping problems can be found in areas of statistics, economics, and mathematical finance (related to the pricing of American options). A key example of an optimal stopping problem is the secretary problem. Optimal stopping problems can often be written in the form of a Bellman equation, and are therefore often solved using dynamic programming.

## Definition
### Discrete time case

Stopping rule problems are associated with two objects:
* A sequence of random variables $X_{1},X_{2},\ldots$, whose joint distribution is something assumed to be known
* A sequence of 'reward' functions $(y_{i})_{i\geq 1}$ which depend on the observed values of the random variables in 1:
    $y_{i}=y_{i}(x_{1},\ldots ,x_{i})$
Given those objects, the problem is as follows:
* You are observing the sequence of random variables, and at each step $i$, you can choose to either stop observing or continue
* If you stop observing at step $i$, you will receive reward $y_{i}$
* You want to choose a stopping rule to maximize your expected reward (or equivalently, minimize your expected loss)

### Continuous time case

Consider a gain process $G=(G_{t})_{t\geq 0}$ defined on a filtered probability space $(\Omega ,{\mathcal {F}},({\mathcal {F}}_{t})_{t\geq 0},\mathbb {P} )$ and assume that $G$ is adapted to the filtration. The optimal stopping problem is to find the stopping time $\tau ^{*}$ which maximizes the expected gain
    $V_{t}^{T}=\mathbb {E} G_{\tau ^{*}}=\sup _{t\leq \tau \leq T}\mathbb {E} G_{\tau }$
where $V_{t}^{T}$ is called the value function. Here $T$ can take value $\infty$.
A more specific formulation is as follows. We consider an adapted strong Markov process $X=(X_{t})_{t\geq 0}$ defined on a filtered probability space $(\Omega ,{\mathcal {F}},({\mathcal {F}}_{t})_{t\geq 0},\mathbb {P} _{x})$ where $\mathbb {P} _{x}$ denotes the probability measure where the stochastic process starts at $x$. Given continuous functions $M,L$, and $K$, the optimal stopping problem is
    $V(x)=\sup _{0\leq \tau \leq T}\mathbb {E} _{x}\left(M(X_{\tau })+\int _{0}^{\tau }L(X_{t})dt+\sup _{0\leq t\leq \tau }K(X_{t})\right).$
This is sometimes called the MLS (which stand for Mayer, Lagrange, and supremum, respectively) formulation.

## Solution methods

There are generally two approaches to solving optimal stopping problems. When the underlying process (or the gain process) is described by its unconditional finite-dimensional distributions, the appropriate solution technique is the martingale approach, so called because it uses martingale theory, the most important concept being the Snell envelope. In the discrete time case, if the planning horizon $T$ is finite, the problem can also be easily solved by dynamic programming.
When the underlying process is determined by a family of (conditional) transition functions leading to a Markov family of transition probabilities, powerful analytical tools provided by the theory of Markov processes can often be utilized and this approach is referred to as the Markov method. The solution is usually obtained by solving the associated free-boundary problems (Stefan problems).

## A jump diffusion result

Let $Y_{t}$ be a Lévy diffusion in $\mathbb {R} ^{k}$ given by the SDE
    $dY_{t}=b(Y_{t})dt+\sigma (Y_{t})dB_{t}+\int _{\mathbb {R} ^{k}}\gamma (Y_{t-},z){\bar {N}}(dt,dz),\quad Y_{0}=y$
where $B$ is an $m$-dimensional Brownian motion, ${\bar {N}}$ is an $l$-dimensional compensated Poisson random measure, $b:\mathbb {R} ^{k}\to \mathbb {R} ^{k}$, $\sigma :\mathbb {R} ^{k}\to \mathbb {R} ^{k\times m}$, and $\gamma :\mathbb {R} ^{k}\times \mathbb {R} ^{k}\to \mathbb {R} ^{k\times l}$ are given functions such that a unique solution $(Y_{t})$ exists. Let ${\mathcal {S}}\subset \mathbb {R} ^{k}$ be an open set (the solvency region) and
    $\tau _{\mathcal {S}}=\inf\{t>0:Y_{t}\notin {\mathcal {S}}\}$
be the bankruptcy time. The optimal stopping problem is:
    $V(y)=\sup _{\tau \leq \tau _{\mathcal {S}}}J^{\tau }(y)=\sup _{\tau \leq \tau _{\mathcal {S}}}\mathbb {E} _{y}\left[M(Y_{\tau })+\int _{0}^{\tau }L(Y_{t})dt\right].$
It turns out that under some regularity conditions, the following verification theorem holds:
If a function $\phi :{\bar {\mathcal {S}}}\to \mathbb {R}$ satisfies
* $\phi \in C({\bar {\mathcal {S}}})\cap C^{1}({\mathcal {S}})\cap C^{2}({\mathcal {S}}\setminus \partial D)$ where the continuation region is $D=\{y\in {\mathcal {S}}:\phi (y)>M(y)\}$,
* $\phi \geq M$ on ${\mathcal {S}}$, and
* ${\mathcal {A}}\phi +L\leq 0$ on ${\mathcal {S}}\setminus \partial D$, where ${\mathcal {A}}$ is the infinitesimal generator of $(Y_{t})$
then $\phi (y)\geq V(y)$ for all $y\in {\bar {\mathcal {S}}}$. Moreover, if
* ${\mathcal {A}}\phi +L=0$ on $D$
Then $\phi (y)=V(y)$ for all $y\in {\bar {\mathcal {S}}}$ and $\tau ^{*}=\inf\{t>0:Y_{t}\notin D\}$ is an optimal stopping time.
These conditions can also be written is a more compact form (the integro-variational inequality):
* $\max \left\{{\mathcal {A}}\phi +L,M-\phi \right\}=0$ on ${\mathcal {S}}\setminus \partial D.$

## Examples
### Coin tossing

(Example where $\mathbb {E} (y_{i})$ converges)
You have a fair coin and are repeatedly tossing it. Each time, before it is tossed, you can choose to stop tossing it and get paid (in dollars, say) the average number of heads observed.
You wish to maximise the amount you get paid by choosing a stopping rule. If X$_i$ (for i ≥ 1) forms a sequence of independent, identically distributed random variables with Bernoulli distribution
    ${\text{Bern}}\left({\frac {1}{2}}\right),$
and if
    $y_{i}={\frac {1}{i}}\sum _{k=1}^{i}X_{k}$
then the sequences $(X_{i})_{i\geq 1}$, and $(y_{i})_{i\geq 1}$ are the objects associated with this problem.

### House selling

(Example where $\mathbb {E} (y_{i})$ does not necessarily converge)
You have a house and wish to sell it. Each day you are offered $X_{n}$ for your house, and pay $k$ to continue advertising it. If you sell your house on day $n$, you will earn $y_{n}$, where $y_{n}=(X_{n}-nk)$.
You wish to maximise the amount you earn by choosing a stopping rule.
In this example, the sequence ($X_{i}$) is the sequence of offers for your house, and the sequence of reward functions is how much you will earn.

### Secretary problem

(Example where $(X_{i})$ is a finite sequence)
You are observing a sequence of objects which can be ranked from best to worst. You wish to choose a stopping rule which maximises your chance of picking the best object.
Here, if $R_{1},\ldots ,R_{n}$ (n is some large number) are the ranks of the objects, and $y_{i}$ is the chance you pick the best object if you stop intentionally rejecting objects at step i, then $(R_{i})$ and $(y_{i})$ are the sequences associated with this problem. This problem was solved in the early 1960s by several people. An elegant solution to the secretary problem and several modifications of this problem is provided by the more recent odds algorithm of optimal stopping (Bruss algorithm).

### Search theory

Economists have studied a number of optimal stopping problems similar to the 'secretary problem', and typically call this type of analysis 'search theory'. Search theory has especially focused on a worker's search for a high-wage job, or a consumer's search for a low-priced good.

### Parking problem

A special example of an application of search theory is the task of optimal selection of parking space by a driver going to the opera (theater, shopping, etc.). Approaching the destination, the driver goes down the street along which there are parking spaces – usually, only some places in the parking lot are free. The goal is clearly visible, so the distance from the target is easily assessed. The driver's task is to choose a free parking space as close to the destination as possible without turning around so that the distance from this place to the destination is the shortest.

### Option trading

In the trading of options on financial markets, the holder of an American option is allowed to exercise the right to buy (or sell) the underlying asset at a predetermined price at any time before or at the expiry date. Therefore, the valuation of American options is essentially an optimal stopping problem. Consider a classical Black–Scholes set-up and let $r$ be the risk-free interest rate and $\delta$ and $\sigma$ be the dividend rate and volatility of the stock. The stock price $S$ follows geometric Brownian motion
    $S_{t}=S_{0}\exp \left\{\left(r-\delta -{\frac {\sigma ^{2}}{2}}\right)t+\sigma B_{t}\right\}$
under the risk-neutral measure.
When the option is perpetual, the optimal stopping problem is
    $V(x)=\sup _{\tau }\mathbb {E} _{x}\left[e^{-r\tau }g(S_{\tau })\right]$
where the payoff function is $g(x)=(x-K)^{+}$ for a call option and $g(x)=(K-x)^{+}$ for a put option. The variational inequality is
    $\max \left\{{\frac {1}{2}}\sigma ^{2}x^{2}V''(x)+(r-\delta )xV'(x)-rV(x),g(x)-V(x)\right\}=0$
for all $x\in (0,\infty )\setminus \{b\}$ where $b$ is the exercise boundary. The solution is known to be
* (Perpetual call) $V(x)={\begin{cases}(b-K)(x/b)^{\gamma }&x\in (0,b)\\x-K&x\in [b,\infty )\end{cases}}$ where $\gamma =({\sqrt {\nu ^{2}+2r}}-\nu )/\sigma$ and $\nu =(r-\delta )/\sigma -\sigma /2,\quad b=\gamma K/(\gamma -1).$
* (Perpetual put) $V(x)={\begin{cases}K-x&x\in (0,c]\\(K-c)(x/c)^{\tilde {\gamma }}&x\in (c,\infty )\end{cases}}$ where ${\tilde {\gamma }}=-({\sqrt {\nu ^{2}+2r}}+\nu )/\sigma$ and $\nu =(r-\delta )/\sigma -\sigma /2,\quad c={\tilde {\gamma }}K/({\tilde {\gamma }}-1).$
On the other hand, when the expiry date is finite, the problem is associated with a 2-dimensional free-boundary problem with no known closed-form solution. Various numerical methods can, however, be used. See Black–Scholes model#American options for various valuation methods here, as well as Fugit for a discrete, tree based, calculation of the optimal time to exercise.