Suppose I have a derivative that will pay $\Phi(S_T)=S_T^2$, where $S_t$ evolves as $$dS_t=\mu S_tdt+\sigma S_tdWt$$
where $(W_t)_{t\geq0}$ is a Brownian motion
I have shown that its price is $V(S_t,t)=S_t^2e^{(r+\sigma^2)(T-t)}$
Now the question asks from me to calculate the replication portfolio of this derivative and I am not really sure what to do. My idea was the following:
Consider a self-financing portfolio with $\phi_t$ shares at time $t$ and $\psi_t$ bonds at time $t$:
$$\Pi_t=\phi_tS_t+\psi_tB_t$$
Since it is self financing then we have that
$$(S_t+dS_t)d\phi_t+(B_t+dB_t)d\psi_t=0$$
Since it replicates the payoff at time $T$ we have $$S_T^2=\phi_TS_T+\psi_TB_T$$
and these $2$ conditions (probably?) should be enough to find $\phi_t, \psi_t$.
However, I am struggling to solve this system which makes me think I have a mistake somewhere.
Thanks in advance
so not sure if you had a chance to consider my hint in the comment above, but essentially you've done the hard work already by explicitly pricing the derivative :)
Your solution $V(S_t,t)=S_t^2e^{(r+\sigma^2)(T-t)}$ satisfies the B-S PDE for terminal value claims and obviously hits your boundary condition so it's pretty much done.
There's more than one way to derive the pricing equation obviously (Martingales / PDEs), but in the context of your question regarding a replicating portfolio, it's probably most direct to think in terms of hedging arguments that lead to the B-S PDE. Won't derive the whole thing here as no doubt you're familiar with it but will use the relevant bits.
First, form a replicating portfolio $\Pi_t:=\phi_tS_t+\psi_tB_t$ as you say, to hedge a position $V(S_t,t)$ of our derivative, so that the total 'book' is a portfolio $\hat\Pi_t$ with weights $(-1,\phi_t,\psi_t)$ in our three securities with the obvious notation. As per comment, to determine $\phi_t$ and $\psi_t$, there are unsurprisingly only two things we need to consider:
(i) Volatility Hedge:
You've probably seen this, but quite simply to hedge the $dW_t$ term in the SDE for $V(S_t,t)$ we have to have, in your case: $$\phi_t=\frac{\partial{V}}{\partial S_t}=2S_te^{(r+\sigma^2)(T-t)}$$ Again this drops straight out of the B-S derivation via Ito's lemma once we've stipulated that $-dV+\phi_t dS_t=r(-V+\phi_t S_t)dt$, or that a hedged portfolio can only accrete at the risk-free rate.
(ii) Self-financing:
Our replicating portfolio is self - financing $\iff d\Pi_t:=\phi_tdS_t+\psi_tdB_t$. In order to replicate then, clearly we must have: $$\psi_t=\frac{V(S_t,t)-\phi_t S_t}{B_t}$$ ...where the $V(S_t,t)$ appears since $\Pi_t$ has to replicate $V(S_t,t)$ for all $t$, not just terminally.
Hope that helps / not too long-winded, but essentially the problem's easy if you've understood the replication approach to deriving the B-S PDE (which is admittedly a different flavour to the martingale approach).