# derivation of the hedging error in a black scholes setup

I'm reading the following short paper by Davis. In section 2.6 he wants to derive an expression for the hedging error. Assume we have Black scholes setup:

$$dS_t = S_t(r dt + \sigma dW_t)$$ $$dB_t = B_t r dt$$

and let $C_h(S, r, \sigma, t) = C(t,S_t)$ be the price time $t$ of an option with exercise value $h(S_T)$. By selling at time $0$ the option we receive $C_h(S_0, r, \hat{\sigma},0)$, where $\hat{\sigma}$ is the implied volatility. He assumes that $\sigma = \hat{\sigma}$, the model volatiltiy is correct.

Assuming that our model is not correct, instead $S$ follows a SDE

$$dS_t = S_t(\alpha(t,\omega)dt + \beta(\omega, t)dW_t)$$

where the involved processes satisfy some regularity condition. We delta hedge the sold option, i.e. the value of our portfolio $X_t$ is given by $X_0=C(0,S_0)$

$$dX_t = \frac{\partial C}{\partial S}dS_t + (X_t -\frac{\partial C}{\partial S}S_t) r dt$$

which is selfinancing. Denoting $Y_t \equiv C(t,S_t)$ and $Z_t = X_t - Y_t$, the hedging error we obtain

$$\frac{d}{dt}Z_t = rX_t - rS_t\frac{\partial C}{\partial S_t}-\frac{\partial C}{\partial t}-\frac{1}{2}\beta^2_t S^2_t \frac{\partial^2 C}{\partial S^2}$$

denoting $\Gamma_t = \frac{\partial^2 C}{\partial S^2}$ and using the Black Scholes PDE we find

$$\frac{d}{dt}Z_t = rZ_t +\frac{1}{2}S_t^2\Gamma_t^2(\hat{\sigma}^2-\beta_t^2)$$

I think the square of the gamma is wrong, it should be $\Gamma_t$.

My question how does he derive the following last expression $(Z_0 = 0)$:

$$Z_T = X_T- h(S_T) = \int_0^T e^{r(T-s)}\frac{1}{2}S^2_t\Gamma^2_t(\hat{\sigma}^2-\beta^2_t)dt$$

I guess the $dt$ should be a $ds$ and all $t$ should be replaced with $s$ under the integral. $Z_T = X_T-h(S_T)$ is clear, thats true by definition. The very last equality is bothering me.

The differential equation has a trend due to the interest rate. When you discount you take this trend away: $$\frac{d}{dt} (e^{-rt}Z_t) = -re^{-rt}Z_t + e^{-rt} \frac{d}{dt}Z_t = e^{-rt}\frac{1}{2}S_t^2\Gamma_t(\hat{\sigma}^2-\beta_t^2)$$ $Z$ doesn't appear on the rhs anymore and you can integrate $$e^{-rT}Z_T - e^{-r0}Z_0 = \int_0^T e^{-rt}\frac{1}{2}S^2_t\Gamma_t(\hat{\sigma}^2-\beta^2_t)\,dt$$ and mulitply by $e^{rT}$ to get the formula. $$Z_T = \int_0^T e^{r(T-t)}\frac{1}{2}S^2_t\Gamma_t(\hat{\sigma}^2-\beta^2_t)dt$$
PS: Note no squared Gamma and no $s$ in the formula.