| name | trend-projection |
| description | Code patterns for fitting a linear trend and projecting calibrated forecasts. Always load alongside fetch-yfinance and vol-regime — references/examples.md includes a Full Pipeline Example showing the complete self-contained script from yfinance data fetch through vol regime to final interval output. |
Linear trend projection
What this skill provides
references/examples.md — Working code patterns for:
- Pattern 1: Fit a linear trend on the most recent
trend_window daily rows and
project to horizons 5, 10, and 21 business days
- Pattern 2: Calibrate 80% prediction interval widths from residual standard error
- Pattern 3: Plausibility guard — clip projections to a multiple of the 52-week range
Typical usage
- Load
fetch-yfinance → fetch price history
- Load
vol-regime → classify regime, detect anomaly, determine trend_window
- Load
trend-projection → fit trend on the trend_window rows, project, calibrate intervals
- Write one complete code block combining all three
Key formula
80% CI half-width at horizon h business days:
half_width = 1.28 * residual_std * sqrt(h / 5)
where residual_std is the standard deviation of in-sample residuals on the
trend window. This produces approximately correct coverage for a normally
distributed trend residual and scales with horizon.
Interval calibration note
Statistical intervals are often too narrow in elevated or extreme vol regimes.
Per the wti-strategy skill: widen 80% CI by ~10–15% when regime is elevated
or extreme. Apply this after computing the base half-width.