Language:  ▾

Residual model

Model description

RESIDUAL model is based on Time-series Cointegration. It is based on a fact that mutually correlated stocks pairs have mathematically similar course of its price. In other words:

(1)          PriceA = X * PriceB + Y

This equation can be modified as follows:

(2)          Residuum = PriceA - (X * PriceB + Y)

Note: Parameters X, Y are determined by the least squares method (linear regression) using EOD time series of prices A and B. Length of the series, for which the regression is implemented, is given by a parameter “Period”.

In an ideal case (ideal correlated prices) the equation (1) would be exact, which means that Residuum in the equation (2) would equal to zero. In the real markets environment are all prices correlated imperfectly, which means that the residuum is not equal to zero.

When the stocks are correlated strongly, the residuum will behave as “white-noise”, which means that there will be random data with normal distribution. In ideal case the residuum will be permanently oscillating around zero with a constant amplitude and with a distribution as per the Gaussian curve of normal distribution.

Anticipation of the normal distribution of the residuum enable us to apply standard statistical apparatus, which can evaluate optimal time for entry to the position.

Procedure of RESIDUAL model calculation

  1. Based on the procedure described above a regression parameters are estimated for today
  2. Residuum is calculated - difference between real and estimated price B
  3. Standard deviation is calculated from values of Residuum at “Period” days back - StDev
  4. Relative standard deviation RelDev is calculated = Res / StDev
  5. If the RelDev will exceed the specified limit, the trade will be entered
Item Description
CloseA EOD Close stock A (entry level)
CloseB EOD Close stock B (entry level)
Residuum = LinRegEst(CloseA) - CloseB A difference between CloseB price estimated based on a linear regression and real price CloseB
ResiduumMA = MovingAverage(Period, Residuum) Moving average of Residuum values within Period of previous business days.
StDev = StDev(Period, Residuum) Standard deviation of Residuum values within Period of previous business days.
RelStDev = (Residuum - ResiduumMA) / StDev Relative standard deviation - comparison of current Residuum value with historical course within Period of previous business days.

Entry to a position

Entry to a position is indicated, when relative standard deviation will exceed previously specified limit. Default entry level is 2.0, which corresponds to 95% quantile of values.

Exit a position

Position is finished (exit), when relative standard deviation will exceed previously specified limit. Initial value of the exit level is 0.0, ie. long-term average of the Residuum. It means that speculations are made on return of short-term bias of the value back to the average.

If the prices ratio will not return to average value in the specified time, the position is closed by so called “Time Stop Loss”. Initial value for the time stop loss is 15 business days.

Graphic display of RESIDUAL model

Item Description
Residuum (black) Residue of liner combination of Stock A and B prices calculated by linear regression with specified Period
Entry levels (silver) Upper level (=entry level to Short position) = Entry level * Standard error of linear regression

Lower level (=entry level to Long position) = -Entry level * Standard error of linear regression

Pair equity (black) Resulting pair equity
Trades (green and red) Profitable (green) and unprofitable (red) trades


A least squares method is used to estimate parameters X and Y. Length of the time line, for which the estimate is performed, is given by the pair period. The longer the period specified, the more stable the estimate of parameters X and Y is - nevertheless at the costs of lower profits. The shorter the Period is, the more aggressive the trading is - Profit is increasing as well as instability and Drawdown.

Residual model is a mathematical expansion of Ratio model: If an absolute member “Y” would be removed from the equation (1), a Ratio model would be created (only mathematically expressed elseway).

Due to the presence of absolute member “Y”, the Residual model can better grasp mutual relationship of stock and eliminate some adverse effects of a simple Ratio model - especially “floating average” at slow increase of the whole market.