# FxPaul

Math in finance or vice versa

Correlation trading is based on few simple ideas:

1. Correlations are changing with time
2. Correlations of pairs of 3 currencies are bounded by strict equation
3. Correlation is bound in the interval $[-1, 1]$

Therefore, one may try to “buy correlation” at -1 and to “sell it” at +1.

Written by fxpaul

November 1, 2011 at 13:04

## Exponential Ornstein-Uhlenbeck process and USD/CHF

In the previous post USD/CHF is considered to follow a mean-reverting process. Let’s look at the dynamics of the process during the days of year 2010.

## Calibration procedure

Calibration is simple: get logs of prices and calibrate against classic Ornstein-Uhlenbeck process as it is described here.
Read the rest of this entry »

Written by fxpaul

July 25, 2011 at 14:19

Tagged with

## SABR model calibration

Don’t use this!

The SABR model is a stochastic volatility model, which attempts to capture the volatility smile in derivatives markets. The name stands for “Stochastic Alpha, Beta, Rho”, referring to the parameters of the model. It was developed by Patrick Hagan, Deep Kumar, Andrew Lesniewski, and Diana Woodward.

The SABR model describes a single forward F, such as a LIBOR forward rate, a forward swap rate, or a forward stock price. The volatility of the forward F is described by a parameter σ. SABR is a dynamic model in which both F and σ are represented by stochastic state variables whose time evolution is given by the following system of stochastic differential equations:
$dF_t = \sigma_t F_t^{\beta} dW_t$
$d\sigma_t = \alpha\sigma_t dZ_t$
Constant parameters should satisfy the condition $0 \leq \beta \leq 1, \alpha \geq 0$
Here, $W_t$ and $Z_t$ are two correlated Wiener processes with correlation coefficient $-1\leq\rho\leq 1$. For simplicity sake, we assume that $\rho = 1$, therefore, we put $Z_t = W_t$:
$dF_t = \sigma_t F_t^{\beta} dW_t$
$d\sigma_t = \alpha\sigma_t dW_t$

Written by fxpaul

June 17, 2011 at 09:27

## Is EUR/USD mean reverting?

Nassim Taleb in his book “Dynamic Hedging” provides an empirical rule to validate if the market has mean reversion tendency. It states that if volatility lowers if the longer time frame is used, then the mean reversion takes place.
Read the rest of this entry »

Written by fxpaul

June 16, 2011 at 20:52

## Exponential Ornstein-Uhlenbeck process

Let’s consider parameter estimation for the following modification of Ornstein-Uhlenbeck process:
$dS_t = \theta(\mu - S_t) dt + \sigma dW_t$
$P_t= \exp S_t$
This model is simplification of Schwarz Model 1, one of Short-rate models
Read the rest of this entry »

Written by fxpaul

June 8, 2011 at 08:28

## 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)$

Written by fxpaul

May 27, 2011 at 08:39

with one comment

## Introduction

In mathematics, Ornstein-Uhlenbeck process satisfies the following stochastic differential equation:
$dS = \theta(\mu - S) dt + \sigma dW_t$
where $\theta$ – mean reversion parameter, $\mu$ – mean and $\sigma$ – volatility.

In finance, it is used to model interest rates, currency exchange rates and commodity prices. Although it is usually modified to incorporate non-negativity of prices.

## Ordinary Least-Squares Approach to calibration

The simplest approach to the calibration problem is to convert SDE to finite difference equation (as it is usually used in Monte Carlo simulation) and to rearrange parts to Ordinary Least Squares equation.

The simplest updating formula for Ornstein-Uhlenbeck process is:
$S_t - S_{t-1} = \theta (\mu - S_{t-1}) \Delta t + \sigma \sqrt{\Delta t} W_{t-1}$
By rearranging we obtain:
$S_t - S_{t-1} = \theta\mu\Delta t - \theta S_{t-1}\Delta t + \sigma \sqrt{\Delta t} W_{t-1}$
Comparing with simple regression formula:
$y = a + bx + \epsilon$
we can equate as follows:
$y = S_t - S_{t-1}$
$x = S_{t-1}$
$a = \theta\mu\Delta t$
$b = -\theta\Delta t$
$\epsilon = \sigma \sqrt{\Delta t} W_{t-1}$
and immediately obtain the following:
$\theta = -\frac{b}{\Delta t}$
$\mu = -\frac{a}{b}$

