# FxPaul

Math in finance or vice versa

## Process definition

In this article we deduce the closed-from solution of the modified version of Ornstein-Uhlenbeck process:
$dS = \theta(\mu - S) dt + \sigma S dW_t$
where $\theta$ – mean reversion parameter, $\mu$ – mean and $\sigma$ – volatility.

## Integrating factor approach

There exists a general approach to non-linear stochastic differential equations of the form:
$dX_t = f(t,X_t) dt + c(t) X_t dW_t \, , \, X_0 = x$
where $f$ and $g$ are given continuous and deterministic functions.

The method consists of:

1. Define the integrating factor:
$F_t = F_t(\omega) = \exp\left( - \int_0^t {c(s) dW_s} + \frac{1}{2}\int_0^t {c^2(s) dW_s} \right)$
2. So the original equation could be written as $d\left(F_t X_t\right) = F_t f(t,X_t) dt$
3. Now define
$Y_t(\omega) = F_t(\omega) X_t(\omega)$
so that $X_t = F^{-1}_t Y_t$
4. And it yields the deterministic differential equation for each $\omega\in\Omega$
$\frac{dY_t(\omega)}{dt} = F_t(\omega) f\left(t, F^{-1}_t(\omega) Y_t(\omega)\right); \, Y_0 = x$

We can therefore solve it with $\omega$ as a parameter to find $Y_t(\omega)$ and then obtain $X_t(\omega)$

## Modified Ornstein-Uhlenbeck process solution

Let’s apply the described approach to the process. Thus we’ve got in notation of the method:
$f(S, t) = \theta(\mu - S)$
$c = \sigma$

Integrating factor transforms to:
$F_t = \exp{\left( -\sigma W_t+\frac{1}{2}\sigma^2t\right)}$
$Y_t = F_t S_t$
and ODE for it is:
$\frac{dY(t)}{dt} = \theta\exp{\left( -\sigma w+\frac{1}{2}\sigma^2t\right)} \left(\mu - Y(t) \exp{\left( \sigma w- \frac{1}{2}\sigma^2t\right)} \right)$
and initial conditions are:
$Y(0) = S_0$

Thus the solution $Y(t)$ is:
$Y(t) ={\frac { 2\theta \mu {\exp\left(-\sigma W_t+\frac{1}{2}\sigma^2 t \right)}}{{\sigma}^{2}+2\,\theta}}+\exp\left(-\theta\,t\right) \left( S_0 - 2 \frac {\theta\mu \exp(-\sigma W_t)}{\sigma^2+2\theta} \right)$

And recovering $S(t)$ solution:
$S(t) = F_t^{-1} Y_t = \exp{\left(\frac{1}{2}\sigma^2t - \sigma W_t \right)} Y(t)$
$S(t) = S_0\exp{\left( - \alpha t + \sigma W_t\right)} + \frac{\theta\mu}{\alpha}\left( 1 + \exp\left( - \alpha t\right) \right)$
where $\alpha = \theta + \frac{1}{2}\sigma^2$