## Common trading task – Part 1

## 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: . The process has a definite starting point 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.

Itō process

An **Itō process** is a stochastic process which can be expressed as the sum of an integral with respect to Brownian motion and an integral with respect to time:

or written as a full differential:

where is a drift component and is a diffusion component of the process.

The simplest model of price evolution is – so called – Geometric Brownian motion (GBM). This process is represented by:

The good point of GBM is that is a log-normally distributed random variable and hence provides a “good enough” approximation of asset price evolution.

## Strategy definition

Let’s define trading strategy as a set of rules that give a recommended position size for each price evolution. Thus we can denote a strategy function as We use purely technical approach, so no fundamental data like news, economical indicator etc.

Let’s construct optimization target for given strategy. There are few possible targets to optimize but our primary goals are PnL (profit and loss) and equity curve.

PnL function is built quite easily as a sum of all position changes multiplied by price, i.e. in continuous case it is with assumption of zero position before and after trades:

This integral could be re-written as stochastic differential equation:

Assuming that the strategy cannot look into future, could be represented as an integral kernel:

or

Therefore, PnL function is:

As curve fitting is evil and we don’t want to stuck with strategy working only during optimization period, we should target for optimization expected value and variance of PnL function. This requires an estimation of either price probability distribution or equivalently price drift/diffusion. This is another ultimate task itself. It will be covered sometimes later.

For now let’s assume that we’ve got such estimation and knowns are probability distribution, Therefore, expected PnL could be defined by means of path integrals. In order to calculate the value one should add up, or integrate, over all possible paths of price histories in between the initial and final states of the strategy:

where is a probability of given path.

Generally speaking, it is a path integral in quantum mechanics. Monte Carlo methods could give good approximation of path integral. This is the topic for further articles.

## Leave a Reply