# Pairs Trading: An Optimal Selling Rule with Constraints

R. Liu School of Mathematics and Statistics, University of Sydney, Sydney, NSW
2006, Australia, E-mail<EMAIL_ADDRESS>J. Tie Department of
Mathematics, University of Georgia, Athens, GA 30602, USA, E-mail:
<EMAIL_ADDRESS>Z. Wu School of Mathematics, Shandong University, Jinan 250100,
P.R. China, E-mail<EMAIL_ADDRESS> Q. Zhang Department of Mathematics,
University of Georgia, Athens, GA 30602, USA, E-mail<EMAIL_ADDRESS>
###### Abstract

The focus of this paper is on identifying the most effective selling strategy
for pairs trading of stocks. In pairs trading, a long position is held in one
stock while a short position is held in another. The goal is to determine the
optimal time to sell the long position and repurchase the short position in
order to close the pairs position. The paper presents an optimal pairs-trading
selling rule with trading constraints. In particular, the underlying stock
prices evolve according to a two dimensional geometric Brownian motion and the
trading permission process is given in terms of a two-state $\\{$trading
allowed, trading not allowed$\\}$ Markov chain. It is shown that the optimal
policy can be determined by a threshold curve which is obtained by solving the
associated HJB equations (quasi-variational inequalities). A closed form
solution is obtained. A verification theorem is provided. Numerical
experiments are also reported to demonstrate the optimal policies and value
functions.

Key words: pairs trading, trading constraints, markov chain, quasi-variational
inequalities

##  1 Introduction

Pairs trading involves the simultaneous trading of two stocks as a pair.
Typically, a pairs position involves taking a long position in one stock and a
short position in the other. The focus of this paper is on determining the
optimal timing for closing an existing pairs position. Specifically, we aim to
identify the most effective strategy for folding the position and exiting the
market.

Pairs trading is closely related to the timing of the optimal investments
studied in McDonald and Siegel [9]. In particular, they considered the optimal
timing of investment in an irreversible project. Two main variables in their
model are the value of the project and the cost of investing. They
demonstrated one should defer the investment until the present value of the
benefits from the project exceed the investment cost by a certain margin. They
transfer the control problem in selecting the optimal trading time to the one
of determining the optimal value in space. Further studies along this line
were carried out by Hu and Øksendal [7] to specify precise optimality
conditions and to provide new proof of the following variational inequalities
among others. Their results can be easily interpreted in terms of the pairs-
trade selling rule when treating the project value as the long position and
investment cost as the short position.

In this paper, we extend these results to incorporate markets with Markov
trading constraints. In particular, a sequence of trading windows is imposed.
One can only buy/sell stocks when the windows are open. We focus on a simple
and easily implementable strategy, and its optimality and the sufficient
conditions for a closed-form solution.

Mathematical trading rules have been studied extensively in the literature,
and various approaches have been proposed to determine optimal trading
strategies. Zhang [16] considers a selling rule that involves two threshold
levels, a target price, and a stop-loss limit, and aims to find the optimal
threshold levels that maximize the expected profit. To achieve this, Zhang
solves a set of two-point boundary value problems, which are a type of
differential equation with conditions specified at two endpoints. The
resulting optimal threshold levels can then be used to construct a profitable
trading strategy. In [6], Guo and Zhang study the optimal selling rule under a
model with switching Geometric Brownian motion, which is a type of stochastic
process commonly used to model asset prices. To determine the optimal
threshold levels, they use a smooth-fit technique that involves solving a set
of algebraic equations. This approach allows them to obtain explicit
expressions for the threshold levels, which can be used to design a profitable
trading strategy. Dai et al. [1] proposed a trend-following rule based on a
conditional probability indicator. They showed that the optimal trading rule
can be determined by solving the associated Hamilton-Jacobi-Bellman equations,
which are a type of partial differential equation commonly used in finance.
Iwarere and Barmish [8] developed a similar idea using a confidence interval
approach, while Merhi and Zervos [11] studied an investment capacity
expansion/reduction problem using dynamic programming under a geometric
Brownian motion market model. In the context of mean reversion trading, Zhang
and Zhang [17] obtained a buy-low and sell-high policy by characterizing the
’low’ and ’high’ levels in terms of mean reversion parameters. Song and Zhang
[13] studied pairs trading under a mean reversion model. It is shown that the
optimal trading rule can be determined by threshold levels that can be
obtained by solving a set of algebraic equations. A set of sufficient
conditions are also provided to establish the desired optimality. Deshpande
and Barmish [2] developed a control-theoretic approach to pairs trading that
relaxes the requirement for spread functions. They demonstrated that their
trading algorithm generates positive expected returns. Other pairs trading
methods can be found in Elliott et al. [4] and Whistler [15]. More recently,
Tie et al. [14] proposed an optimal pairs trading rule aimed at maximizing a
discounted payoff function by sequentially initiating and closing positions of
the pair. Using a dynamic programming approach under a geometric Brownian
motion model, they showed that buying and selling decisions can be determined
by two threshold curves in closed form. They also proved the optimality of
their trading strategy.

Studies of trading rules with trading constraints are important from
application point of view. Market liquidity is one of the causes of limited
trading windows. Poor liquidity restricts one’s ability to trade freely. Such
trading conditions have greater impacts on small cap stocks. It affects even
more on pairs trading because both buying and selling have to executed all
together. Mathematical treatment on trading constraints can be found in Dupuis
and Wang [3] in which they used a Poisson process to capture permissible
trading moments. They obtained a closed form solution under a one-dimensional
geometric Brownian motion. Further studies can be found in Menaldi and Robin
[10]. They treated related optimal stopping with a class of general Markov-
Feller processes and focused on theoretical characterizations of optimal
stopping.

In this paper, we consider a pairs selling rule under a two-dimensional
geometric Brownian motion with trading constraints. We model the sequence of
trading windows in terms of a two-state Markov chain. One can only buy/sell
stocks when the trading windows are open. We focus on such constrained optimal
stopping. We generalize the results of Hu and Oksendal [7] by imposing trading
constraints. We show that the optimal selling rule can be determined by a
single threshold curve. We also establish sufficient conditions that guarantee
the optimality of the selling policy. In addition, we report our numerical
experiments to demonstrate our results.

This paper is organized as follows. In §2, we formulate the pairs trading
problem under consideration. In §3, we study the associated HJB equations and
their solutions. In §4, we provide a verification theorem that guarantee the
optimality of our selling rule. In §5, we consider asymptotic properties of
the trading switching policies as the trading constraint jump rates go to
infinity. Numerical examples are given in §6. Some concluding remarks are
given in §7. We postpone the proof of lemma 3.1 to the appendix.

##  2 Problem Formulation

Our pairs trading involves two stocks: ${\mathbf{S}}^{1}$ and
${\mathbf{S}}^{2}$. Let $\\{X^{1}_{t},t\geq 0\\}$ denote the prices of stock
${\mathbf{S}}^{1}$ and $\\{X^{2}_{t},t\geq 0\\}$ that of stock
${\mathbf{S}}^{2}$. They satisfy the following stochastic differential
equation:

$d\left(\\!\\!\begin{array}[]{c}X^{1}_{t}\\\ X^{2}_{t}\\\
\end{array}\\!\\!\right)=\left(\\!\\!\begin{array}[]{cc}X^{1}_{t}&\\\
&X^{2}_{t}\\\
\end{array}\\!\\!\right)\left[\left(\\!\\!\begin{array}[]{c}\mu_{1}\\\
\mu_{2}\\\
\end{array}\\!\\!\right)dt+\left(\\!\\!\begin{array}[]{cc}\sigma_{11}&\sigma_{12}\\\
\sigma_{21}&\sigma_{22}\\\
\end{array}\\!\\!\right)d\left(\\!\\!\begin{array}[]{c}W^{1}_{t}\\\
W^{2}_{t}\\\ \end{array}\\!\\!\right)\right],$ (1)

where $\mu_{i}$, $i=1,2$, are the return rates, $\sigma_{ij}$, $i,j=1,2$, the
volatility constants, and $(W^{1}_{t},W^{2}_{t})$ a 2-dimensional standard
Brownian motion.

The liquidity process $\alpha_{t}$ is assumed to be a two-state Markov chain
with state space ${\mathcal{M}}=\\{0,1\\}$. We impose the following trading
constraint: One can only buy/sell stocks when $\alpha_{t}=1$. Let $Q$ be the
generator of $\alpha_{t}$ given by
$Q=\left(\begin{array}[]{cc}-\lambda_{0}&\lambda_{0}\\\\[-3.61371pt]
\lambda_{1}&-\lambda_{1}\\\ \end{array}\right)$, with $\lambda_{0}>0$ and
$\lambda_{1}>0$. We assume $\alpha_{t}$ and $(W^{1}_{t},W^{2}_{t})$ are
independent.

In this paper, we consider a pairs selling rule. We assume the corresponding
pair’s position consists of a one-share long position in stock
${\mathbf{S}}^{1}$ and a one-share short position in stock ${\mathbf{S}}^{2}$.
This condition can be easily relaxed; see Tie et al. [14] for details. The
problem is to determine an optimal stopping time $\tau$ (subject to trading
constraints) to fold the pairs position by selling ${\mathbf{S}}^{1}$ and
buying back ${\mathbf{S}}^{2}$.

Let $K$ denote the transaction cost percentage (e.g., slippage and/or
commission) associated with stock transactions. For example, the proceeds to
close the pairs position at $t$ is $(1-K)X^{1}_{t}-(1+K)X^{2}_{t}$. For ease
of notation, let $\beta_{\rm b}=1+K$ and $\beta_{\rm s}=1-K$.

Let ${\mathcal{F}}_{t}=\sigma\\{(X^{1}_{r},X^{2}_{r},\alpha_{r}):\ r\leq
t\\}$. We consider admissible stopping times ${\mathcal{S}}=\\{\tau:\
{\mathcal{F}}_{t}\mbox{ stopping times such that }\tau<\infty\mbox{ only when
}\alpha_{\tau}=1\\}$.

Given the initial state $(x_{1},x_{2})$, $\alpha=0,1$, and the admissible
selling time $\tau$, the corresponding reward function

$J(x_{1},x_{2},\alpha,\tau)=E\big{[}e^{-\rho\tau}(\beta_{\rm
s}X^{1}_{\tau}-\beta_{\rm b}X^{2}_{\tau})\big{]},$ (2)

where $\rho>0$ is a given discount factor.

The problem is to find an admissible stopping time $\tau$ to maximize $J$. Let
$V_{\alpha}(x_{1},x_{2})$ denote the corresponding value function:

$V_{\alpha}(x_{1},x_{2})=\sup_{\tau}J(x_{1},x_{2},\alpha,\tau).$ (3)

We impose the following conditions throughout this paper.

(A1) $\rho>\mu_{1}$ and $\rho>\mu_{2}$.

Under these conditions, we have the lower and upper bounds for $V$:

$-\beta_{\rm b}x_{2}\leq V_{\alpha}(x_{1},x_{2})\leq\beta_{\rm s}x_{1}.$ (4)

Actually, for any $\tau\in{\mathcal{S}}$, we have $-\beta_{\rm
b}E\big{[}e^{-\rho\tau}X^{2}_{\tau}\big{]}\leq
J(x_{1},x_{2},\alpha,\tau)\leq\beta_{\rm
s}E\big{[}e^{-\rho\tau}X^{1}_{\tau}\big{]}$. The rest follows from Dynkin’s
formula

$E[e^{-\rho\tau}X^{j}_{\tau}]=\left(x_{j}+E\int_{0}^{\tau}e^{-\rho
t}X^{j}_{t}(-\rho+\mu_{j})dt\right)\leq x_{j},\mbox{ for }j=1,2.$

In addition, in view of the value function definition, we have

$V_{1}(x_{1},x_{2})\geq J(x_{1},x_{2},1,\tau)|_{\tau=0}=\beta_{\rm
s}x_{1}-\beta_{\rm b}x_{2}.$

##  3 HJB Equations

In this paper, we follow the dynamic programming approach and study the
associated HJB equations. Let

${\mathcal{A}}=\frac{1}{2}\left\\{a_{11}x_{1}^{2}\frac{\partial^{2}}{\partial
x_{1}^{2}}+2a_{12}x_{1}x_{2}\frac{\partial^{2}}{\partial x_{1}\partial
x_{2}}+a_{22}x_{2}^{2}\frac{\partial^{2}}{\partial
x_{2}^{2}}\right\\}+\mu_{1}x_{1}\frac{\partial}{\partial
x_{1}}+\mu_{2}x_{2}\frac{\partial}{\partial x_{2}},$

where $a_{11}=\sigma^{2}_{11}+\sigma^{2}_{12},\
a_{12}=\sigma_{11}\sigma_{21}+\sigma_{12}\sigma_{22},\mbox{ and
}a_{22}=\sigma^{2}_{21}+\sigma^{2}_{22}$. The associated HJB equations have
the form: For $x_{1},x_{2}>0$,

$\left\\{\begin{array}[]{l}[(\rho+\lambda_{0})-{\mathcal{A}}]v_{0}(x_{1},x_{2})=\lambda_{0}v_{1}(x_{1},x_{2}),\\\
\min\Big{\\{}[\rho+\lambda_{1})-{\mathcal{A}}]v_{1}(x_{1},x_{2})-\lambda_{1}v_{0}(x_{1},x_{2}),\
v_{1}(x_{1},x_{2})-\beta_{\rm s}x_{1}+\beta_{\rm b}x_{2}\Big{\\}}=0.\\\
\end{array}\right.$ (5)

To solve the above HJB equations, we first convert them into single variable
equations. Let $y=x_{2}/x_{1}$ and
$v_{i}(x_{1},x_{2})=x_{1}w_{i}(x_{2}/x_{1})$, for some function $w_{i}(y)$ and
$i=0,1$. Then we have by direct calculation that

$\begin{array}[]{l}\displaystyle\frac{\partial v_{i}}{\partial
x_{1}}=w_{i}(y)-yw^{\prime}_{i}(y),\ \frac{\partial v_{i}}{\partial
x_{2}}=w^{\prime}_{i}(y),\\\ \displaystyle\frac{\partial^{2}v_{i}}{\partial
x_{1}^{2}}=\frac{y^{2}w^{\prime\prime}_{i}(y)}{x_{1}},\
\frac{\partial^{2}v_{i}}{\partial
x^{2}_{2}}=\frac{w^{\prime\prime}_{i}(y)}{x_{1}},\mbox{ and
}\frac{\partial^{2}v_{1}}{\partial x_{1}\partial
x_{2}}=-\frac{yw^{\prime\prime}_{i}(y)}{x_{1}}.\end{array}$

Write ${\mathcal{A}}v_{i}$ in terms of $w_{i}$ to obtain

