arbitragelab.stochastic_control_approach.ou_model_mudchanatongsuk

Module implements the optimal pairs trading strategy using Stochastic Control Approach.

This module is a realization of the methodology in the following paper:

Mudchanatongsuk, S., Primbs, J.A. and Wong, W., 2008, June. Optimal pairs trading: A stochastic control approach.

Module Contents

Classes

OUModelMudchanatongsuk

This class implements a stochastic control approach to the problem of pairs trading.

class OUModelMudchanatongsuk

This class implements a stochastic control approach to the problem of pairs trading.

We model the log-relationship between a pair of stock prices as an OrnsteinUhlenbeck process, and use this to formulate a portfolio optimization based stochastic control problem. We are able to obtain the optimal solution to this control problem in closed form via the corresponding Hamilton-Jacobi-Bellman equation. This closed form solution is calculated under a power utility on terminal wealth. The parameters in the model are calculated using closed form maximum-likelihood estimation formulas.

fit(prices: pandas.DataFrame)

This method uses inputted training data to calculate the spread and estimate the parameters of the corresponding OU process.

The spread construction implementation follows Section II A in Mudchanatongsuk (2008).

Parameters:

prices – (pd.DataFrame) Contains price series of both stocks in spread.

spread_calc(prices: pandas.DataFrame) tuple

This method calculates the spread on test data.

Parameters:

prices – (pd.DataFrame) Contains price series of both stocks in spread.

Returns:

(tuple) Consists of time remaining array and spread numpy array.

optimal_portfolio_weights(prices: pandas.DataFrame, gamma: float = -100) numpy.array

This method calculates the final optimal portfolio weights for the calculated spread.

The calculation of weights follows Section III in Mudchanatongsuk (2008), specifically equation 28.

Parameters:
  • prices – (pd.DataFrame) Contains price series of both stocks in spread.

  • gamma – (float) Parameter of utility function (gamma < 1).

Returns:

(np.array) Optimal weights array.

describe() pandas.Series

Method returns values of instance attributes calculated from training data.

Returns:

(pd.Series) series describing parameter values.