Solution (source code)

= Solution

Use the discounted wealth $\widetilde X=X/B$ and the <discounted dividend gains>
$$
Y_t=\frac{S_t}{B_t}+\int_0^t\frac{D_s}{B_s}\,ds.
$$
The integral uses $ds$: the printed $dt$ inside an integral indexed by $s$ is a differential typo. Since $B$ is a positive <finite-variation process>, the <Itô product rule> gives
$$
d\widetilde X_t
=\frac{dX_t}{B_t}-\frac{X_t}{B_t^2}\,dB_t
=\pi_t\cdot\left(\frac{dS_t}{B_t}-\frac{S_t}{B_t^2}\,dB_t+\frac{D_t}{B_t}\,dt\right)
=\pi_t\cdot dY_t.
$$
The bank-account terms cancel using $X_t=\phi_tB_t+\pi_t\cdot S_t$.

If $Y$ is a $Q$-<martingale>, discounted self-financing wealth is a $Q$-<local martingale>. The <admissible trading strategy> lower bound makes it a <supermartingale>, exactly as in the previous no-arbitrage proof. A zero-cost portfolio with nonnegative terminal wealth must therefore have terminal wealth zero $Q$-almost surely and, by equivalence, physically almost surely. Hence \b[an equivalent martingale measure for discounted dividend gains excludes arbitrage]. It is the gains process, not just the ex-dividend price ratio, that must have zero martingale drift.