${\mathcal{A}}v_{i}=x_{1}\left\\{\frac{1}{2}\left[a_{11}-2a_{12}+a_{22}\right]y^{2}w^{\prime\prime}_{i}(y)+(\mu_{2}-\mu_{1})yw^{\prime}_{i}(y)+\mu_{1}w_{i}(y)\right\\}.$

Then, the HJB equations can be given in terms of $y$ and $w_{i}$ as follows:

$\left\\{\begin{array}[]{l}[(\rho+\lambda_{0})-{\mathcal{L}}]w_{0}(y)=\lambda_{0}w_{1}(y),\\\
\min\Big{\\{}[(\rho+\lambda_{1})-{\mathcal{L}}]w_{1}(y)-\lambda_{1}w_{0}(y),\
w_{1}(y)-\beta_{\rm s}+\beta_{\rm b}y\Big{\\}}=0,\\\ \end{array}\right.$ (6)

where

${\mathcal{L}}[w_{i}(y)]=\sigma
y^{2}w^{\prime\prime}_{i}(y)+(\mu_{2}-\mu_{1})yw^{\prime}_{i}(y)+\mu_{1}w_{i}(y),$

with $\sigma=({a_{11}-2a_{12}+a_{22}})/{2}\geq 0$. We only consider the case
when $\sigma\not=0$. If $\sigma=0$, the problem reduces to a first-order case
and can be treated in a similar way.

### Solution of the HJB Equation

Intuitively, one should close the pairs position when $X^{1}_{t}$ is large and
$X^{2}_{t}$ is small. Namely, we expect a threshold $k$ so that the pairs
position is to be closed when $y=x_{2}/x_{1}\leq k$. In view of this, we focus
on searching for such $k$ so that the second equation in (6) has the form
$w_{1}(y)=\beta_{\rm s}-\beta_{\rm b}y$, for $y\in(0,k)$; and
$[(\rho+\lambda_{1})-{\mathcal{L}}]w_{1}(y)=\lambda_{1}w_{0}(y)$, for
$y\in(k,\infty)$, Since $w_{0}(y)$ satisfies

$[(\rho+\lambda_{0})-{\mathcal{L}}]w_{0}(y)=\lambda_{0}w_{1}(y)$

for all $y$, we can combine these equations on the interval $(k,\infty)$ and
get a system of $w_{0}(y)$ and $w_{1}(y)$:

$[(\rho+\lambda_{1})-{\mathcal{L}}]w_{1}(y)=\lambda_{1}w_{0}(y)\quad\text{and}\quad[(\rho+\lambda_{0})-{\mathcal{L}}]w_{0}(y)=\lambda_{0}w_{1}(y)$
(7)

We can reduce the system into a single equation about $w_{1}(y)$ (or
$w_{0}(y)$);

$\\{[(\rho+\lambda_{0})-{\mathcal{L}}][(\rho+\lambda_{1})-{\mathcal{L}}]-\lambda_{0}\lambda_{1}\\}w_{1}(y)=0.$

The above equation can be simplified to

$[({\mathcal{L}}-\rho)({\mathcal{L}}-\rho-\lambda_{0}-\lambda_{1})]w_{1}(y)=0.$

This equation is a Cauchy-Euler type equation and its solutions are the linear
combination of $y^{\delta}$ with $\delta$ satisfying the polynomial equation:

$[\sigma\delta(\delta-1)+(\mu_{2}-\mu_{1})\delta+\mu_{1}-\rho][\sigma\delta(\delta-1)+(\mu_{2}-\mu_{1})\delta+\mu_{1}-\rho-\lambda_{0}-\lambda_{1}]=0.$
(8)

Simplify further and we can find $\delta$ explicitly:

$\left[\delta^{2}-\left(1+\frac{\mu_{1}-\mu_{2}}{\sigma}\right)\delta-\frac{\rho-\mu_{1}}{\sigma}\right]\left[\delta^{2}-\left(1+\frac{\mu_{1}-\mu_{2}}{\sigma}\right)\delta-\frac{\rho+\lambda_{0}+\lambda_{1}-\mu_{1}}{\sigma}\right]=0.$

There are four real roots $\delta_{1}$, $\delta_{2}$, $\delta_{3}$ and
$\delta_{4}$ (by direct calculation $\delta_{1}<0,\delta_{3}<0$ and
$\delta_{2}>1,\delta_{4}>1$) given by

$\begin{array}[]{l}\displaystyle\delta_{1}=\frac{1}{2}\Biggl{(}1+\frac{\mu_{1}-\mu_{2}}{\sigma}-\sqrt{\left(1+\frac{\mu_{1}-\mu_{2}}{\sigma}\right)^{2}+\frac{4(\rho-\mu_{1})}{\sigma}}\,\Biggr{)},\\\
\displaystyle\delta_{2}=\frac{1}{2}\Biggl{(}1+\frac{\mu_{1}-\mu_{2}}{\sigma}+\sqrt{\left(1+\frac{\mu_{1}-\mu_{2}}{\sigma}\right)^{2}+\frac{4(\rho-\mu_{1})}{\sigma}}\,\Biggr{)},\\\
\displaystyle\delta_{3}=\frac{1}{2}\Biggl{(}1+\frac{\mu_{1}-\mu_{2}}{\sigma}-\sqrt{\left(1+\frac{\mu_{1}-\mu_{2}}{\sigma}\right)^{2}+\frac{4(\rho+\lambda_{0}+\lambda_{1}-\mu_{1})}{\sigma}}\,\Biggr{)},\\\
\displaystyle\delta_{4}=\frac{1}{2}\Biggl{(}1+\frac{\mu_{1}-\mu_{2}}{\sigma}+\sqrt{\left(1+\frac{\mu_{1}-\mu_{2}}{\sigma}\right)^{2}+\frac{4(\rho+\lambda_{0}+\lambda_{1}-\mu_{1})}{\sigma}}\,\Biggr{)}.\end{array}$
(9)

Using the inequalities in (4), we have $-\beta_{\rm b}y\leq
w_{i}(y)\leq\beta_{\rm s}$. In view of this, the general solution of
$w_{1}(y)$ for $y\in(k,\infty)$ should be of the form:

$w_{1}(y)=C_{1}y^{\delta_{1}}+C_{3}y^{\delta_{3}},$ (10)

for some constants $C_{1}$ and $C_{3}$. Once we find $w_{1}(y)$, $w_{0}(y)$ is
given by

$w_{0}(y)=\frac{[(\rho+\lambda_{1})-{\mathcal{L}}]w_{1}(y)}{\lambda_{1}}=w_{1}(y)-\frac{1}{\lambda_{1}}({\mathcal{L}}-\rho)w_{1}(y).$

Note that $w_{1}(y)=C_{1}y^{\delta_{1}}+C_{3}y^{\delta_{3}}$ and

$({\mathcal{L}}-\rho)(y^{\delta_{1}})=0\quad\text{and}\quad({\mathcal{L}}-\rho-\lambda_{0}-\lambda_{1})y^{\delta_{3}}=0.$

This yields

$\displaystyle w_{0}(y)$
$\displaystyle=w_{1}(y)-\frac{1}{\lambda_{1}}({\mathcal{L}}-\rho)w_{1}(y)$
$\displaystyle=C_{1}y^{\delta_{1}}+C_{3}y^{\delta_{3}}-\frac{1}{\lambda_{1}}({\mathcal{L}}-\rho)[C_{1}y^{\delta_{1}}+C_{3}y^{\delta_{3}}]$
$\displaystyle=C_{1}y^{\delta_{1}}+C_{3}y^{\delta_{3}}-\frac{1}{\lambda_{1}}({\mathcal{L}}-\rho)[C_{3}y^{\delta_{3}}]$
$\displaystyle=C_{1}y^{\delta_{1}}+C_{3}y^{\delta_{3}}-\frac{\lambda_{0}+\lambda_{1}}{\lambda_{1}}C_{3}y^{\delta_{3}}$
$\displaystyle=C_{1}y^{\delta_{1}}-\frac{\lambda_{0}}{\lambda_{1}}C_{3}y^{\delta_{3}}.$

Let $\eta=({\lambda_{0}}/{\lambda_{1}})$. Then, we have

$w_{0}(y)=C_{1}y^{\delta_{1}}-\eta C_{3}y^{\delta_{3}}\quad\text{and}\quad
w_{1}(y)=C_{1}y^{\delta_{1}}+C_{3}y^{\delta_{3}}$ (11)

on the interval $(k,\infty)$.

On the interval $(0,k)$, $w_{1}(y)=\beta_{\rm s}-\beta_{\rm b}y$ and

$[(\rho+\lambda_{0})-{\mathcal{L}}]w_{0}(y)=\lambda_{0}w_{1}(y)=\lambda_{0}(\beta_{\rm
s}-\beta_{\rm b}y).$

A particular solution for

$(\rho+\lambda_{0}-{\mathcal{L}})w_{0}(y)=\lambda_{0}(\beta_{\rm s}-\beta_{\rm
b}y)$

can be given by $w_{0}(y)=a_{0}\beta_{\rm s}-a_{1}\beta_{\rm b}y$, with

$a_{0}=\frac{\lambda_{0}}{\rho+\lambda_{0}-\mu_{1}}\quad\text{and}\quad
a_{1}=\frac{\lambda_{0}}{\rho+\lambda_{0}-\mu_{2}}.$ (12)

To find a general solution to the above non-homogeneous equation, we only need
to add the homogeneous equation $(\rho+\lambda_{0}-{\mathcal{L}})w_{0}=0$ to
the above particular solution. This is also of Cauchy-Euler type and its
solution is of the form $y^{\gamma}$. Then $\gamma$ must be the roots of the
quadratic equation

$\sigma\gamma(\gamma-1)+(\mu_{2}-\mu_{1})\gamma-(\rho+\lambda_{0}-\mu_{1})=0.$

and are given by

$\begin{split}\gamma_{1}&=\frac{1}{2}\left(1+\frac{\mu_{1}-\mu_{2}}{\sigma}-\sqrt{\left(1+\frac{\mu_{1}-\mu_{2}}{\sigma}\right)^{2}+\frac{4(\rho+\lambda_{0}-\mu_{1})}{\sigma}}\right)<0,\\\
\gamma_{2}&=\frac{1}{2}\left(1+\frac{\mu_{1}-\mu_{2}}{\sigma}+\sqrt{\left(1+\frac{\mu_{1}-\mu_{2}}{\sigma}\right)^{2}+\frac{4(\rho+\lambda_{0}-\mu_{1})}{\sigma}}\right)>1.\end{split}$
(13)

The general solution for $w_{0}(y)$ on $(0,k)$ is given by

$w_{0}=C_{2}y^{\gamma_{2}}+a_{0}\beta_{\rm s}-a_{1}\beta_{\rm b}y,$ (14)

for some constant $C_{2}$. Here, we skipped the term $y^{\gamma_{1}}$ because
the solution should be bounded at $y=0$. We summarize the computation so far
as follows.

The solutions of the HJB equations (6) have the following form:

$\begin{array}[]{l}w_{0}(y)=\left\\{\begin{array}[]{ll}C_{2}y^{\gamma_{2}}+a_{0}\beta_{\rm
s}-a_{1}\beta_{\rm b}y&\mbox{ if }0<y<k,\\\ C_{1}y^{\delta_{1}}-\eta
C_{3}y^{\delta_{3}}&\mbox{ if }y\geq k,\\\ \end{array}\right.\\\
w_{1}(y)=\left\\{\begin{array}[]{ll}\beta_{\rm s}-\beta_{\rm b}y&\mbox{ if
}0<y<k,\\\ C_{1}y^{\delta_{1}}+C_{3}y^{\delta_{3}}&\mbox{ if }y\geq k.\\\
\end{array}\right.\\\ \end{array}$ (15)

In what follows, we use a smooth-fit approach to determine the parameter
values $k$, and $C_{j}$, $j=1,2,3$.

### Smooth-fit conditions.

Smooth-fit conditions in connection with optimal stopping typically require
the value functions to be continuously differentiable. First, the continuous
differentiability of $w_{1}$ at $y=k$ yields

$\begin{array}[]{rl}\beta_{\rm s}-\beta_{\rm
b}k=&C_{1}k^{\delta_{1}}+C_{3}k^{\delta_{3}},\\\ -\beta_{\rm
b}k=&C_{1}\delta_{1}k^{\delta_{1}}+C_{3}\delta_{3}k^{\delta_{3}}.\\\
\end{array}$ (16)

Similarly, continuous differentiability of $w_{0}$ at $y=k$ leads to

$\begin{split}C_{2}k^{\gamma_{2}}+a_{0}\beta_{\rm s}-a_{1}\beta_{\rm
b}k=&C_{1}k^{\delta_{1}}-\eta C_{3}k^{\delta_{3}},\\\
C_{2}\gamma_{2}k^{\gamma_{2}}-a_{1}\beta_{\rm
b}k=&\delta_{1}C_{1}k^{\delta_{1}}-\eta\delta_{3}C_{3}k^{\delta_{3}}.\end{split}$
(17)

Here we have four equations with four unknown parameters $k$, $C_{j}$ for
$j=1,2,3$.

Let

$\Phi(k;\delta_{1},\delta_{3})=\begin{pmatrix}k^{\delta_{1}}&k^{\delta_{3}}\\\
\delta_{1}k^{\delta_{1}}&\delta_{3}k^{\delta_{3}}\end{pmatrix}.$

Its inverse is given by

$\Phi^{-1}(k;\delta_{1},\delta_{3})=\frac{1}{\delta_{3}-\delta_{1}}\begin{pmatrix}\delta_{3}k^{-\delta_{1}}&-k^{-\delta_{1}}\\\
-\delta_{1}k^{-\delta_{3}}&k^{-\delta_{3}}\end{pmatrix}.$

Using $\Phi$, we rewrite (16) and (17):

$\Phi(k;\delta_{1},\delta_{3})\begin{pmatrix}C_{1}\\\
C_{3}\end{pmatrix}=\begin{pmatrix}\beta_{\rm s}-\beta_{\rm b}k\\\ -\beta_{\rm
b}k\end{pmatrix}\ \text{and}\
\Phi(k;\delta_{1},\delta_{3})\begin{pmatrix}C_{1}\\\ -\eta
C_{3}\end{pmatrix}=\begin{pmatrix}C_{2}k^{\gamma_{2}}+a_{0}\beta_{\rm
s}-a_{1}\beta_{\rm b}k\\\ C_{2}\gamma_{2}k^{\gamma_{2}}-a_{1}\beta_{\rm
b}k\end{pmatrix}.$

It follows that

$\begin{pmatrix}C_{1}\\\
C_{3}\end{pmatrix}=\Phi^{-1}(k;\delta_{1},\delta_{3})\begin{pmatrix}\beta_{\rm
s}-\beta_{\rm b}k\\\ -\beta_{\rm b}k\end{pmatrix},$ (18)

and

$\begin{pmatrix}C_{1}\\\ C_{3}\end{pmatrix}=\begin{pmatrix}1&0\\\
0&-\eta^{-1}\end{pmatrix}\Phi^{-1}(k;\delta_{1},\delta_{3})\begin{pmatrix}C_{2}k^{\gamma_{2}}+a_{0}\beta_{\rm
s}-a_{1}\beta_{\rm b}k\\\ C_{2}\gamma_{2}k^{\gamma_{2}}-a_{1}\beta_{\rm
b}k\end{pmatrix}.$ (19)

Eliminate $C_{1}$ and $C_{3}$ to obtain

$\Phi(k;\delta_{1},\delta_{3})\begin{pmatrix}1&0\\\
0&-\eta\end{pmatrix}\Phi^{-1}(k;\delta_{1},\delta_{3})\begin{pmatrix}\beta_{\rm
s}-\beta_{\rm b}k\\\ -\beta_{\rm
b}k\end{pmatrix}=\begin{pmatrix}C_{2}k^{\gamma_{2}}+a_{0}\beta_{\rm
s}-a_{1}\beta_{\rm b}k\\\ C_{2}\gamma_{2}k^{\gamma_{2}}-a_{1}\beta_{\rm
b}k\end{pmatrix}.$ (20)

Some simple calculations yield

$\Phi(k;\delta_{1},\delta_{3})\begin{pmatrix}1&0\\\
0&-\eta\end{pmatrix}\Phi^{-1}(k;\delta_{1},\delta_{3})=\frac{1}{\delta_{3}-\delta_{1}}\begin{pmatrix}\delta_{3}+\eta\delta_{1}&-(1+\eta)\\\
\delta_{1}\delta_{3}(1+\eta)&-(\delta_{1}+\eta\delta_{3})\end{pmatrix}.$

We note that this matrix is independent of $k$. This reduces (20) to

$\frac{1}{\delta_{3}-\delta_{1}}\begin{pmatrix}\delta_{3}+\eta\delta_{1}&-(1+\eta)\\\
\delta_{1}\delta_{3}(1+\eta)&-(\delta_{1}+\eta\delta_{3})\end{pmatrix}\begin{pmatrix}\beta_{\rm
s}-\beta_{\rm b}k\\\ -\beta_{\rm
b}k\end{pmatrix}=\begin{pmatrix}C_{2}k^{\gamma_{2}}+a_{0}\beta_{\rm
s}-a_{1}\beta_{\rm b}k\\\ C_{2}\gamma_{2}k^{\gamma_{2}}-a_{1}\beta_{\rm
b}k\end{pmatrix}.$

This leads to two equations:

$\displaystyle\frac{(\delta_{3}+\eta\delta_{1})(\beta_{\rm s}-\beta_{\rm
b}k)+(1+\eta)\beta_{\rm b}k}{\delta_{3}-\delta_{1}}$
$\displaystyle=C_{2}k^{\gamma_{2}}+a_{0}\beta_{\rm s}-a_{1}\beta_{\rm b}k,$
$\displaystyle\frac{\delta_{1}\delta_{3}(1+\eta)(\beta_{\rm s}-\beta_{\rm
b}k)+(\delta_{1}+\eta\delta_{3})\beta_{\rm b}k}{\delta_{3}-\delta_{1}}$
$\displaystyle=C_{2}\gamma_{2}k^{\gamma_{2}}-a_{1}\beta_{\rm b}k.$

Eliminating $C_{2}k^{\gamma_{2}}$, we obtain an equation containing only $k$:

$\displaystyle\frac{[(\delta_{3}+\eta\delta_{1})(\beta_{\rm s}-\beta_{\rm
b}k)+(1+\eta)\beta_{\rm
b}k]\gamma_{2}-[\delta_{1}\delta_{3}(1+\eta)(\beta_{\rm s}-\beta_{\rm
b}k)+(\delta_{1}+\eta\delta_{3})\beta_{\rm b}k]}{\delta_{3}-\delta_{1}}$
$\displaystyle=$ $\displaystyle a_{0}\gamma_{2}\beta_{\rm
s}-a_{1}(\gamma_{2}-1)\beta_{\rm b}k.$

This leads to the solution

$k=\frac{\delta_{1}\delta_{3}(1+\eta)-(\delta_{3}+\eta\delta_{1})\gamma_{2}-a_{0}(\delta_{1}-\delta_{3})\gamma_{2}}{(1+\eta)(\delta_{1}\delta_{3}+\gamma_{2})-(\delta_{3}+\eta\delta_{1})\gamma_{2}-(\delta_{1}+\eta\delta_{3})-a_{1}(\gamma_{2}-1)(\delta_{1}-\delta_{3})}\cdot\frac{\beta_{\rm
s}}{\beta_{\rm b}}.$ (21)

Note that $k>0$ and this can be shown by proving that both the numerator and
denominator in (21) are positive. Since $0<a_{0}<1$ and $0<a_{1}<1$, we have

$\begin{array}[]{l}\delta_{1}\delta_{3}(1+\eta)-(\delta_{3}+\eta\delta_{1})\gamma_{2}-a_{0}(\delta_{1}-\delta_{3})\gamma_{2}\\\
>\delta_{1}\delta_{3}(1+\eta)-(\delta_{3}+\eta\delta_{1})\gamma_{2}-(\delta_{1}-\delta_{3})\gamma_{2}\\\
=(1+\eta)(-\delta_{1})(\gamma_{2}-\delta_{3})>0.\end{array}$

Moreover,

$\begin{array}[]{l}(1+\eta)(\delta_{1}\delta_{3}+\gamma_{2})-(\delta_{3}+\eta\delta_{1})\gamma_{2}-(\delta_{1}+\eta\delta_{3})-a_{1}(\gamma_{2}-1)(\delta_{1}-\delta_{3})\\\
>(1+\eta)(\delta_{1}\delta_{3}+\gamma_{2})-(\delta_{3}+\eta\delta_{1})\gamma_{2}-(\delta_{1}+\eta\delta_{3})-(\gamma_{2}-1)(\delta_{1}-\delta_{3})\\\
=(1+\eta)(\delta_{1}\delta_{3}+\gamma_{2})-\gamma_{2}(\delta_{3}+\eta\delta_{1}+\delta_{1}-\delta_{3})-(\delta_{1}+\eta\delta_{3}-\delta_{1}+\delta_{3})\\\
=(1+\eta)(\delta_{1}\delta_{3}+\gamma_{2}-\gamma_{2}\delta_{1}-\delta_{3})\\\
=(1+\eta)(\gamma_{2}-\delta_{3})(1-\delta_{1})>0.\end{array}$

Therefore, $k>0$.

Next, we solve for the rest of parameters. From (18), we have

$C_{1}=\frac{-\delta_{3}\beta_{\rm s}+(\delta_{3}-1)\beta_{\rm
b}k}{(\delta_{1}-\delta_{3})k^{\delta_{1}}},\quad\text{and}\quad
C_{3}=\frac{\delta_{1}\beta_{\rm s}-(\delta_{1}-1)\beta_{\rm
b}k}{(\delta_{1}-\delta_{3})k^{\delta_{3}}}.$ (22)

Similarly, (19) yields

$\begin{split}C_{1}&=\frac{(\gamma_{2}-\delta_{3})C_{2}k^{\gamma_{2}}-a_{0}\delta_{3}\beta_{\rm
s}+a_{1}(\delta_{3}-1)\beta_{\rm
b}k}{(\delta_{1}-\delta_{3})k^{\delta_{1}}},\\\
C_{3}&=\frac{(\gamma_{2}-\delta_{1})C_{2}k^{\gamma_{2}}-a_{0}\delta_{1}\beta_{\rm
s}+a_{1}(\delta_{1}-1)\beta_{\rm
b}k}{\eta(\delta_{1}-\delta_{3})k^{\delta_{3}}}.\end{split}$ (23)

Combine (22) and (23) to obtain

$\displaystyle(\gamma_{2}-\delta_{3})C_{2}k^{\gamma_{2}}+(1-a_{1})(1-\delta_{3})\beta_{\rm
b}k$ $\displaystyle=(a_{0}-1)\delta_{3}\beta_{\rm s},$
$\displaystyle(\gamma_{2}-\delta_{1})C_{2}k^{\gamma_{2}}-(\eta+a_{1})(1-\delta_{1})\beta_{\rm
b}k$ $\displaystyle=(a_{0}+\eta)\delta_{1}\beta_{\rm s}.$

Eliminating the term linear in $k$, we have

$C_{2}=\frac{[(1-a_{0})(\eta+a_{1})(1-\delta_{1})(-\delta_{3})+(1-a_{1})(\eta+a_{0})(1-\delta_{3})\delta_{1}]\beta_{\rm
s}}{(1+\eta)(\delta_{1}\delta_{3}+\gamma_{2})-\delta_{1}[(a_{1}+\eta)\gamma_{2}+(1-a_{1})]-\delta_{3}[(a_{1}+\eta)+\gamma_{2}(1-a_{1})]k^{\gamma_{2}}}.$
(24)

Finally, we give a lemma needed in the proof a verification theorem to follow.
Its proof is technical and length. We provide it in the Appendix.

###### Lemma 3.1

. Under Assumption (A1), the constants $C_{1}$, $C_{2}$, and $C_{3}$ are
positive.

##  4 A Verification Theorem

In this section, we first show that the functions $w_{0}$ and $w_{1}$ are
solutions of the HJB equations (6). Then, we provide a verification theorem.

###### Theorem 4.1

. Assume (A1). Then, the following functions $w_{0}$ and $w_{1}$ satisfy the
HJB equations (6):

$\begin{array}[]{l}w_{0}(y)=\left\\{\begin{array}[]{ll}C_{2}y^{\gamma_{2}}+a_{0}\beta_{\rm
s}-a_{1}\beta_{\rm b}y&\mbox{ if }0<y<k,\\\ C_{1}y^{\delta_{1}}-\eta
C_{3}y^{\delta_{3}}&\mbox{ if }y\geq k,\\\ \end{array}\right.\\\
w_{1}(y)=\left\\{\begin{array}[]{ll}\beta_{\rm s}-\beta_{\rm b}y&\mbox{ if
}0<y<k,\\\ C_{1}y^{\delta_{1}}+C_{3}y^{\delta_{3}}&\mbox{ if }y\geq k.\\\
\end{array}\right.\\\ \end{array}$

Proof. It suffices to show the following variational inequalities hold:

$\begin{split}(0,k):\quad&(\rho+\lambda_{1}-{\mathcal{L}})w_{1}(y)\geq\lambda_{1}w_{0}(y),\\\
(k,\infty):\quad&w_{1}(y)\geq\beta_{\rm s}-\beta_{\rm b}y.\end{split}$

Recall that on the interval $(0,k)$,

$w_{0}(y)=C_{2}y^{\gamma_{2}}+a_{0}\beta_{\rm s}-a_{1}\beta_{\rm
b}y\quad\text{and}\quad w_{1}(y)=\beta_{\rm s}-\beta_{\rm b}y.$

Then

$(\rho+\lambda_{1}-{\mathcal{L}})w_{1}(y)=(\rho+\lambda_{1}-\mu_{1})\beta_{\rm
s}-(\rho+\lambda_{1}-\mu_{2})\beta_{\rm b}y.$

We let

$\displaystyle\psi(y)$
$\displaystyle=(\rho+\lambda_{1}-{\mathcal{L}})w_{1}(y)-\lambda_{1}w_{0}(y)$
$\displaystyle=(\rho+\lambda_{1}-\mu_{1})\beta_{\rm
s}-(\rho+\lambda_{1}-\mu_{2})\beta_{\rm
b}y-\lambda_{1}(C_{2}y^{\gamma_{2}}+a_{0}\beta_{\rm s}-a_{1}\beta_{\rm b}y)$
$\displaystyle=[\rho+(1-a_{0})\lambda_{1}-\mu_{1}]\beta_{\rm
s}-[\rho+(1-a_{1})\lambda_{1}-\mu_{2}]\beta_{\rm
b}y-\lambda_{1}C_{2}y^{\gamma_{2}}.$

We need to show that $\psi(y)\geq 0$ on the interval $(0,k)$. First, we note
that

$\psi(0)=[\rho+(1-a_{0})\lambda_{1}-\mu_{1}]\beta_{\rm s}>0\mbox{ and
}\psi^{\prime}(0)=-[\rho+(1-a_{1})\lambda_{1}-\mu_{2}]\beta_{\rm b}<0.$

We also have

$\psi^{\prime\prime}(y)=-C_{2}\lambda_{1}\gamma_{2}(\gamma_{2}-1)y^{\gamma_{2}-2}<0\quad\text{since
$\gamma_{2}>1$ and $C_{2}>0$}.$

Hence $\psi^{\prime}(y)$ is decreasing and $\psi^{\prime}(y)<0$ on the
interval $(0,k)$. It suffices to show that $\psi(k)\geq 0$ which implies
$\psi(y)\geq 0$ for $0\leq y\leq k$. Introduce new functions $w^{+}_{j}$ and
$w^{-}_{j}$ such that

$w_{j}(y)=\begin{cases}w^{-}_{j}(y)&0\leq y<k,\\\ w^{+}_{j}(y)&y\geq
k,\end{cases}\quad\text{for}\ j=0,1.$

Then, following from the smooth-fit conditions, we have, for $j=0,1$,

$w^{-}_{j}(k)=w^{+}_{j}(k)\quad\text{and}\quad[w^{-}_{j}]^{\prime}(k)=[w^{+}_{j}]^{\prime}(k).$

Moreover, $\psi(k)\geq 0$ is equivalent to

$(\rho+\lambda_{1}-{\mathcal{L}})w^{-}_{1}(y)|_{y=k}\geq\lambda_{1}w^{-}_{0}(k).$

Note that

$\quad(\rho+\lambda_{1}-{\mathcal{L}})w^{+}_{1}(y)|_{y=k}=\lambda_{1}w^{+}_{0}(y)|_{y=k}=\lambda_{1}w^{-}_{0}(y)|_{y=k}.$

This reduces the proof of $\psi(k)\geq 0$ to

$(\rho+\lambda_{1}-{\mathcal{L}})w^{-}_{1}(y)|_{y=k}\geq(\rho+\lambda_{1}-{\mathcal{L}})w^{+}_{1}(y)|_{y=k}.$

Then we use

$w^{-}_{j}(k):=\lim_{y\uparrow
k}w^{-}_{j}(y)=w^{+}_{j}(k)\quad\text{and}\quad[w^{-}_{j}]^{\prime}(k):=\lim_{y\uparrow
k}[w^{-}_{j}]^{\prime}(y)=[w^{+}_{j}]^{\prime}(k),$

for $j=0,1$, to the above to get

$-\sigma k^{2}[w^{-}_{1}]^{\prime\prime}(y)|_{y=k}\geq-\sigma
k^{2}[w^{+}_{1}]^{\prime\prime}(y)|_{y=k},$

which is equivalent to

$[w^{-}_{1}]^{\prime\prime}(y)|_{y=k}\leq[w^{+}_{1}]^{\prime\prime}(y)|_{y=k}.$

Recall Lemma 3.1. The latter holds because

$[w^{-}_{1}]^{\prime\prime}(y)|_{y=k}=0\quad\text{and}\quad[w^{+}_{1}]^{\prime\prime}(y)|_{y=k}=C_{1}\delta_{1}(\delta_{1}-1)k^{\delta_{1}-2}+C_{3}\delta_{3}(\delta_{3}-1)k^{\delta_{3}-2}>0.$

Therefore, $\psi(k)\geq 0$ and hence $\psi(y)\geq 0$ on $(0,k)$.

On the interval $(k,\infty)$ we need to show that $w_{1}(y)\geq\beta_{\rm
s}-\beta_{\rm b}y$ with $w_{1}(y)=C_{1}y^{\delta_{1}}+C_{3}y^{\delta_{3}}$.
Let $\phi(y)=C_{1}y^{\delta_{1}}+C_{3}y^{\delta_{3}}-\beta_{\rm s}+\beta_{\rm
b}y$. Then the smooth-fitting conditions implies $\phi(k)=\phi^{\prime}(k)=0$.
Moreover,

$\displaystyle\phi^{\prime}(y)$
$\displaystyle=C_{1}\delta_{1}y^{\delta_{1}-1}+C_{3}\delta_{3}y^{\delta_{3}-1}+\beta_{\rm
b},$ $\displaystyle\phi^{\prime\prime}(y)$
$\displaystyle=C_{1}\delta_{1}(\delta_{1}-1)y^{\delta_{1}-2}+C_{3}\delta_{3}(\delta_{3}-1)y^{\delta_{3}-2}.$

Since $\delta_{1}<0$ and $\delta_{3}<0$, $\phi^{\prime\prime}(y)>0$ in the
interval $[y,\infty)$. This implies $\phi^{\prime}(y)$ is increasing and
$\phi^{\prime}(k)=0$ implies $\phi^{\prime}(y)>0$ for $y>k$. Hence $\phi(y)$
is increasing, $\phi(k)=0$ implies $\phi(y)>0$ for $y>k$. $\Box$

Next, we next provide a verification theorem.

###### Theorem 4.2

. Assume (A1). Then,
$v_{\alpha}(x_{1},x_{2})=x_{1}w_{\alpha}(x_{2}/x_{1})=V_{\alpha}(x_{1},x_{2})$,
$\alpha=0,1$. Let $D=\\{(x_{1},x_{2},1):\ x_{2}>kx_{1}\\}$. Let
$\tau^{*}=\inf\\{t:\ (X^{1}_{t},X^{2}_{t},\alpha_{t})\not\in D\\}$. Then
$\tau^{*}$ is optimal.

Proof. The proof is similar to that of [6, Theorem 2]. We only sketch the main
steps for the sake of completeness. First, for any admissible stopping time
$\tau$, following Dynkin’s formula, we have

$v_{\alpha}(x_{1},x_{2})\geq
Ee^{-\rho\tau}v_{\alpha_{\tau}}(X^{1}_{\tau},X^{2}_{\tau})\geq
Ee^{-\rho\tau}(\beta_{\rm s}X^{1}_{\tau}-\beta_{\rm
b}X^{2}_{\tau})=J(x_{1},x_{2},\alpha,\tau).$

So, $v_{\alpha}(x_{1},x_{2})\geq V_{\alpha}(x_{1},x_{2})$. The equality holds
when $\tau=\tau^{*}$. Hence,
$v_{\alpha}(x_{1},x_{2})=J(x_{1},x_{2},\alpha,\tau^{*})=V_{\alpha}(x_{1},x_{2})$.
$\Box$

##  5 Asymptotics of $k=k(\lambda_{0},\lambda_{1})$

In this section, we consider the asymptotic behavior of
$k=k(\lambda_{0},\lambda_{1})$ as one of $\lambda_{0}$ and $\lambda_{1}$ goes
to $\infty$ with the other fixed. To facilitate the subsequent calculation, we
regroup the terms in (21) for $k$ as follows:

$k=\frac{(1+\eta)\delta_{1}\delta_{3}+\gamma_{2}[(a_{0}+\eta)(-\delta_{1})+(1-a_{0})(-\delta_{3})]}{(1+\eta)(\delta_{1}\delta_{3}+\gamma_{2})-\delta_{1}[(a_{1}+\eta)\gamma_{2}+(1-a_{1})]-\delta_{3}[(a_{1}+\eta)+\gamma_{2}(1-a_{1})]}\cdot\frac{\beta_{\rm
s}}{\beta_{\rm b}}.$

### Asymptotics of $k$ as $\lambda_{0}\to\infty$

We first consider the limit of $k=k(\lambda_{0},\lambda_{1})$ as
$\lambda_{0}\to\infty$ with $\lambda_{1}$ fixed. In this case, the mean time
for $\alpha_{t}$ spent at state 0 is given by $(1/\lambda_{0})$ which goes to
0. In view of this, the limit of $k$ should correspond to the threshold of
unconstrained pairs selling.

To validate this observation, we list all the terms in (21) that are
$\lambda_{0}$ depended:

$\eta=\frac{\lambda_{0}}{\lambda_{1}},\
1-a_{0}=\frac{\rho-\mu_{1}}{\rho-\mu_{1}+\lambda_{0}},\
1-a_{1}=\frac{\rho-\mu_{2}}{\rho-\mu_{2}+\lambda_{0}},\
\gamma_{2}\approx\frac{\sqrt{\lambda_{0}}}{\sqrt{\sigma}},\ \text{and}\
\delta_{3}\approx-\frac{\sqrt{\lambda_{0}}}{\sqrt{\sigma}}.$

Therefore, we have

$\lim_{\lambda_{0}\to\infty}k=\lim_{\lambda_{0}\to\infty}\frac{-2\delta_{1}\lambda_{0}^{3/2}/(\lambda_{1}\sqrt{\sigma})+\text{lower
order
terms}}{2(1-\delta_{1})\lambda_{0}^{3/2}/(\lambda_{1}\sqrt{\sigma})+\text{lower
order terms}}\cdot\frac{\beta_{\rm s}}{\beta_{\rm
b}}=\frac{-\delta_{1}}{1-\delta_{1}}\cdot\frac{\beta_{\rm s}}{\beta_{\rm
b}}=:k_{0}.$

To see the connection with the selling rule without constraints. We note that
the associated HJB equation (unconstrained) has the form:

$\min\Big{\\{}\rho w(y)-{\mathcal{L}}w(y),\ w(y)-\beta_{\rm s}+\beta_{\rm
b}y\Big{\\}}=0.$

Repeating our previous smooth-fit calculation yields exactly $k=k_{0}$
obtained above.

### Asymptotics of $k$ as $\lambda_{1}\to\infty$

Similarly, we can consider the limit $\lambda_{1}\to\infty$ with fixed
$\lambda_{0}$. Note that
$\delta_{3}\approx-{\sqrt{\lambda_{1}}}/{\sqrt{\sigma}}$ and
$\eta={\lambda_{0}}/{\lambda_{1}}$ are the only two terms depending on
$\lambda_{1}$. It follows that

$\lim_{\lambda_{1}\to\infty}k=\frac{\delta_{1}-\gamma_{2}(1-a_{0})}{\delta_{1}-[a_{1}+\gamma_{2}(1-a_{1})]}\cdot\frac{\beta_{\rm
s}}{\beta_{\rm
b}}=\frac{-\delta_{1}+\gamma_{2}(1-a_{0})}{1-\delta_{1}+(\gamma_{2}-1)(1-a_{1})}\cdot\frac{\beta_{\rm
s}}{\beta_{\rm b}}=:k_{1}.$

It is not difficult to show $k_{1}>k_{0}$. (Actually, it is equivalent to the
inequality in (28) that is proved in the Appendix.) Intuitively, this makes
sense because one has to make trading easier (with larger $k$) when trading
constraints are present.

##  6 Numerical Examples

In this section, we consider the trading pair of Target Corp. (TGT) and
Walmart Stores Inc. (WMT). The model is calibrated by using the daily closing
prices from 1985-1999. Let ${\mathbf{S}}^{1}$=WMT and ${\mathbf{S}}^{2}$=TGT.
Using the traditional least squares method, we have $\mu_{1}=0.2459$,
$\mu_{2}=0.2059$, $\sigma_{11}=0.2943$, $\sigma_{12}=0.0729$,
$\sigma_{21}=0.0729$, and $\sigma_{22}=0.3112$. We take $\rho=0.5$,
$\lambda_{0}=\lambda_{1}=10$, and $K=0.001$. Using (21), we obtain $k=0.7036$.
We plot the corresponding $w_{0}(y)$ and $w_{1}(y)$ in Figure 1 and
$v_{i}(x_{1},x_{2})=x_{1}w_{i}(x_{2}/x_{1}),i=0,1$ in Figure 2.

Figure 1: Functions $w_{0}$ and $w_{1}$

Figure 2: Functions $v_{0}$ and $v_{1}$

#### Asymptotics of $k(\lambda_{0},\lambda_{1})$.

Next, we examine the asymptotics of $k=k(\lambda_{0},\lambda_{1})$ as one of
$\lambda_{0}$ and $\lambda_{1}$ goes to $\infty$ with the other fixed (at 10).
The corresponding graphs are plotted in Figure 3 along with $y=k_{0}$ and
$y=k_{1}$.

Figure 3: Asymptotics of $k(\lambda_{0},10)$ and $k(10,\lambda_{1})$

In addition, we give the 2D graph of $k(\lambda_{0},\lambda_{1})$ in Figure 4.

Figure 4: Dependence of $k$ on $\lambda_{0},\lambda_{1}$

#### Dependence of $k$ on various parameters.

In this section, we fix $\lambda_{0}=\lambda_{1}=10$. We vary one parameter at
a time and examine the dependence of $k$ on
$\mu_{i},\sigma_{ij},i,j=1,2,K,\rho$ respectively.

First, we vary $\mu_{i},i=1,2$. Recall that we close the position by selling
$X^{1}$ and buying back $X^{2}$ on $[0,k]$ in the state $\alpha=1$. A larger
$\mu_{i}$ implies greater growth potential in $X^{i}$. It can be seen in Table
1 that $k$ decrease in $\mu_{1}$ leading to fewer selling opportunities and
$k$ increases in $\mu_{2}$ leading to more selling opportunities. It is
because a larger $\mu_{2}$ and a smaller $\mu_{1}$ will encourage its early
exit.

Table 1: $k$ with varying $\mu_{1},\mu_{2}$ $\mu_{1}$ | 0.1259 | 0.1659 | 0.2059 | 0.2459 | 0.2859
---|---|---|---|---|---
$k$ | 0.7834 | 0.7481 | 0.7036 | 0.6481 | 0.5798
|  |  |  |  |
$\mu_{2}$ | 0.1659 | 0.2059 | 0.2459 | 0.2859 | 0.3259
$k$ | 0.6332 | 0.6688 | 0.7036 | 0.7367 | 0.7669

Next, we vary $\sigma_{11}$ and $\sigma_{22}$. Larger volatility leads to a
bigger room for the prices to move. This is associated with a smaller selling
zone and therefore smaller $k$.

Table 2: $k$ with varying $\sigma_{11},\sigma_{22}$ $\sigma_{11}$ | 0.2312 | 0.2712 | 0.3112 | 0.3512 | 0.3912
---|---|---|---|---|---
$k$ | 0.7516 | 0.7286 | 0.7036 | 0.6777 | 0.6514
|  |  |  |  |
$\sigma_{22}$ | 0.2143 | 0.2543 | 0.2943 | 0.3343 | 0.3743
$k$ | 0.7469 | 0.7265 | 0.7036 | 0.6794 | 0.6543

Then, we vary $\sigma_{12}$ $(=\sigma_{21})$. Increasing these parameters
makes the two stocks more related to each other which leads to a larger
selling zone as shown in Table 3.

Table 3: $k$ with varying $\sigma_{12}=\sigma_{21}$ $\sigma_{12}=\sigma_{21}$ | -0.0129 | 0.0329 | 0.0729 | 0.1129 | 0.1529
---|---|---|---|---|---
$k$ | 0.6060 | 0.6561 | 0.7036 | 0.75477 | 0.8094

Finally, we vary the discount rate $\rho$ and the transaction fee $K$. Larger
$\rho$ encourages to sell early which translates to a bigger selling zone as
can be seen in Table 4. Additionally, larger $K$ sets up a higher barrier for
selling which leads to a smaller selling zone.

Table 4: $k$ with varying $\rho$ and $K$ $\rho$ | 0.3 | 0.4 | 0.5 | 0.6 | 0.7
---|---|---|---|---|---
$k$ | 0.5590 | 0.6541 | 0.7036 | 0.7358 | 0.7590
|  |  |  |  |
$K$ | 0.0001 | 0.0005 | 0.001 | 0.002 | 0.003
$k$ | 0.7049 | 0.7043 | 0.7036 | 0.7022 | 0.7008

##  7 Conclusion

The focus of this paper is on pairs selling with limited opportunities, and
its main goal is to derive an optimal policy in closed form, which is
desirable for practical applications.

It would be intriguing to extend the results of this study to models that
incorporate more practical considerations, such as large block selling, where
intensive trading may affect trading windows.

Overall, this paper contributes to the understanding of pairs selling and
provides insights into developing optimal policies that can be applied in
real-world scenarios. There is potential for future research to expand on
these findings and explore more complex models that better capture real-world
dynamics.

## Appendix

In this appendix, we provide the proof of Lemma 3.1.

Proof of Lemma 3.1. We first work on $C_{1}$ and $C_{3}$. In view of (22),
$C_{1}>0$ and $C_{3}>0$ are equivalent to

$\frac{-\delta_{1}}{1-\delta_{1}}\cdot\frac{\beta_{s}}{\beta_{b}}<k<\frac{-\delta_{3}}{1-\delta_{3}}\cdot\frac{\beta_{s}}{\beta_{b}}.$
(25)

To simplify notation, let $b_{0}=1-a_{0}$ and $b_{1}=1-a_{1}$. Note that
$0<b_{0}<1$ and $0<b_{1}<1$. Using this notation, we rewrite $k$ as

$k=\frac{(1+\eta)(-\delta_{1})(\gamma_{2}-\delta_{3})+b_{0}(\delta_{1}-\delta_{3})\gamma_{2}}{(1+\eta)(\gamma_{2}-\delta_{3})(1-\delta_{1})+b_{1}(\gamma_{2}-1)(\delta_{1}-\delta_{3})}\cdot\frac{\beta_{\rm
s}}{\beta_{\rm b}}.$ (26)

The inequalities are equivalent to

$\frac{-\delta_{1}}{1-\delta_{1}}<\frac{(1+\eta)(-\delta_{1})(\gamma_{2}-\delta_{3})+b_{0}(\delta_{1}-\delta_{3})\gamma_{2}}{(1+\eta)(\gamma_{2}-\delta_{3})(1-\delta_{1})+b_{1}(\gamma_{2}-1)(\delta_{1}-\delta_{3})}<\frac{-\delta_{3}}{1-\delta_{3}}.$
(27)

### First inequality of (27).

The first inequality in (27) is equivalent to

$b_{1}(\gamma_{2}-1)(\delta_{1}-\delta_{3})(-\delta_{1})<b_{0}\gamma_{2}(\delta_{1}-\delta_{3})(1-\delta_{1})\
\Longleftrightarrow\
b_{1}(\gamma_{2}-1)(-\delta_{1})<b_{0}\gamma_{2}(1-\delta_{1}).$

The last inequality is equivalent to

$\frac{b_{1}}{b_{0}}<\frac{\gamma_{2}}{\gamma_{2}-1}\cdot(1-\frac{1}{\delta_{1}})=\left(1+\frac{1}{\gamma_{2}-1}\right)\left(1-\frac{1}{\delta_{1}}\right).$
(28)

Note that

$b_{0}=\frac{\rho-\mu_{1}}{\rho+\lambda_{0}-\mu_{1}}\mbox{ and
}b_{1}=\frac{\rho-\mu_{2}}{\rho+\lambda_{0}-\mu_{2}}.$

We consider two cases: Case I ($\mu_{1}\leq\mu_{2}$) and Case II
($\mu_{1}>\mu_{2}$).

Case I: If $\mu_{1}\leq\mu_{2}$, then

$\frac{b_{1}}{b_{0}}=\frac{1+\frac{\lambda_{0}}{\rho-\mu_{1}}}{1+\frac{\lambda_{0}}{\rho-\mu_{2}}}\leq
1;$

and the right hand side (28) is bigger than $1$ since $\gamma_{2}>1$ and
$\delta_{1}<0$. So the first inequality in (27) follows.

Case II: If $\mu_{1}>\mu_{2}$, then

$\frac{b_{1}}{b_{0}}=\frac{1+\frac{\lambda_{0}}{\rho-\mu_{1}}}{1+\frac{\lambda_{0}}{\rho-\mu_{2}}}=\frac{(\rho+\lambda_{0}-\mu_{1})(\rho-\mu_{2})}{(\rho+\lambda_{0}-\mu_{2})(\rho-\mu_{1})}>1.$

The previous simple argument no longer works. We need to elaborate the value
of $\left(1+\frac{1}{\gamma_{2}-1}\right)\left(1-\frac{1}{\delta_{1}}\right)$.
To this end, note that

$\displaystyle\frac{\gamma_{2}}{\gamma_{2}-1}$
$\displaystyle=\frac{1+\frac{\mu_{1}-\mu_{2}}{\sigma}+\sqrt{\left(1+\frac{\mu_{1}-\mu_{2}}{\sigma}\right)^{2}+\frac{4(\rho+\lambda_{0}-\mu_{1})}{\sigma}}}{-1+\frac{\mu_{1}-\mu_{2}}{\sigma}+\sqrt{\left(1+\frac{\mu_{1}-\mu_{2}}{\sigma}\right)^{2}+\frac{4(\rho+\lambda_{0}-\mu_{1})}{\sigma}}}$
$\displaystyle=\frac{\rho+\lambda_{0}+\frac{\sigma+\sigma\sqrt{B_{1}}-\mu_{1}-\mu_{2}}{2}}{\rho+\lambda_{0}-\mu_{2}},$

where

$B_{1}=\left(1+\frac{\mu_{1}-\mu_{2}}{\sigma}\right)^{2}+\frac{4(\rho+\lambda_{0}-\mu_{1})}{\sigma}.$

Next we compute

$\displaystyle\frac{\delta_{1}-1}{\delta_{1}}$
$\displaystyle=\frac{-1+\frac{\mu_{1}-\mu_{2}}{\sigma}-\sqrt{\left(1+\frac{\mu_{1}-\mu_{2}}{\sigma}\right)^{2}+\frac{4(\rho-\mu_{1})}{\sigma}}}{1+\frac{\mu_{1}-\mu_{2}}{\sigma}-\sqrt{\left(1+\frac{\mu_{1}-\mu_{2}}{\sigma}\right)^{2}+\frac{4(\rho-\mu_{1})}{\sigma}}}$
$\displaystyle=\frac{1-\frac{\mu_{1}-\mu_{2}}{\sigma}+\sqrt{\left(1+\frac{\mu_{1}-\mu_{2}}{\sigma}\right)^{2}+\frac{4(\rho-\mu_{1})}{\sigma}}}{-1-\frac{\mu_{1}-\mu_{2}}{\sigma}+\sqrt{\left(1+\frac{\mu_{1}-\mu_{2}}{\sigma}\right)^{2}+\frac{4(\rho-\mu_{1})}{\sigma}}}$
$\displaystyle=\frac{\rho+\frac{\sigma+\sigma\sqrt{B_{2}}-\mu_{1}-\mu_{2}}{2}}{\rho-\mu_{1}},$

where

$B_{2}=\left(1+\frac{\mu_{1}-\mu_{2}}{\sigma}\right)^{2}+\frac{4(\rho-\mu_{1})}{\sigma}.$

Since $\mu_{1}>\mu_{2}$, we have

$\sqrt{B_{1}}>1+\frac{\mu_{1}-\mu_{2}}{\sigma}\quad\text{and}\quad\sqrt{B_{2}}>1+\frac{\mu_{1}-\mu_{2}}{\sigma}.$

This implies

$\frac{\sigma+\sigma\sqrt{B_{1}}-\mu_{1}-\mu_{2}}{2}>\sigma-\mu_{2},\quad\frac{\sigma+\sigma\sqrt{B_{2}}-\mu_{1}-\mu_{2}}{2}>\sigma-\mu_{2},$

and

$\displaystyle\left(1+\frac{1}{\gamma_{2}-1}\right)\left(1-\frac{1}{\delta_{1}}\right)$
$\displaystyle>\frac{\rho+\lambda_{0}+\sigma-\mu_{2}}{\rho+\lambda_{0}-\mu_{2}}\cdot\frac{\rho+\sigma-\mu_{2}}{\rho-\mu_{1}}$
$\displaystyle>\frac{(\rho+\lambda_{0}-\mu_{1})(\rho-\mu_{2})}{(\rho+\lambda_{0}-\mu_{2})(\rho-\mu_{1})}.$

This is exactly what we need to show. Here we have used

$\rho+\lambda_{0}+\sigma-\mu_{2}>\rho+\lambda_{0}-\mu_{1}\ \text{and}\
\rho+\sigma-\mu_{2}>\rho-\mu_{2},$

since $\mu_{1}>\mu_{2}$ and $\sigma>0$.

### Second inequality of (27).

The second inequality in (27) is equivalent to

$\displaystyle(1+\eta)(-\delta_{1})(\gamma_{2}-\delta_{3})(1-\delta_{3})+b_{0}\gamma_{2}(\delta_{1}-\delta_{3})(1-\delta_{3})$
$\displaystyle<$
$\displaystyle(1+\eta)(\gamma_{2}-\delta_{3})(1-\delta_{1})(-\delta_{3})+b_{1}(\gamma_{2}-1)(\delta_{1}-\delta_{3})(-\delta_{3}).$

This is equivalent to

$b_{0}\gamma_{2}(1-\delta_{3})<(1+\eta)(\gamma_{2}-\delta_{3})+b_{1}(\gamma_{2}-1)(-\delta_{3}).$

We will let $a=-\delta_{3}>0$ and $\gamma_{2}=1+\gamma$. Then, the above
inequality is reduced to

$b_{0}(1+\gamma)(1+a)<(1+\eta)(1+\gamma+a)+b_{1}\gamma a.$

Since $1+\gamma+a=(1+a)(1+\gamma)-a\gamma$, the above inequality is equivalent
to

$(1+\eta-b_{1})a\gamma<(1+\eta-
b_{0})(1+a)(1+\gamma)\quad\Longleftrightarrow\quad\frac{1+\eta-b_{1}}{1+\eta-
b_{0}}<\frac{(1+a)(1+\gamma)}{a\gamma}.$

Then, we have

$\displaystyle\frac{1+\eta-b_{1}}{1+\eta-b_{0}}$
$\displaystyle=\frac{1+\frac{\lambda_{0}}{\lambda_{1}}-\frac{\rho-\mu_{2}}{\rho+\lambda_{0}-\mu_{2}}}{1+\frac{\lambda_{0}}{\lambda_{1}}-\frac{\rho-\mu_{1}}{\rho+\lambda_{0}-\mu_{1}}}=\frac{\frac{\lambda_{0}}{\lambda_{1}}+\frac{\lambda_{0}}{\rho+\lambda_{0}-\mu_{2}}}{\frac{\lambda_{0}}{\lambda_{1}}+\frac{\lambda_{0}}{\rho+\lambda_{0}-\mu_{1}}}$
$\displaystyle=\frac{1+\frac{\lambda_{1}}{\rho+\lambda_{0}-\mu_{2}}}{1+\frac{\lambda_{1}}{\rho+\lambda_{0}-\mu_{1}}}=\frac{(\rho+\lambda_{0}+\lambda_{1}-\mu_{2})(\rho+\lambda_{0}-\mu_{1})}{(\rho+\lambda_{0}+\lambda_{1}-\mu_{1})(\rho+\lambda_{0}-\mu_{2})},$

and

$\displaystyle\frac{(1+a)(1+\gamma)}{a\gamma}$
$\displaystyle=\left(1+\frac{1}{a}\right)\left(1+\frac{1}{\gamma}\right).$

Recall that

$\displaystyle a=-\delta_{3}$
$\displaystyle=\frac{1}{2}\left[\sqrt{\left(1+\frac{\mu_{1}-\mu_{2}}{\sigma}\right)^{2}+\frac{4(\rho+\lambda_{0}+\lambda_{1}-\mu_{1})}{\sigma}}-\left(1+\frac{\mu_{1}-\mu_{2}}{\sigma}\right)\right],$
$\displaystyle a+1$
$\displaystyle=\frac{1}{2}\left[\sqrt{\left(1+\frac{\mu_{1}-\mu_{2}}{\sigma}\right)^{2}+\frac{4(\rho+\lambda_{0}+\lambda_{1}-\mu_{1})}{\sigma}}+\left(1-\frac{\mu_{1}-\mu_{2}}{\sigma}\right)\right].$

Simple calculation yields

$\displaystyle\frac{1+a}{a}$
$\displaystyle=\frac{\sqrt{\left(1+\frac{\mu_{1}-\mu_{2}}{\sigma}\right)^{2}+\frac{4(\rho+\lambda_{0}+\lambda_{1}-\mu_{1})}{\sigma}}+\left(1-\frac{\mu_{1}-\mu_{2}}{\sigma}\right)}{\sqrt{\left(1+\frac{\mu_{1}-\mu_{2}}{\sigma}\right)^{2}+\frac{4(\rho+\lambda_{0}+\lambda_{1}-\mu_{1})}{\sigma}}-\left(1+\frac{\mu_{1}-\mu_{2}}{\sigma}\right)}$
$\displaystyle=\frac{\left[\sqrt{\left(1+\frac{\mu_{1}-\mu_{2}}{\sigma}\right)^{2}+\frac{4(\rho+\lambda_{0}+\lambda_{1}-\mu_{1})}{\sigma}}+1\right]^{2}-\left(\frac{\mu_{1}-\mu_{2}}{\sigma}\right)^{2}}{\frac{4(\rho+\lambda_{0}+\lambda_{1}-\mu_{1})}{\sigma}}$
$\displaystyle=\frac{2+\frac{4(\rho+\lambda_{0}+\lambda_{1}-\mu_{1})+2\mu_{1}-2\mu_{2}}{\sigma}+2\sqrt{B_{3}}}{\frac{4(\rho+\lambda_{0}+\lambda_{1}-\mu_{1})}{\sigma}}$
$\displaystyle=\frac{\rho+\lambda_{0}+\lambda_{1}-\frac{\mu_{1}+\mu_{2}}{2}+\frac{1+\sqrt{B_{3}}}{2}\sigma}{\rho+\lambda_{0}+\lambda_{1}-\mu_{1}},$

where

$B_{3}=\left(1+\frac{\mu_{1}-\mu_{2}}{\sigma}\right)^{2}+\frac{4(\rho+\lambda_{0}+\lambda_{1}-\mu_{1})}{\sigma}.$

Recall
$B_{1}=\left(1+\frac{\mu_{1}-\mu_{2}}{\sigma}\right)^{2}+\frac{4(\rho+\lambda_{0}-\mu_{1})}{\sigma}$.
We have

$\displaystyle\frac{\gamma+1}{\gamma}$
$\displaystyle=\frac{\frac{\mu_{1}-\mu_{2}}{\sigma}+1+\sqrt{\left(\frac{\mu_{1}-\mu_{2}}{\sigma}+1\right)^{2}+\frac{4(\rho+\lambda_{0}-\mu_{1})}{\sigma}}}{\frac{\mu_{1}-\mu_{2}}{\sigma}-1+\sqrt{\left(\frac{\mu_{1}-\mu_{2}}{\sigma}+1\right)^{2}+\frac{4(\rho+\lambda_{0}-\mu_{1})}{\sigma}}}$
$\displaystyle=\frac{\rho+\lambda_{0}-\frac{\mu_{1}+\mu_{2}}{2}+\frac{1+\sqrt{B_{1}}}{2}\sigma}{\rho+\lambda_{0}-\mu_{2}}.$

Note that

$\sqrt{B_{3}}>\left|1+\frac{\mu_{1}-\mu_{2}}{\sigma}\right|\quad\text{and}\quad\sqrt{B_{1}}>\left|1+\frac{\mu_{1}-\mu_{2}}{\sigma}\right|.$

This implies

$\displaystyle\frac{(1+\sqrt{B_{3}})\sigma}{2}-\frac{\mu_{1}+\mu_{2}}{2}$
$\displaystyle>\frac{\sigma+|\sigma+\mu_{1}-\mu_{2}|-\mu_{1}-\mu_{2}}{2}$
$\displaystyle=\begin{cases}\sigma-\mu_{2}&\sigma+\mu_{1}>\mu_{2},\\\
-\mu_{1}&\sigma+\mu_{1}\leq\mu_{2}.\end{cases}$

and similarly

$\frac{(1+\sqrt{B_{1}})\sigma}{2}-\frac{\mu_{1}+\mu_{2}}{2}>\begin{cases}\sigma-\mu_{2}&\sigma+\mu_{1}>\mu_{2},\\\
-\mu_{1}&\sigma+\mu_{1}\leq\mu_{2}.\end{cases}$

This implies that if $\sigma+\mu_{1}>\mu_{2}$ we have

$\displaystyle\frac{(1+a)(1+\gamma)}{a\gamma}$
$\displaystyle>\frac{\rho+\lambda_{0}+\lambda_{1}-\mu_{2}+\sigma}{\rho+\lambda_{0}+\lambda_{1}-\mu_{1}}\cdot\frac{\rho+\lambda_{0}-\mu_{2}+\sigma}{\rho+\lambda_{0}-\mu_{2}}$
$\displaystyle>\frac{(\rho+\lambda_{0}+\lambda_{1}-\mu_{2})(\rho+\lambda_{0}-\mu_{1})}{(\rho+\lambda_{0}+\lambda_{1}-\mu_{1})((\rho+\lambda_{0}-\mu_{2})}$
$\displaystyle=\frac{1+\eta-b_{1}}{1+\eta-b_{0}}.$

Here we have used $\sigma+\mu_{1}-\mu_{2}>0$ hence $\sigma-\mu_{2}>-\mu_{1}$
and

$\rho+\lambda_{0}-\mu_{2}+\sigma>\rho+\lambda_{0}-\mu_{1}.$

If $\sigma+\mu_{1}\leq\mu_{2}$, then $\mu_{1}<\sigma+\mu_{1}\leq\mu_{2}$ and

$\rho+\lambda_{0}+\lambda_{1}-\mu_{1}>\rho+\lambda_{0}+\lambda_{1}-\mu_{2}$

and

$\displaystyle\frac{(1+a)(1+\gamma)}{a\gamma}$
$\displaystyle>\frac{\rho+\lambda_{0}+\lambda_{1}-\mu_{1}}{\rho+\lambda_{0}+\lambda_{1}-\mu_{1}}\cdot\frac{\rho+\lambda_{0}-\mu_{1}}{\rho+\lambda_{0}-\mu_{2}}$
$\displaystyle>\frac{(\rho+\lambda_{0}+\lambda_{1}-\mu_{2})(\rho+\lambda_{0}-\mu_{1})}{(\rho+\lambda_{0}+\lambda_{1}-\mu_{1})((\rho+\lambda_{0}-\mu_{2})}$
$\displaystyle=\frac{1+\eta-b_{1}}{1+\eta-b_{0}}.$

This exactly what we need to prove for the second inequality in (27).

### Proof of $C_{2}>0$

Recall $C_{2}$ given in (24). In that formula, the denominator is positive
since $\delta_{3}<\delta_{1}<0$, $\gamma_{2}>1$, and $0<a_{0},\ a_{1}<1$.
$C_{2}$ is positive if

$(1-a_{0})(\eta+a_{1})(1-\delta_{1})(-\delta_{3})>(1-a_{1})(\eta+a_{0})(1-\delta_{3})(-\delta_{1}).$

Since $\delta_{1}<0$ and $\delta_{3}<0$, this is equivalent to

$\frac{\eta+a_{1}}{1-a_{1}}\cdot\frac{-\delta_{1}}{1-\delta_{1}}>\frac{\eta+a_{0}}{1-a_{0}}\cdot\frac{1-\delta_{3}}{-\delta_{3}}.$
(29)

We need to compute both sides and compare them. Note that

$\displaystyle\frac{\eta+a_{1}}{1-a_{1}}$
$\displaystyle=\frac{\frac{\lambda_{0}}{\lambda_{1}}+\frac{\lambda_{0}}{\rho+\lambda_{0}-\mu_{2}}}{\frac{\rho-\mu_{2}}{\rho+\lambda_{0}-\mu_{2}}}=\frac{\lambda_{0}}{\lambda_{1}}\cdot\frac{\rho+\lambda_{0}+\lambda_{1}-\mu_{2}}{\rho-\mu_{2}},$
$\displaystyle\frac{\eta+a_{0}}{1-a_{0}}$
$\displaystyle=\frac{\frac{\lambda_{0}}{\lambda_{1}}+\frac{\lambda_{0}}{\rho+\lambda_{0}-\mu_{1}}}{\frac{\rho-\mu_{1}}{\rho+\lambda_{0}-\mu_{1}}}=\frac{\lambda_{0}}{\lambda_{1}}\cdot\frac{\rho+\lambda_{0}+\lambda_{1}-\mu_{1}}{\rho-\mu_{1}}.$

Then (29) is reduced to

$\frac{\rho+\lambda_{0}+\lambda_{1}-\mu_{2}}{\rho-\mu_{2}}\cdot\frac{1-\delta_{1}}{-\delta_{1}}>\frac{\rho+\lambda_{0}+\lambda_{1}-\mu_{1}}{\rho-\mu_{1}}\cdot\frac{1-\delta_{3}}{-\delta_{3}}.$
(30)

Recall that

$\frac{1-\delta_{1}}{-\delta_{1}}=\frac{\rho-\frac{\mu_{1}+\mu_{2}}{2}+\frac{1+\sqrt{B_{2}}}{2}\sigma}{\rho-\mu_{1}},\mbox{
and
}\frac{1-\delta_{3}}{-\delta_{3}}=\frac{\rho+\lambda_{0}+\lambda_{1}-\frac{\mu_{1}+\mu_{2}}{2}+\frac{1+\sqrt{B_{3}}}{2}\sigma}{\rho+\lambda_{0}+\lambda_{1}-\mu_{1}}.$

Then (30) is reduced to

$\frac{\rho+\lambda_{0}+\lambda_{1}-\mu_{2}}{\rho-\mu_{2}}\left(\rho-\frac{\mu_{1}+\mu_{2}}{2}+\frac{1+\sqrt{B_{2}}}{2}\sigma\right)>\rho+\lambda_{0}+\lambda_{1}-\frac{\mu_{1}+\mu_{2}}{2}+\frac{1+\sqrt{B_{3}}}{2}\sigma.$

This is equivalent to

$\displaystyle(\rho+\lambda_{0}+\lambda_{1}-\mu_{2})\left(\rho-\frac{\mu_{1}+\mu_{2}-\sigma}{2}\right)-\left(\rho+\lambda_{0}+\lambda_{1}-\frac{\mu_{1}+\mu_{2}-\sigma}{2}\right)(\rho-\mu_{2})$
$\displaystyle>$
$\displaystyle(\rho-\mu_{2})\frac{\sqrt{B_{3}}}{2}\sigma-(\rho+\lambda_{0}+\lambda_{1}-\mu_{2})\frac{\sqrt{B_{2}}}{2}\sigma$
$\displaystyle=$
$\displaystyle\frac{\sigma}{2}(\rho-\mu_{2})(\sqrt{B_{3}}-\sqrt{B_{2}})-(\lambda_{0}+\lambda_{1})\frac{\sqrt{B_{2}}}{2}\sigma.$

We can simplify the above inequality and it is equivalent to

$(\lambda_{0}+\lambda_{1})(1+\frac{\mu_{2}-\mu_{1}}{\sigma}+\sqrt{B_{2}})>(\rho-\mu_{2})(\sqrt{B_{3}}-\sqrt{B_{2}}).$
(31)

Note that

$\sqrt{B_{3}}-\sqrt{B_{2}}=\frac{B_{3}-B_{2}}{\sqrt{B_{3}}+\sqrt{B_{2}}}=\frac{4(\lambda_{0}+\lambda_{1})}{\sigma}\cdot\frac{1}{\sqrt{B_{3}}+\sqrt{B_{2}}}.$

We can reduce (31) to

$\left(1+\frac{\mu_{2}-\mu_{1}}{\sigma}+\sqrt{B_{2}}\right)(\sqrt{B_{3}}+\sqrt{B_{2}})>\frac{4(\rho-\mu_{2})}{\sigma}.$

This is equivalent to

$\left(1+\frac{\mu_{2}-\mu_{1}}{\sigma}+\sqrt{B_{2}}\right)\sqrt{B_{3}}+\left(1+\frac{\mu_{2}-\mu_{1}}{\sigma}\right)\sqrt{B_{2}}>\frac{4(\rho-\mu_{2})}{\sigma}-B_{2}.$

Then we note that

$\displaystyle\frac{4(\rho-\mu_{2})}{\sigma}-B_{2}=\frac{4(\rho-\mu_{2})}{\sigma}-\left(1+\frac{\mu_{1}-\mu_{2}}{\sigma}\right)^{2}-\frac{4(\rho-\mu_{1})}{\sigma}$
$\displaystyle=$
$\displaystyle\frac{4(\mu_{1}-\mu_{2})}{\sigma}-\left(1+\frac{\mu_{1}-\mu_{2}}{\sigma}\right)^{2}=-\left(1-\frac{\mu_{1}-\mu_{2}}{\sigma}\right)^{2}=-\left(1+\frac{\mu_{2}-\mu_{1}}{\sigma}\right)^{2}.$

The inequality is equivalent to

$\left(1+\frac{\mu_{2}-\mu_{1}}{\sigma}+\sqrt{B_{2}}\right)\sqrt{B_{3}}+\left(1+\frac{\mu_{2}-\mu_{1}}{\sigma}\right)\sqrt{B_{2}}>-\left(1+\frac{\mu_{2}-\mu_{1}}{\sigma}\right)^{2}.$

Moving the term $-\left(1+\frac{\mu_{2}-\mu_{1}}{\sigma}\right)^{2}$ to the
left-hand side and we obtain

$\left(1+\frac{\mu_{2}-\mu_{1}}{\sigma}+\sqrt{B_{2}}\right)\left(1+\frac{\mu_{2}-\mu_{1}}{\sigma}+\sqrt{B_{3}}\right)>0.$
(32)

Then we apply

$\sqrt{B_{2}}>|1+\frac{\mu_{1}-\mu_{2}}{\sigma}|\quad\text{and}\quad\sqrt{B_{3}}>|1+\frac{\mu_{1}-\mu_{2}}{\sigma}|$

to obtain

$1+\frac{\mu_{2}-\mu_{1}}{\sigma}+\sqrt{B_{2}}>\begin{cases}2&\text{if
$\sigma>\mu_{2}-\mu_{1}$},\\\ \frac{2(\mu_{2}-\mu_{1})}{\sigma}\geq 2&\text{if
$\sigma\leq\mu_{2}-\mu_{1}$}.\end{cases}$

Similarly, $1+\frac{\mu_{2}-\mu_{1}}{\sigma}+\sqrt{B_{3}}>2$. So (32) follows.
Therefore, $C_{2}>0$. $\Box$

## Acknowledgments

This work is supported jointly by the Australian Research Council Discovery
Project DP200101550, the Natural Science Foundation of China 11831010 and
61961160732, the Natural Science Foundation of Shandong Province ZR2019ZD42
and the Taishan Scholars Climbing Program of Shandong TSPD20210302.

## References

  * [1] M. Dai, Q. Zhang, and Q. Zhu, Trend following trading under a regime switching model, _SIAM J. Financial Mathematics_ 1 (2010), 780-810.
  * [2] A. Deshpande and B.R. Barmish, A general framework for pairs trading with a control-theoretic point of view, _Proceedings of the IEEE Conference on Control Applications (CCA)_ September 19-22, 2016. Buenos Aires, Argentina.
  * [3] P. Dupuis and H. Wang, Optimal stopping with random intervention times, _Adv. Appl. Probab._ 34 (2002), pp. 141-157.
  * [4] R.J. Elliott, J. Van Der Hoek, and W.P. Malcolm, Pairs trading, _Quantitative Finance_ 5 (2005), 271–276.
  * [5] E. Gatev, W.N. Goetzmann, and K.G. Rouwenhorst, Pairs trading: Performance of a relative-value arbitrage rule, _Review of Financial Studies_ 19 (2006), 797-827.
  * [6] X. Guo and Q. Zhang, Optimal selling rules in a regime switching model, _IEEE Transactions on Automatic Control_ 50 (2005), 1450-1455.
  * [7] Y. Hu and B. Øksendal, Optimal time to invest when the price processes are geometric Brownian motions, _Finance and Stochastics_ 2 (1998), 295-310.
  * [8] S. Iwarere and B.R. Barmish, A confidence interval triggering method for stock trading via feedback control, _Proc. American Control Conference_ 2010, Baltimore, MD.
  * [9] R. McDonald and D. Siegel, The value of waiting to invest, _Quarterly J. Economics_ 101 (1986), 707-727.
  * [10] J.L. Menaldi and M. Robin, On some optimal stopping problems with constraint, _SIAM J. Control Optim._ 54, pp. 2650-2671, (2016).
  * [11] A. Merhi and M. Zervos, A model for reversible investment capacity expansion, _SIAM J. Control. Optim._ 46 (2007), 839-876.
  * [12] B. ${\O}$ksendal, _Stochastic Differential Equations_ , 6th Ed., Springer-Verlag, New York. 2003.
  * [13] Q.S. Song and Q. Zhang, An optimal pairs-trading rule, _Automatica_ 49 (2013), 3007-3014.
  * [14] J. Tie, H. Zhang, and Q. Zhang, An Optimal strategy for pairs-trading under geometric Brownian motions, _J. Optimization Theory Applications_ 179 (2018), 654-675.
  * [15] M. Whistler, _Trading Pairs: Capturing Profits and Hedging Risk with Statistical Arbitrage Strategies_ , John Wiley and Sons, 2004.
  * [16] Q. Zhang, Stock trading: An optimal selling rule, _SIAM J. Contr. Optim._ 40 (2001), 64-87.
  * [17] H. Zhang and Q. Zhang, Trading a mean-reverting asset: Buy low and sell high, _Automatica_ 44 (2008), 1511-1518.


#  Xp-GAN: Unsupervised Multi-object Controllable Video Generation

1st Bahman Rouhani  Faculty of Computer Engineering
Amirkabi University of Technology
Tehran, Iran
<EMAIL_ADDRESS>2nd Mohammad Rahmati  Faculty of Computer Engineering
Amirkabi University of Technology
Tehran, Iran
<EMAIL_ADDRESS>
###### Abstract

Video Generation is a relatively new and yet popular subject in machine
learning due to its vast variety of potential applications and its numerous
challenges. Current methods in Video Generation provide the user with little
or no control over the exact specification of how the objects in the generate
video are to be moved and located at each frame, that is, the user can’t
explicitly control how each object in the video should move. In this paper we
propose a novel method that allows the user to move any number of objects of a
single initial frame just by drawing bounding boxes over those objects and
then moving those boxes in the desired path. Our model utilizes two
Autoencoders to fully decompose the motion and content information in a video
and achieves results comparable to well-known baseline and state of the art
methods.

###### Index Terms:

Generative Adversarial Networks, GANs, Autoencoders, AEs, Video Generation,
Controllable Video Generation.

##  I Introduction

With the introduction of Generative Adversarial Networks [1], the tasks of
image generation and consequently video generation have seen great progress
[2] [3] [4] [5] [6].

Despite all these progress however, a very desirable feature is lacking. The
current video generation methods offer little to no control over how the
generated video is to behave, that is, there are currently few models that
allow the user to choose how the elements of a video should move and behave in
the generated video. This is a desired feature since it opens a large area of
applications for video generation. For example one can use video generation to
create high quality animations. Some methods allow the user to implicitly
control the final video by conditioning the output video on some input e.g.
the initial frame [7], the initial and final frame [8] or a text input [9] or
changing the style of a video with another [10] [11]. These methods have some
shortcomings. A text input or few frames are too implicit; the user can’t
specify every move and detail by text or a small number of frames. Specifying
initial and final frame will not guarantee what path the video takes to get
from initial frame to the final frame. Style transfer models [10] [12] [13]
allow the user to change the style of one video with another, e.g. turn a
video to its semantic map or vice versa. However creating a video semantic map
video is still a computationally expensive task on its own.

Recently GameGAN [14] was introduced which simulates a game environment,
allowing the user to control the agents actions with keyboard. While GameGAN
needs labeled data, a newer method called CADDY [15] allows unsupervised
playable video generation where the user controls the main object in the scene
by pressing keys. However these methods are still not fully controllable.
GameGAN can’t be used for general purpose video generation since it requires
labeled data. Moreover, both of these methods only allow the user to control
one object (game agent or the main moving object in the scene). Finally both
GameGAN and CADDY only allow the already observed actions to take place, in
other words, the object can only move in a way that the network has seen
before. These problems vastly limit the ability of model in generating
arbitrary videos.

We propose a model that allows the unsupervised generation of video where user
is allowed to control multiple objects and move them in novel ways. The user
has control over objects through a schematic motion reference video where each
object in the final video is represented by a simple rectangle, and the
movement of rectangles dictate how the objects in the final video should move.
We specify what the objects are, how they look and what environment they are
in by providing a single content reference image. In the first frame of our
motion reference video, every rectangle is located on the same pixels as its
corresponding object so the network knows which object each rectangle refers
to. Similarly in the generated video, the first frame looks like the reference
content image, and the objects move according to their corresponding rectangle
in the motion reference video. A general schema of the inputs and output can
be seen in figure 1.

Figure 1: General view of Xp-GAN. The content reference image determines the
objects and how they look while the motion reference image determines how they
move and where they should be in each frame.

It should be noted that generating the motion reference video has almost no
computational cost, since it only consists of a blank background and a number
of rectangles. This input can be easily generated with a few lines of code, or
indeed via a user-friendly interface by which user can drag each object in its
desired path. Alternatively, the video can be set to be controlled via
keyboard as in GameGAN and CADDY.

We utilize two Auto-Encoders to decompose content and motion information and
encode them in a latent space. A Generator is then trained to generate videos
based on these information. We train this generator both adversarial loss via
a Discriminator network and by a reconstruction loss in the conventional
Autoencoder training fashion. The intuition behind this training is that
learning to reconstruct a video is less computationally intense and much more
stable. After the network learns the simpler task of reconstructing a video,
we start adversarial training where the network learns to produce videos with
better quality and with more diversity.

Our model is able to generate videos with a quality comparable to the state of
the art with objects moving correctly with respect to their references.

The rest of this paper is structured as follows: in the Section II we discuss
related works. Section III describes our method by first defining the problem
of controllable video generation and outlining the overall structure of our
model before going into details of the model. In section IV the implementation
details are discussed. We report the performance of Xp-GAN and draw
conclusions in sections V and VI respectively.

##  II Related works

###  II-A Video Generation

Vondrick et al [6] introduce VGAN which generates videos trough two streams,
one that generates a background and one that generates a foreground. These two
streams are then combined by a mask that applies appropriate weights to
foreground and background pixels. While VGAN maps a vector $z$ in the latent
space to a background and foreground video, TGAN [5] first uses a temporal
generator to map a vector $z$ in latent space to a sequence of vectors in an
intermediate space representing a sequence of frames which are then fed to an
image generator network to generate the corresponding frames.

This approach still ultimately maps each video to a vector in the initial
latent space, therefore Tulyakov et al [4] introduced MoCoGAN which considers
each frame a vector in space and assumes videos are generated by traversing
through these vectors with arbitrary speeds. Moreover, MoCoGAN learns to
generate a video based on decomposed content and motion vectors. This
architecture also introduces two discriminators: a video discriminator which
is trained to distinguish between real and fake videos and an image
discriminator which focuses on distinguishing between real and fake single
frames sub-sampled from the video. DVDGAN [3] also uses a temporal and a
separate spatial discriminator. However to make these networks more scalable,
the temporal network is trained on downsampled videos.

Kahembwe et al [16] argue that the 3D kernels used in video discriminators
(namely on those of VGAN and MoCoGAN) results in higher curvature in the loss
landscape, rendering the optimization harder and less stable. With this in
mind LDVD-GANs are introduced which decompose 3D convolutions into 2D
convolutions followed by 1D temporal convolution layers. This significantly
reduces the parameter count in the model whilst stabilizing the training
procedure.

###  II-B Conditional and Constrained Video Generation

A sub-class of video generation is condition or constrained video generation
in which the generated video is conditioned on some input other than the
noise. This input can be category [4], text [17] [9], or another video [10]
[11] [13], or some input images [7] [8].

A popular task in conditional video generation is video translation in which
the input is another video and the output is usually the same video in a
different domain, style or setting [10] [11] [13]. Cycle-GAN [12] uses two
generators to transfer a video from original domain $a$ to a domain $b$. The
generator $G_{b}$ transfers each image $I_{a}$ from domain $a$ to domain $b$
and generator $G_{a}$ then translates the same image $G_{b}(I_{a})$ back to
the original domain $a$. The cycle consistency loss is the difference between
the reconstructed image $G_{a}(G_{b}(I_{a}))$ and the original image $I_{a}$.
Recycle-GAN [10] also uses cycle consistency, however this method additionally
uses the temporal information to transfer videos. Each frame $x^{t}_{a}$ in
domain $a$ and time $t$ is first translated to another domain in the same
fashion as Cycle-GAN, then a prediction network $P_{y}$ generates the next
frame based on this translated frame, and the predicted frame is transferred
back to the original domain. The loss function here is the distance between
frame $x^{t+1}_{a}$ and its reconstructed $G_{a}(P_{y}(G_{b}(x^{t}_{a})))$.
Building on the same idea, MoCycleGAN [13] uses optical flow between two
consecutive frames two predict the next frame in the second domain, while also
directly translating the warping between two consecutive frames and comparing
them.

Other tasks involve different conditional inputs. Yitong et al [17] use GANs
and Variational Autoencoders (VAEs) to generate a video from text. Marwah et
al [9] use a VAE along with two soft attention mechanism (one for short-term
and one for long-term) two solve the same problem. Given a single image,
ImagineFlow network [7] can generate a video starting with that image.
ImagineFlow uses a network to predict and generate a flow for the given image
and then uses the final frame to predict the backward flow, leading back to
the original image and ensuring bi-directional consistency. Wang et al [8]
define and solve the task of point to point video generation, where given an
initial and target frame, the model generates a video starting from the former
and ending in latter.

###  II-C Controllable Video Generation

An emerging task in video generation is to explicitly control the movement of
object or objects in the video through users instructions. For example
controlling how the agent in the video should move by pressing different keys
or by moving a corresponding object in the desired path. Note that this is
different from video to video translation in that the user has direct and
arbitrary control over the movement of objects in the video, while in video
translation the user can replace the movement of a video with that of another
realistic video which is computationally costly to produce.

GameGAN [14] aims to simulate a game environment using GANs. The architecture
consists of a dynamic module responsible for learning the game logic, a
rendering module for generating high quality frames and an external memory
module for saving the game state. The framework is trained on video-game
footage and the keys player pressed between each two frames.

CADDY (Clustering for Action Decomposition and DiscoverY) [15] solves the
problem of controllable video generation in an unsupervised manner.
Specifically, an encoder is used to extract frame representation. An action
model uses the frame representations to predict the action taking place and a
recurrent model uses the frame representations along with the predicted action
to predict the next state. Finally the predicted states are fed to a decoder
to reconstruct the frame. In this way the network learns the action and state
space simultaneously.

##  III Proposed Model

###  III-A Problem Definition

Let us denote a realistic video of length $n$ with $V=\\{f_{1},...,f_{n}\\}$
with $f_{t}$ being the frame at time $t$. We show the distribution of all such
realistic videos with $\mathbb{P}_{v}$. Supposing there are $m$ objects
present in the video, we show all their locations in each frame by
$L=[\\{l^{1},...,l^{m}\\}_{1},\dotsc\\{l^{1},...,l^{m}\\}_{n}]$ where $l^{i}$
denotes the location of $i$th object and $\\{l^{1},..,^{m}\\}_{t}$ denotes
$t$th frame. Finally, consider a function $\mathcal{H}(.)$ which given a
video, will output the location of its objects (i.e. an object detection and
tracking algorithm):

$\mathcal{H}(V)=[\\{l^{1},...,l^{m}\\}_{1},\dotsc\\{l^{1},...,l^{m}\\}_{n}].$
(1)

Given an initial frame $f_{1}$ and a set of location instructions $L$ we would
like to generate the video $\widetilde{V}$ such that its probability of
belonging to $\mathbb{P}_{v}$ is maximized. We would also like the locations
of objects in the generated video, $\mathcal{H}(\widetilde{V})$, to match $L$.
Thus we define our goal as finding $\widetilde{V}$ such that:

$\displaystyle\begin{split}Max_{\widetilde{V}}\mathbb{P}_{v}(\widetilde{V})\;\;s.t\\\
\widetilde{V}=\\{\widehat{f}_{1},...,\widehat{f}_{n}\\},\\\
\widehat{f}_{1}\simeq f_{1},\\\ \mathcal{H}(\widetilde{V})\simeq L\end{split}$
(2)

###  III-B Overall pipeline

We use a pre-trained object tracking model $\mathcal{H}$ to create motion
reference videos $V_{\mathcal{M}}$ from regular videos $V$. All the pixels
inside bounding boxes where objects where detected are set to 1 (or white) and
all other pixels are masked with 0 (black). Some sample frames of motion
reference videos are shown at figure 2 below their matching original frames.

Figure 2: Two frames from training video (top), the corresponding frames in
the motion reference video (middle) and the product of the original frame and
the motion reference frame (bottom). When original frames from $V$ are
multiplied by corresponding frames from motion reference video
$V_{\mathcal{M}}$, the background is masked but the objects are preserved
since their pixels in $V_{\mathcal{M}}$ are set to 1.

We then employ a Variational Autoencoder (VAE) called Content VAE to extract
content information from a single image (hereafter referred to as the content
reference image) and another VAE called Motion VAE to extract motion
information from the a schematic video (called motion reference video). We
denote the encoder for our Content and Motion VAEs as $E_{c}(.)$ and
$E_{m}(.)$ respectively. The two VAEs are trained separately to reconstruct
the motion reference video and reference content image and each use their own
specific loss functions. We will discuss these details on sections III-C and
III-D respectively.

Figure 3:  Pre-processing is done to mask videos and generate their matching
motion reference video. We also use an Autoencoder to further more separate
the foreground and background. The reason for this and details are explain in
IV. After Content-VAE and Motion-VAE are trained, they are used to provide
latent information for the Generator. The Decoder part of Generator is first
trained to minimize a reconstruction loss. Then the whole Generator is trained
adversarially along with the Discriminator.

Our Generator consists of two sub-modules: a Decoder $D(.)$, responsible for
learning for reconstructing a rough sketch of the final video and a Super
Resolution Module $SR(.)$ which helps the enhancement of quality and
consistency in the videos. After training the two VAEs, for each video $V$ in
dataset we feed its motion reference video $V_{\mathcal{M}}$ to the Motion
Encoder and its first frame $f^{1}$ to the Content Encoder. The extracted
motion information $M$ and content information $C$ are then concatenated and
fed to the Decoder which is trained to reconstruct the video. We can show
these operations as equations 3 to 6 where $\widehat{V}$ is the reconstructed
video, $\widetilde{V}$ is the final generated video and $z$ is the noise
accounting for randomness in the final video and $\langle\rangle$ denotes the
concatenation of two vectors.

$\displaystyle L=E_{m}(V_{\mathcal{M}}),$ (3) $\displaystyle C=E_{c}(f_{1}),$
(4) $\displaystyle\widehat{V}=D(\langle L,C\rangle),$ (5)
$\displaystyle\widetilde{V}=SR(\widehat{V},z)$ (6)

The Decoder $D$ is trained as a decoder on reconstruction loss:

$L_{D}=|D(\langle L,C\rangle)-V|_{1}$ (7)

Finally we train the Decoder along with the Super Resolution module in our
Generator and the Discriminator similar to Wasserstein-GAN with gradient
penalty [18].

###  III-C Motion VAE

The Motion VAE has the task of reconstructing the motion reference video. We
use a DCNN (Deep Convolutional Neual Net) with 3D-convolution for this
network.

In a general setting, there is no guaranteed bound on the ratio of number of
foreground to background pixels which means one can be significantly greater
than the other. This presents a challenge to the training of the network. When
number of black and white pixels are significantly different, the network
converges to the local minima of reconstructing a blank white or black image
since this will result in a relatively low (and close to optimal) loss. It
should be noted that this point in solution space is far from the optimal
point of reconstructing the image so the network fails to exit this state.
This can also be explained as the network ”denoising” the video. Denoising is
a well-known feature of Autoencoders [19] [20] [21] [20]. This feature results
in the unwanted blank black or white reconstructed image when one set of the
regions are small enough to be treated as noise.

Another challenge arises from the speed of objects in the videos.
Specifically, if the objects move too slowly, the network can achieve a low
loss by just reconstructing the same frame for the whole video. In this case
the network will learn to encode the information pertaining the location of
objects but not their movement.

To overcome the first challenge, we generate a pixel-wise weight matrix for
each motion reference video, where the foreground and background pixels are
weighed such that the overall sum of both sets will be ultimately equal. We
first reconstruct the video, then count the number of foreground and
background pixels in both original and reconstructed video. We consider a
pixel as foreground if its labeled as foreground in either original or
reconstructed image since in our dataset background pixels outnumber those of
foreground. Consider the motion reference video $M$ and its reconstruction
$\widehat{M}$, a function $N_{fg}(.)$ which takes as input a video and returns
the number of foreground pixels and $|M|$ as the total number of pixels in $M$
and denote logical ”OR” operation with $\lor$, we then calculate the weight
matrix $W$ as 8.

$\displaystyle\begin{split}M_{fg}=\widehat{M}\lor M,\\\
W_{bg}=\dfrac{N_{fg}(M)+N_{fg}(\widehat{M})+\epsilon}{2\times|M|},\\\
W_{fg}=\dfrac{2\times|M|-N_{fg}(M)+N_{fg}}{2\times|M|},\\\
W(i,j)=\begin{cases}W_{fg}\;\;if\;\;M_{fg}(i,j)=1\\\
W_{bg}\;\;if\;\;M_{fg}(i,j)=0\end{cases}\end{split}$ (8)

To address the second challenge, we calculate the difference between each
frame and its previous frame. To be exact, we calculate the ”exclusive or”
(XOR) of each frame and its previous frame except for the first frame. This
operation finds the pixels that have changed in the new frame. We then
increase the weight of these pixels to a factor $\lambda$. We find that a good
value for $\lambda$ can be twice the calculated weight for foreground (or the
maximum of the in general). For the first frame of each video, we do not
increase weight of any pixels. We construct a difference weight matrix in this
way as stated in equation 9 where $\oplus$ denotes the XOR operation,
$M^{i:j}$ denotes the frames $i$ to $j$ inclusive and $0$ is a zero matrix the
same size as a single frame, which we concatenate to $M_{diff}$ so it has the
same dimensions and shape as $W$ in equation 8.

$M_{diff}=M^{1:n-1}\oplus M^{2:n},\;\;\;W_{diff}=\langle
0,M_{diff}\times\lambda\rangle$ (9)

The Motion Weighed loss function (denoted with $L_{MW}$) for our Motion VAE is
then calculated as in equation 10 where $\odot$ is pixel-wise multiplication
and the $||$ denotes absolute value (not norm).

$\displaystyle L_{MW}=Mean(|M-\widehat{M}|\odot[W_{bg}+W_{diff}])$ (10)

Figure 4 shows a very simple view of this network with two reconstructed
samples.

Figure 4: The Motion VAE and two reconstructed samples (right). Each image is
16 frames of a video. The two top images contain some incorrect detection and
maskings (the bigger rectangles). The lower images depict a case where
detection system failed to detect objects in some of the frames, this is
interpolated by the Motion VAE.

###  III-D Content VAE

When generating our final video, we want the location and motion of objects to
be exclusively dependent on the motion encoding provided by our Motion VAE.
That is to say, when generating videos with fixed motion encoding, any change
in the content encoding should not affect the location of the objects. To
ensure this, we would like our content encoding to contain as little motion or
location information as possible. A naive approach is to reconstruct a single
frame to encode the content information since a single frame does not contain
any information about how the items in the scene will move. This frame will,
however, contain information about where the objects are initially located.

To train our Content VAE to exclusively encode content information, we
leverage the motion reference videos. To be specific, we modify the
established $L_{1}$ reconstruction loss used for training of Autoencoders so
that the network will not be penalized greatly on where the objects are
reconstructed. We define Content Weight Loss (denoted with $L_{CW}$) as in
equation 11 where $\odot$ is pixel-wise multiplication and $M_{1}$ is the
first frame in the motion reference video and the $||$ denotes the absolute
value rather than norm.

$L_{CW}=Mean(|\widehat{f}-f|\odot M_{1})$ (11)

By multiplying the loss with the corresponding frame in motion reference
video, we effectively mask the loss function on the pixels where no object was
present. This in turn allows the network to reproduce objects not just in the
exact location the object resides, but also on the neighboring regions on
which there is no other object. Figure 5 shows two examples of how this loss
works. The reconstructed image on itself is chaotic and makes no sense to
human eye since the objects have been reproduced with no location restraint.
After applying the mask however it is visible that the objects (soccer players
in this case) are fully and correctly reconstructed.

In practice, here we use a more delicate type of masking instead of using the
motion reference video. This is because in cases where the objects are
relatively small and the camera is fixed the VAE tends to only reconstruct the
background and not the foreground objects. Masking the background with motion
reference video somewhat alleviates this problem. When the objects are small
though, the network can still learn to only reconstruct the background since
the bounding boxes around objects still contain more of background rather than
the objects. We explain how these more exact masks are generated in section
IV.

Figure 5: The Content VAE reconstructs images, masks the background and then
applies the loss function which results in correct reconstruction in desired
areas and no limit on what can be on other regions.

###  III-E Generator

Our Generator module consists of two sub-modules, a Decoder which is tasked
with generating a rough sketch of the video and a Super Resolution module
which will help the Generator to generate better quality videos. This is
intended to help stabilize and accelerate the learning process in GANs.
Reconstructing a set of videos is an inherently simpler task rather than
learning to generate novel and new videos. Therefor we first train our system
to simply learn reconstructing some videos. After the Decoder learns to
generate the general structure and overall view of video, we use adversarial
learning to improve the quality of this images and also allow for generation
of new images.

In the first stage of training, only the Decoder network is trained. We feed a
single frame to our Content Encoder and a motion reference video to our Motion
Encoder, the encoding from these two networks is then concatenated and fed to
the decoder, which is trained to reconstruct the original video. When training
the Super Resolution, in contrast to the previous stage, we do not use
encodings from Motion and Content Encoder but rather sample these two vectors
from a normal distribution. In this way we ensure that our network will learn
to generate new videos. Figure 6 shows the pipeline for Generator module.

Figure 6: The Generator module. Our Decoder is first trained to produce a
rough sketch of the video. The whole generator is then trained in an
adversarial manner.

##  IV Implementation details

As mentioned in section III-D, we use a more exact and delicate masks for the
training of our Content VAE. These masks cover almost all of the background
and none of the foreground. The reason for using this type of mask, as
explained more extensively in section III-D, is that when presented with
images of small objects, the VAEs only learn to reconstruct the background of
images. In these cases we use this aspect of VAEs to our advantage. We train
an ordinary Autoencoder on these images (with the regular $L_{1}$ loss) which
only learns to generate the background. We then use this AE to subtract and
remove the acquired background from the images. The original frame $f$ and the
background of that frame $f_{bg}$ are subtracted and the pixels where the
absolute value of the results is higher than a threshold are set to 1, and the
remaining pixels are set to 0. Figure 7 shows this process.

Figure 7: An Autoencoder is trained to extract the background of each image.
we then use this extracted background to detect the foreground objects in all
the frames of each video.

Since we want our network to learn the shape of the objects, we leave out some
of the background around the margins of foreground. This is done by applying a
Gaussian kernel to the resulting mask to widen the white regions of the masks.
For our dataset we use a $10$ kernel.

##  V Experiments

We train our method on Alfheim dataset [22] consisting of footage of soccer
games captured on 3 different cameras. We also train RecycleGAN [10], MocoGAN
[4] and ldvdGAN [16] on this dataset and measure the Frechet Inception
Distance (FID) [23] for all these methods. We train MocoGAN and ldvdGAN as
conventional GANs with no conditional input. To train RecycleGAN we consider
the original videos of Alfheim dataset as the domain $A$ and their motion
reference videos as domain $B$. This network is then asked to apply style
transfer to motion reference videos, converting them to realistic videos. We
use random vectors sampled from a Normal distribution two generate videos with
Xp-GAN rather than with encoding from Motion and Content AE. This is to ensure
a fair comparison since Xp-GAN might perform better when the encodings are
extracted from real videos.

For each method we produce 15 sets of 300 videos and compute FID for each set.
We use these sets to a confidence interval for our results using
bootstrapping. These results are shown in table I.

FID $\downarrow$ | Xp-GAN* | ldvdGAN | RecycleGAN | MocoGAN
---|---|---|---|---
Mean | 156.21 | 194.48 | 297.69 | 144.74
Variance | 6.69 | 0.1999 | 8.27 | 0.31
Best result | 151.23 | 193.48 | 293.56 | 143.96
Worst result | 161.47 | 195.19 | 305.07 | 145.90
TABLE I: FID of evaluated methods. It should be noted that all methods perform
better on this dataset since it has a lower complexity. Our method (Xp-GAN)
has been distinguished by an asterisk. Figure 8: 4 frames (frames 1, 5, 9 and
13) from a video Alfheim generated by the network when trained on Alfheim
dataset.

Overall we find that our method is able to generate fully controllable videos
from a single initial reference frame and a simple low complexity schematic
video while maintaining relative quality to state of the art methods. Our
experiments show that the model is able to move the objects in the scene
according to the reference motion video as long as the movements are within
bounds of natural movement. Figures 8 and 9 show examples of generated videos.

Figure 9: 4 frames (frames 1, 5, 9 and 13) from a generated video (top left),
the matching motion reference frame (bottom left) and the content reference
image (right).

We also test our model on motion reference videos with un-natural movements,
that is, movements that differ highly with what the network has seen on
dataset e.g. all the soccer players moving exactly in a single unusual
direction. We find that our model does slightly drift in these cases, which
might be resolved by using larger datasets.

##  VI Conclusions and Future Work

We introduce a novel method to generate videos in a more controllable setting
than the current state of the art methods. Our model allows the user to select
an arbitrary number of objects and move them in a specified path by placing a
rectangle on them and moving the rectangles in the desired path. Our method is
able to produce results comparable to baseline models in quality on the
selected datasets. Moreover, we ease the training process by first training
and Autoencoder and then training the whole network adversarially.

Our method can be improved through adding support for objects of different
types as at the moment, all moving object are of the same type. The same model
might be able to generate videos with multiple objects provided it was
modified to have a greater capacity for learning and generalizing, since in
theory, the model should be able to distinguish which rectangle corresponds to
which object based on their location and therefore infer how to generate its
corresponding object. A better approach would be to make use of all the
information provided by the object detection algorithm and encode the object
category into the rectangle instead of the value $1$ for all the pixels.

Our proposed method was applied to baseline and simple AE and GAN models which
results in average quality and performance due to our limitations in
processing power. Another improvement to the current model would be applying
the same workflow to more complicated GAN models with higher number of
parameters which usually yields better quality and allows for higher
resolution.

The model could also benefit from more frame count or ideally generating
videos with an arbitrary number of frames.

We believe this model can be built upon and used widely in day to day
applications after few improvements. We speculate that developing models that
learn to generate videos more specifically and explicitly would be a natural
next step for the research in video generation.

## References

  * [1] I. J. Goodfellow, J. Pouget-Abadie, M. Mirza, B. Xu, D. Warde-Farley, S. Ozair, A. Courville, and Y. Bengio, “Generative adversarial networks,” _arXiv preprint arXiv:1406.2661_ , 2014.
  * [2] J. Pan, C. Wang, X. Jia, J. Shao, L. Sheng, J. Yan, and X. Wang, “Video generation from single semantic label map,” in _Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition_ , 2019, pp. 3733–3742.
  * [3] A. Clark, J. Donahue, and K. Simonyan, “Adversarial video generation on complex datasets,” _arXiv preprint arXiv:1907.06571_ , 2019.
  * [4] S. Tulyakov, M.-Y. Liu, X. Yang, and J. Kautz, “Mocogan: Decomposing motion and content for video generation,” in _2018 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)_. IEEE Computer Society, 2018, pp. 1526–1535.
  * [5] M. Saito, E. Matsumoto, and S. Saito, “Temporal generative adversarial nets with singular value clipping,” in _2017 IEEE International Conference on Computer Vision (ICCV)_. IEEE, 2017, pp. 2849–2858.
  * [6] C. Vondrick, H. Pirsiavash, and A. Torralba, “Generating videos with scene dynamics,” in _Proceedings of the 30th International Conference on Neural Information Processing Systems_ , 2016, pp. 613–621.
  * [7] L. Sheng, J. Pan, J. Guo, J. Shao, X. Wang, and C. C. Loy, “Unsupervised bi-directional flow-based video generation from one snapshot,” _arXiv preprint arXiv:1903.00913_ , 2019.
  * [8] T.-H. Wang, Y.-C. Cheng, C. H. Lin, H.-T. Chen, and M. Sun, “Point-to-point video generation,” in _Proceedings of the IEEE/CVF International Conference on Computer Vision_ , 2019, pp. 10 491–10 500.
  * [9] T. Marwah, G. Mittal, and V. N. Balasubramanian, “Attentive semantic video generation using captions,” in _Proceedings of the IEEE International Conference on Computer Vision_ , 2017, pp. 1426–1434.
  * [10] A. Bansal, S. Ma, D. Ramanan, and Y. Sheikh, “Recycle-gan: Unsupervised video retargeting,” in _European Conference on Computer Vision_. Springer, 2018, pp. 122–138.
  * [11] C. Chan, S. Ginosar, T. Zhou, and A. A. Efros, “Everybody dance now,” in _Proceedings of the IEEE/CVF International Conference on Computer Vision_ , 2019, pp. 5933–5942.
  * [12] J.-Y. Zhu, T. Park, P. Isola, and A. A. Efros, “Unpaired image-to-image translation using cycle-consistent adversarial networks,” in _Proceedings of the IEEE International Conference on Computer Vision (ICCV)_ , Oct 2017.
  * [13] Y. Chen, Y. Pan, T. Yao, X. Tian, and T. Mei, “Mocycle-gan: Unpaired video-to-video translation,” in _Proceedings of the 27th ACM International Conference on Multimedia_ , 2019, pp. 647–655.
  * [14] S. W. Kim, Y. Zhou, J. Philion, A. Torralba, and S. Fidler, “Learning to simulate dynamic environments with gamegan,” in _Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition_ , 2020, pp. 1231–1240.
  * [15] W. Menapace, S. Lathuilière, S. Tulyakov, A. Siarohin, and E. Ricci, “Playable video generation,” in _Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition_ , 2021, pp. 10 061–10 070.
  * [16] E. Kahembwe and S. Ramamoorthy, “Lower dimensional kernels for video discriminators,” _Neural Networks_ , vol. 132, pp. 506–520, 2020.
  * [17] Y. Li, M. Min, D. Shen, D. Carlson, and L. Carin, “Video generation from text,” in _Proceedings of the AAAI Conference on Artificial Intelligence_ , vol. 32, no. 1, 2018.
  * [18] I. Gulrajani, F. Ahmed, M. Arjovsky, V. Dumoulin, and A. Courville, “Improved training of wasserstein gans,” in _Proceedings of the 31st International Conference on Neural Information Processing Systems_ , 2017, pp. 5769–5779.
  * [19] P. Vincent, H. Larochelle, Y. Bengio, and P.-A. Manzagol, “Extracting and composing robust features with denoising autoencoders,” in _Proceedings of the 25th international conference on Machine learning_ , 2008, pp. 1096–1103.
  * [20] A. Ashfahani, M. Pratama, E. Lughofer, and Y.-S. Ong, “Devdan: Deep evolving denoising autoencoder,” _Neurocomputing_ , vol. 390, pp. 297–314, 2020.
  * [21] A. Majumdar, “Blind denoising autoencoder,” _IEEE transactions on neural networks and learning systems_ , vol. 30, no. 1, pp. 312–317, 2018.
  * [22] S. A. Pettersen, D. Johansen, H. Johansen, V. Berg-Johansen, V. R. Gaddam, A. Mortensen, R. Langseth, C. Griwodz, H. K. Stensland, and P. Halvorsen, “Soccer video and player position dataset,” in _Proceedings of the 5th ACM Multimedia Systems Conference_ , 2014, pp. 18–23.
  * [23] M. Heusel, H. Ramsauer, T. Unterthiner, B. Nessler, and S. Hochreiter, “Gans trained by a two time-scale update rule converge to a local nash equilibrium,” _Advances in neural information processing systems_ , vol. 30, 2017.