OPEN-SOURCE SCRIPT

CNOOC Oil-Following Study | Extremes + DY Regime + 2-Factor

440
What It Does
Your indicator is a 2-factor return attribution model with extreme event analysis and dividend yield regime conditioning. It answers one core question: When oil moves — especially violently — does CNOOC follow, and does its dividend yield affect that behavior?
The Architecture
Layer 1 — Rolling 2-Factor Regression
Every week, the model runs a rolling OLS regression: CNOOC return = β₁ × Brent + β₂ × SSE50 + residual. This decomposes CNOOC's performance into three streams: what came from oil, what came from the China market, and what is company-specific alpha. The auto-lag feature tests 0–8 week delays on Brent to find the strongest fit.
Layer 2 — Extreme Oil Detection
It computes a rolling Z-score of Brent returns. Any week where |Z| exceeds your threshold (default 2.0) gets flagged as an extreme oil event, classified as either up-extreme or down-extreme, and highlighted on the chart with green or red backgrounds.
Layer 3 — Conditional Beta Accumulation
This is the study's core innovation. Instead of just one rolling beta, it maintains separate running OLS accumulators for different market conditions: all bars, normal bars, extreme bars, up extremes only, down extremes only. This produces a conditional beta table showing how CNOOC's oil sensitivity changes depending on whether oil is behaving normally or experiencing a tail event.
Layer 4 — Dividend Yield Regime
It estimates CNOOC's trailing dividend yield (annual dividend / price) and classifies each week into High DY, Low DY, or Mid using rolling percentile thresholds. It then cross-tabulates this with the oil regime to produce betas for combinations like High DY + Extreme Oil, Low DY + Oil Down, etc. This tests whether valuation level affects oil sensitivity.
Layer 5 — Cumulative Decomposition
From a fixed start date, it geometrically compounds the oil contribution, index contribution, and residual separately, producing four cumulative return lines that visually show how much of CNOOC's total return came from each source.
Layer 6 — Event Window
Around any anchor date you choose, it accumulates returns within ± N weeks and reports the decomposition for that specific period, plus how many extreme oil bars fell within the window.

إخلاء المسؤولية

لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.