Close Navigation
Learn more about IBKR accounts
Optimal Stopping in Pairs Trading: Ornstein-Uhlenbeck Model

Optimal Stopping in Pairs Trading: Ornstein-Uhlenbeck Model

Posted September 24, 2020
Valeriia Pervushyna - Hudson and Thames Quantitative Research Blog
Hudson and Thames Quantitative Research

Following the work of Professor Tim Leung and Xin Lee, we explored how the Ornstein-Uhlenbeck process known for modelling mean-reverting interest rates, currency exchange rates, and commodity prices can be used in pairs trading and statistical arbitrage.

Introduction

Nothing makes a situation better like good timing. Whether it’s getting a promotion, catching the last train after a night out, meeting the love of your life, or joining a quant community – it is many of small consequential gambles of stopping decisions that get us to that triumphant “Yes!” moment. When outputs may vary, the basic setup of all these problems is the same: we observe some process that involves randomness in it evolving in time. Based only on the knowledge available the person has to decide how to maximize reward or minimize the cost. There is no requirement on how much information has to be available, whether it is scarce or abundant the decision-maker has to make the best choice. Luckily for us, knowing the powers of probability allows us to tilt odds in our favor.

Let’s look at some more mundane problems that can be solved with the little help of optimal-stopping theory.

The first example is the problem of finding a suitable partner, also known as the secretary problem, dowry, or best-choice problem. Imagine, you decide to marry, and to find your perfect other half you conduct an interview with 100 applicants. The decision about an applicant is made immediately. You can not marry candidates who you already rejected, and if you are not married after interviewing candidate 99 – you have to marry candidate 100. Of course, you can choose the first applicant and get a 1% chance of getting the best spouse. But there is a way to marry the absolute best candidate more than one-third of the time.

The rule is to reject n / e = 100 / 2.718 = 37 potential spouses, and then choose the first applicant who is better than every applicant interviewed so far.

The various problems similar to the ‘secretary problem’ create so-called ‘search theory’, that has especially focused on a worker’s search for the highest-paying job or a consumer’s search for the best deal on wanted goods.

Optimal stopping is also encountered in house selling. For example, if you wish to sell a house. Each day you are offered Xn for your house, and pay k to continue advertising it. If you sell your house on day n, you will earn yn, where yn = (Xn − nk). You maximize the amount you earn by choosing the best stopping rule.

The field of optimal stopping problems is broad and vast, it ranges from option pricing with the Black-Scholes model to choosing the best parking spot when going to buy groceries. But what if I tell you that there is a simple and elegant way to use it for the statistical arbitrage?

Welcome to Part 1 of the series of blog posts on optimal stopping problems for statistical arbitrage. And today we are going to talk about the Ornstein-Uhlenbeck model application to optimal stopping problems in pairs trading.

Mean-reversion

But before that, we need to start with something that will allow the statistical arbitrage in the first place – mean-reversion.

Mean-reversion is a financial term for the assumption that a stock’s price will tend to return to the average price over time. Some asset prices are naturally mean-reverted: commodities, foreign exchange rates, volatility indices, equities – all of those can be modeled with mean-reverting processes, alongside with interest rate and default risk.

However, there is a much more lucrative approach that also allows for greater freedom of choice for the investor – pairs-trading. Facilitated by many hedge-fund managers, creation of the mean-reverting portfolios gave the ability to both pick almost any asset you’d want to trade and simultaneously rely on rigid mathematical concepts in the decision-making process. The only requirement to be is that the pair chosen has to be correlated or co-moving. Technically speaking, a portfolio is created by longing an α amount of one asset and shorting β amount of a second asset.

It is no surprise that such spreads are widely used for statistical arbitrage.

Looking deeper, one very important commonly faced problem still stands – how to determine when to open and close the position. Should an investor wait or close the position immediately? When is it the optimal time to enter the market? All these questions bring us to a brilliant idea: what if we could look at it as an optimal stopping problem? Can we create a procedure that will give us the means to predict the best time to enter or liquidate the position?

For an answer to this question, we turn to a book by Professor Tim Leung and Xin Li: “Optimal Mean reversion Trading: Mathematical Analysis and Practical Applications“. We will showcase how the widely known Ornstein-Uhlenbeck process can be used to create your optimal mean-reverted portfolio and to also find the solution for the optimal timing of trades problem.

The work of Professor Tim Leung

Ornstein-Uhlenbeck model is established by the following SDE:

Where:

θ − long term mean level, all future trajectories of X will evolve around a mean level θ in the long run.

μ – the speed of reversion, characterizes the velocity at which such trajectories will regroup around θ in time.

σ – instantaneous volatility, measures instant by instant the amplitude of randomness entering the system. Higher values imply more randomness.

Note that we are using the same notation as used in the book, so the meaning behind theta and mu parameter may differ from other sources (Wikipedia, etc.).

To create an optimal portfolio using this model we can without the loss of generality presume that 
α = const while varying  β, since our main goal during this step can be simplified to finding an optimal ratio between the assets.

We observe the resulting portfolio values for every strategy β realized over an n-day period. To fit the model to our data and find optimal parameters we define the average log-likelihood function. Our log-likelihood function is dependent on our β coefficient and the OU model’s parameters theta, mu, and sigma.

Visit Hudson and Thames Quantitative Research Blog to read the next steps in this tutorial, such as maximizing the log-likelihood function by applying maximum likelihood estimation(MLE) and establishing optimal stopping problem.

References

  1. Leung, Tim, and Xin Li. “Optimal Mean Reversion Trading: Mathematical Analysis and Practical Applications.” World Scientific Publishing Company (2015).
Disclosure: Interactive Brokers

Information posted on IBKR Campus that is provided by third-parties does NOT constitute a recommendation that you should contract for the services of that third party. Third-party participants who contribute to IBKR Campus are independent of Interactive Brokers and Interactive Brokers does not make any representations or warranties concerning the services offered, their past or future performance, or the accuracy of the information provided by the third party. Past performance is no guarantee of future results.

This material is from Hudson and Thames Quantitative Research and is being posted with its permission. The views expressed in this material are solely those of the author and/or Hudson and Thames Quantitative Research and Interactive Brokers is not endorsing or recommending any investment or trading discussed in the material. This material is not and should not be construed as an offer to buy or sell any security. It should not be construed as research or investment advice or a recommendation to buy, sell or hold any security or commodity. This material does not and is not intended to take into account the particular financial conditions, investment objectives or requirements of individual customers. Before acting on this material, you should consider whether it is suitable for your particular circumstances and, as necessary, seek professional advice.

IBKR Campus Newsletters

This website uses cookies to collect usage information in order to offer a better browsing experience. By browsing this site or by clicking on the "ACCEPT COOKIES" button you accept our Cookie Policy.