As $W_t$ is drawn from normal distribution, its expectation equals zero and one should use variance to obtain $\sigma$:
$\sigma_{\epsilon} = \sigma \sqrt{\Delta t} \sigma_W$
where $\sigma_{W} = 1$ as it has been already normalized by $\sqrt{\Delta t}$. Finally, we can obtain:
$\sigma = \frac{\sigma_{\epsilon}}{\sqrt{\Delta t}}$

So, regression of $S_{t-1}$ against $S_t - S_{t-1}$ gives estimation of process parameters.

## The modified process

Let’s consider the process with slight modification and apply the same approach to the modified process:
$dS = \theta(\mu - S) dt + \sigma S dW_t$
Then the naive updating formula is
$S_t - S_{t-1} = \theta (\mu - S_{t-1}) \Delta t + \sigma S_{t-1} \sqrt{\Delta t} W_{t-1}$
Then dividing by $S_{t-1}$:
$\frac{S_t}{S_{t-1}} - 1 = \theta\mu\Delta t\frac{1}{S_{t-1}} - \theta \Delta t + \sigma \sqrt{\Delta t} W_{t-1}$
Given simple regression formula:
$y = a + bx + \epsilon$
we can equate as follows:
$y = \frac{S_t}{S_{t-1}} -1$
$x = \frac{1}{S_{t-1}}$
$a = - \theta\Delta t$
$b = \theta\mu\Delta t$
$\epsilon = \sigma \sqrt{\Delta t} W_{t-1}$
and immediately obtain the following:
$\theta = - \frac{a}{\Delta t}$
$\mu = - \frac{b}{a}$
Applying the same logic as in previous section, finally we get:
$\sigma = \frac{\sigma_{\epsilon}}{\sqrt{\Delta t}}$

Therefore, regression of $\frac{S_t}{S_{t-1}} - 1$ against $\frac{1}{S_{t-1}}$ yields estimation of modified process parameters.

## Open questions

1. Bias of the estimators. For the original process this approach usually gives quite precise estimation of mean and volatility but fails to provide mean reversion parameter
2. Closed-form solution of the modified SDE. It could be used to improve the updating formula
3. Statistical hypothesis testing if the sample drawn from the process. This is quite crucial point as it helps to identify model regime shift in trading.

Written by fxpaul

May 26, 2011 at 11:17

## Quantum Mechanics and Market Observables

Quantum mechanics has quite powerful notion of observables. They are just properties of system state that can be determined by measurement process. Let’s recall main principles of quantum mechanics and how they could be applied to markets.

Written by fxpaul

January 15, 2011 at 10:53

## Stochastic process

As Wikipedia suggests, a stochastic process is a random process, the counterpart to a deterministic process. For our simple tasks all we need is a time series, i.e. for each moment of time we have only one random value, or price: $P(t)$. The process has a definite starting point $P(0)$ but its further evolution has some degree of uncertainty described by probability distribution.

A lot of types of stochastic processes has been studied in mathematical literature. In this article I use only Itō processes as they provide quite good approximation of price dynamics.

Written by fxpaul

January 3, 2011 at 12:00

Tagged with ,

## Mixing up Fx and Stocks

Anybody can find enormous amount of books about stocks trading but all of Forex books give an expression of spurious market: plain old strategies, positive only examples of profit-loss calculations etc. It’s easy to get impressed as well as to get depressed by results of trading.

I want to explore how we could apply stock strategies to foreign exchange markets. Vast majority of stock strategies should be adopted to turbulent dynamic of Forex markets.

The nearest future is:

1. Define the common trading task in a precise, mathematical way – this is the starting point.
2. Monte Carlo methods for optimization and trading experiments.
3. Simple strategy emulations on model processes

I do hope the list will be continued.

Written by fxpaul

December 27, 2010 at 20:56

Posted in Uncategorized

Tagged with ,