Skip to content
All library documents

CIR Mean-Reversion Models for Optimal Entry, Exit, and Switching Levels

Code Stratmill research code

Summary

The code implements a Cox–Ingersoll–Ross model for a mean-reverting portfolio, extending an Ornstein–Uhlenbeck model interface. It supports fitting the model to portfolio prices or to two assets, and estimates the long-run mean, reversion speed, and variance parameter through a likelihood calculation. A simulation method generates CIR process values using either supplied parameters or fitted values.

For trading applications, the class calculates optimal liquidation and entry levels using discount rates and transaction costs, with methods for optimal switching levels when repeated trades are considered. It also exposes model descriptions and plots of portfolio prices alongside calculated levels. The accompanying explanation distinguishes a single optimal entry-exit pair from repeatedly switching between positions, and relates the portfolio setup to pairs trading. This is a mathematical implementation rather than empirical evidence: the excerpt contains no backtest or profitability results. Estimates and thresholds depend on model fit and assumptions, and implementation details such as data quality, parameter stability, and trading frictions require separate assessment.

Key ideas

  • The model fits a CIR process to a portfolio time series and estimates its long-run mean, reversion speed, and volatility.
  • It offers simulation using either supplied process parameters or fitted model parameters.
  • Optimal entry and liquidation levels incorporate discount rates and transaction costs.
  • Optimal switching levels address repeated trades, while optimal stopping addresses a single entry-exit cycle.
  • The code provides diagnostics and plots but no evidence of trading performance.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.