Half-life is Negative (How to Interpret?)

Course Name: Mean Reversion Strategies In Python, Section No: 12, Unit No: 4, Unit type: Notebook

  1. Computation of Halflife via Ols

  2. We calculated the half-life for the pair HDFCAMC and SBICARD using 480 data points and the course’s implementation code. Despite the clean data, the half-life values were negative. Is half-life not always expected to be positive? Find the Implementation Code Below :-

import pandas as pd
import statsmodels.api as sm
import numpy as np
import math

y = stock_data.iloc[:,0]
x = stock_data.iloc[:,1]
# Hedge Ratio
model = sm.OLS(y.iloc[:], x.iloc[:])
model = model.fit()

# Spread GLD - hedge ratio * GDX
spread = -model.params[0]*x + y
spread = spread.iloc[:]

# Spread and difference between spread
spread_x = np.mean(spread) - spread
spread_y = spread.shift(-1) - spread
spread_df = pd.DataFrame({'x': spread_x, 'y': spread_y}).dropna()

# Theta as regression beta between spread and difference between spread
model_s = sm.OLS(spread_df['y'], spread_df['x']).fit()
theta = model_s.params[0]

# Type your code below

hl = math.log(2) / theta 

print("Half Life:", hl)```

Hi Tarun,

We are looking into it. Will get back to you shortly.

Hi Tarun,

Half-life is useful when your spread moves back toward its typical level. A negative half-life means your data says it doesn’t: the gap widens, or the spread was built incorrectly.

  1. Build the spread properly: fit one series to the other with an offset (include a baseline level); don’t force through zero.
  2. Clean and align the data: same dates, corrected for splits/dividends, comparable pricing.
  3. Check that the spread looks stable around a level over time. If measured “pull back” isn’t positive, don’t quote a half-life. Say “no mean reversion,” or try a different period or a better pair.