Moment generating function of a stochastic integral Let $(B_t)_{t\geq 0}$ be a Brownian motion and $f(t)$ a square integrable deterministic function. Then:
$$
\mathbb{E}\left[e^{\int_0^tf(s) \, dB_s}\right] = \mathbb{E}\left[e^{\frac{1}{2}\int_0^t f^2(s) \, ds}\right]
$$
Now assume $(X_t)_{t\geq 0}$ is such that $\left(\int_0^tX_sdB_s\right)_{t\geq 0}$ is well defined. Does 
$$
\mathbb{E}\left[e^{\int_0^tX_s \, dB_s}\right] = \mathbb{E}\left[e^{\frac{1}{2}\int_0^tX_s^2 \, ds}\right]
$$
still hold?
 A: No, in general this is not correct. 
Applying Itô's formula, one can actually show that $$(t,w) \mapsto M(t,w) := \exp \left( \int_0^t X_s \, dB_s - \frac{1}{2} \int_0^t X_s^2 \, ds \right)$$ is a local martingale. There are several sufficient conditions (on the process $(X_t)_t$) implying that $(M_t)_{t \geq 0}$ is indeed a martingale. In this case, one obtains
$$1=\mathbb{E}M_0 = \mathbb{E}M_t = \mathbb{E}  \exp \left( \int_0^t X_s \, dB_s - \frac{1}{2} \int_0^t X_s^2 \, ds \right)$$
Note that this is not equivalent to $$\mathbb{E} \exp \left( \frac{1}{2} \int_0^t X_s^2 \, ds \right) = \mathbb{E}\exp \left( \int_0^t X_s \, dB_s  \right)$$
(It works fine for deterministic functions, since in this case the left-hand side of the last equation does not depend on $\omega$.)
A: If $X$ and $B$ are independent, yes (use the first result to compute the expectation conditional on $X$, then take the expectation). 
Otherwise, no. For a counterexample, consider $X=B$ and use Itô's formula $\mathrm d (B^2)=2B\mathrm dB+\mathrm dt$.
