Solution (source code)

= Solution

Set
$$
M_t=\mathbb E[Y_T\xi_T\mid\mathcal F_t],
\qquad V_t=\frac{M_t}{Y_t}.
$$
The boundedness of $\xi_T$ and positivity of the deflator make $M$ a nonnegative true martingale. By the <Brownian martingale representation theorem>, $dM_t=\eta_t dW_t$. A self-financing wealth process with stock holding $\pi_t$ satisfies
$$
dV_t=\{r_tV_t+\pi_tS_t(\mu_t-r_t)\}dt
+\pi_tS_t\sigma_t dW_t.
$$
The product $YV$ then has diffusion coefficient
$$
Y_t(\pi_tS_t\sigma_t-V_t\lambda_t).
$$
Choose
$$
\pi_t=\frac{\eta_t/Y_t+V_t\lambda_t}{S_t\sigma_t},
\qquad
\phi_t=\frac{V_t-\pi_tS_t}{B_t}.
$$
Then $Y_tV_t=M_t$, so $V_T=\xi_T$ and the strategy replicates the claim. It is admissible because $V=M/Y$ is nonnegative.

For any other admissible replicating wealth $\widetilde V$, the nonnegative local martingale $Y\widetilde V$ is a supermartingale. Hence
$$
\widetilde V_0\geq\mathbb E[Y_T\widetilde V_T]
=\mathbb E[Y_T\xi_T].
$$
The constructed strategy has
$$
\boxed{V_0=\phi_0B_0+\pi_0S_0
=\mathbb E[Y_T\xi_T],}
$$
so this is the minimal replication cost.