Single-Market CoT Diagnostics
A structured framework for analysing futures positioning, flow, and reversal risk for an individual market, with optional price overlays from yfinance.
Abstract
The Single-Market CoT Diagnostics framework turns weekly Commitment of Traders (CoT) data into a compact, trade-focused view for one market at a time. It combines net positioning, positioning stretch, recent flow, and a composite reversal score with regime flags (crowding, squeeze risk, exhaustion risk, hedger extremes). When available, daily prices from yfinance are aligned to CoT dates and displayed both as an overlay and as a dedicated price panel, enabling visual inspection of how positioning regimes interact with price trends.
1. Objective
The goal is to answer: “Who controls the market, how stretched are they, what is the recent flow doing, and is there evidence of a tactical reversal setup?” The tool is:
- Consistent across markets.
- Action-oriented for trading preparation.
- Price-aware through aligned futures or spot data.
2. Inputs & Data Sources
The tool expects a per-market dataframe with fields such as:
- Report_Date
- Spec_Net_%OI, Hedger_Net_%OI
- Spec_zscore, Hedger_zscore
- Flow_4w and optional Flow_4w_3w_ma
- Binary regime flags including crowding, squeeze, exhaustion, hedger extremes, divergence
- Price or a ticker for yfinance pull
3. Pre‑processing & Lookback
Data is sorted, coerced to datetime, and trimmed to a rolling window (default 52 weeks). This focuses the visualisation on the most relevant trading conditions.
4. Price Integration (yfinance)
If a ticker is supplied, daily prices are fetched, aligned to CoT dates, and forward‑filled. This places positioning signals directly beside price behaviour.
start = df["Report_Date"].min() - pd.Timedelta(days=10)
end = df["Report_Date"].max() + pd.Timedelta(days=2)
data = yf.download(ticker, start=start, end=end, auto_adjust=True)
price = data["Adj Close"]
df = df.set_index("Report_Date")
df["Price"] = price.reindex(df.index).ffill()
5. Panel 1 — Net % of Open Interest
Shows whether speculative traders or hedgers are in control. Price overlay adds context for whether crowding occurs at highs, lows, or mid‑trend.
6. Panel 2 — Positioning Stretch (Z‑Scores)
±2 z‑score bands highlight extreme positioning. Shading makes stretched markets easy to identify.
7. Panel 3 — 4‑Week Flow & Momentum
Tracks whether traders are adding to positions or backing off. Acceleration and fading markers provide early indications of flow turning points.
8. Panel 4 — Reversal Score & Regime Flags
Combines stretch, crowding, flow, and hedger signals into a reversal score, with layered binary flags beneath it to highlight tactical setup conditions.
9. Panel 5 — Price with Regime Signals
When price is available, squeeze and exhaustion risk points are marked directly on the price trend. This enables visual back‑testing of whether CoT conditions coincide with turning points.
10. Implementation Sketch
df = df_signal.copy()
df["Report_Date"] = pd.to_datetime(df["Report_Date"])
if ticker is not None:
price = self._get_yf_price_series(ticker, start, end)
df = df.set_index("Report_Date")
df["Price"] = price.reindex(df.index).ffill()
df = df.reset_index()
cutoff = df["Report_Date"].max() - pd.Timedelta(weeks=self.lookback_weeks)
df_plot = df[df["Report_Date"] >= cutoff]
11. Interpretation & Trading Use
- Use extremes and flow shifts to avoid poor entries.
- Monitor reversal_score spikes for tactical setups.
- Use squeeze/exhaustion regimes for risk management.
- Compare markets consistently using the same structure.
12. Limitations & Extensions
- Reporting lag — CoT data is weekly and delayed.
- Persistent extremes — trends can sustain crowded regimes.
- Market depth — thinner markets create noisier signals.
13. Full Panel Logic Summary
- Panel 1: Net positioning dominance.
- Panel 2: Positioning stretch via z‑scores.
- Panel 3: Positioning flow and momentum.
- Panel 4: Reversal conditions + regime states.
- Panel 5: Price alignment with tactical signals.
14. Recommended Enhancements
- Forward‑return tagging (1–4w) for empirical validation.
- Regime shading on price for visual back‑testing.
- Long/short setup rules integrated into output.
- Macro or volatility overlays for multi‑factor signals.