Solution
= Solution
Between times $n-1$ and $n$, the investor holds $\theta_n$ shares worth $\theta_nS_{n-1}$ and places the remaining wealth $X_{n-1}-\theta_nS_{n-1}$ in the risk-free asset. The <self-financing portfolio>[self-financing] condition therefore gives
$$
\begin{aligned}
X_n
&=\theta_nS_n+(1+r)(X_{n-1}-\theta_nS_{n-1})\\
&=(1+r)X_{n-1}
+\theta_n[S_n-(1+r)S_{n-1}].
\end{aligned}
$$