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:

2. Inputs & Data Sources

The tool expects a per-market dataframe with fields such as:

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

12. Limitations & Extensions

13. Full Panel Logic Summary

14. Recommended Enhancements