Adaptive Local Linear Regression for Short-Term Trend Following in Growth Stocks
These articles are AI-generated summaries. Please check the original sources for full details.
Adaptive Local Linear Regression for Short-Term Trend Following in Growth Stocks
Adaptive Local Linear Regression (ALLR) replaces static moving averages with dynamic kernels that weight recent price data more heavily than distant observations. This system modulates its bandwidth based on realized volatility to maintain signal quality in growth stocks like QQQ.
Why This Matters
Standard OLS regression models treat all market regimes equally, causing significant signal lag during sharp inflection points. ALLR addresses this technical debt by fitting linear models locally, allowing slope estimates to update fluidly as volatility and momentum conditions shift. This prevents old data from misleading slope estimates during trend reversals, which is a common failure mode in fixed-window momentum indicators.
Key Insights
- Local Linear Regression fits a model by weighting observations with a Gaussian kernel that decays as time distance increases from the target point.
- The adaptive bandwidth mechanism expands the kernel width during high-volatility episodes (e.g., 2020 and 2022) to filter noise and narrows it during clean trends to capture momentum.
- Backtests on QQQ data from 2020 to 2025 demonstrate Sharpe ratios between 0.7 and 1.1, outperforming buy-and-hold during high-momentum regimes.
- The system requires transaction costs to remain below 10 bps per side, as it averages 3 to 5 round-trip trades per month.
- Slope estimates provide a continuous trend strength signal rather than binary flags, enabling more granular portfolio weighting and risk management.
Working Examples
Core engine for computing locally weighted linear regression slopes using a Gaussian kernel.
def gaussian_kernel_weights(n, bandwidth):
x = np.arange(n)
center = n - 1
weights = np.exp(-0.5 * ((x - center) / bandwidth) ** 2)
return weights / weights.sum()
def local_linear_slope(price_window, bandwidth):
n = len(price_window)
if n < 5: return np.nan
x = np.arange(n, dtype=float)
y = np.array(price_window, dtype=float)
w = gaussian_kernel_weights(n, bandwidth)
W = np.diag(w)
X = np.column_stack([np.ones(n), x])
try:
beta = np.linalg.solve(X.T @ W @ X, X.T @ W @ y)
return beta[1]
except np.linalg.LinAlgError: return np.nan
Adaptive bandwidth selector that modulates kernel width based on realized volatility.
def compute_adaptive_slopes(prices, base_bw, vol_lookback, vol_scalar):
log_returns = np.log(prices / prices.shift(1))
realized_vol = log_returns.rolling(vol_lookback).std()
median_vol = realized_vol.median()
slopes = []
for i in range(len(prices)):
rv = realized_vol.iloc[i]
if np.isnan(rv) or median_vol == 0:
slopes.append(np.nan)
continue
adj_bw = base_bw * (1 + vol_scalar * (rv / median_vol - 1))
adj_bw = max(5, min(adj_bw, base_bw * 4))
window_size = int(adj_bw * 3)
start_idx = max(0, i - window_size + 1)
window = prices.iloc[start_idx: i + 1].values
slopes.append(local_linear_slope(window, adj_bw))
return pd.Series(slopes, index=prices.index)
Practical Applications
- Systematic equity screening: Ranking growth stock universes by ALLR slope values to prioritize high-momentum assets. Pitfall: Over-calibration of base bandwidth leading to excessive turnover in sideways markets.
- Regime filter overlay: Monitoring simultaneous bandwidth expansion across index baskets to identify high-volatility macro regimes for risk-off positioning. Pitfall: Lookahead bias if using full-sample median volatility instead of rolling medians.
- Options strategy timing: Using positive and accelerating slope signals as entry filters for short-dated call spreads. Pitfall: Slope estimates can be misleading for 1-3 days following sharp, non-linear events like earnings gap-downs.
References:
Continue reading
Next article
AI Whipper String: High-Performance Physics Simulation in React
Related Content
Building a Local AI-Native Hedge Fund: Multi-Agent Architecture and Auditability
Tapesh Chandra Das developed a free, local multi-agent hedge fund system achieving a 0.61 Sharpe ratio using Ollama and yfinance without paid APIs.
Beyond Detection: Architecting PII Prevention for Agentic AI Systems
In 2026, OpenAI launched Privacy Filter and developers shipped local firewalls to intercept PII before it reaches AI models.
123 Million CS2 Simulations: Engineering Reliable Weighted RNG
Analysis of 123 million simulated CS2 case openings reveals critical pitfalls in weighted RNG modeling, including floating-point errors and UI bias.