Stage A - VWAP/SD Recompute Method

Run date 2026-06-05 · Companion to kti pilot + Liberator validation · Method per vcet_engine.py compute_features() · Anchor: Pull-In Research Hub

Verdict: the canonical VCET VWAP/SD method is consistent across 1-min and 5-min cadences

The 1-min-derived session VWAP matches the engine's 5-min-aggregated VWAP within median 0.023% across 6,264 comparison points spanning 62 pairs. The p99 of 0.54% and max of 3.13% are concentrated in early-session bars with thin volume. For mechanism classification, this drift is well below any threshold that would change state assignment.

1. Method specification

1.1 Session anchor

Each session is identified by Eastern Time date: session_id = bar_timestamp.tz_convert("US/Eastern").date. VWAP and SD reset at the boundary of each session.

1.2 Extended hours handling

The current implementation includes all bars within the session-date window (including pre-market and post-market). The session-active gate (in compute_features()) limits state classification to bars where cumulative volume exceeds cfg.min_vol_fraction (0.10) of the prior session's typical volume - effectively excluding early pre-market activity until enough volume has accumulated.

1.3 VWAP formula (cumulative)

src = (high + low + close) / 3
pv  = src * volume
pv2 = src^2 * volume

per-session cumulative:
  cum_pv  = sum(pv) within session, expanding window
  cum_v   = sum(volume) within session, expanding window
  cum_pv2 = sum(pv2) within session, expanding window

vwap     = cum_pv / cum_v
variance = cum_pv2 / cum_v - vwap^2
sigma    = sqrt(max(variance, 0))

This is the standard typical-price VWAP with cumulative variance for sigma. The max(variance, 0) clip handles small numerical noise where the cumulative formula can produce tiny negative values.

1.4 Band geometry

band_width_pct = (2 * sd_mult * sigma) / vwap * 100   # sd_mult = 2.0 default
upper_band     = vwap + sd_mult * sigma
lower_band     = vwap - sd_mult * sigma

1.5 Smoothing variants (for compression detection)

fast_sigma = SMA(sigma, fast_len=5)    # per-session rolling
slow_sigma = SMA(sigma, slow_len=20)   # per-session rolling

fast_width = (2 * sd_mult * fast_sigma) / vwap * 100
slow_width = (2 * sd_mult * slow_sigma) / vwap * 100
width_delta = fast_width - slow_width

2. Cross-check methodology (Stage A pilot)

For each computable (symbol, date) pair, the pilot computed VWAP at two cadences and compared:

  1. 1-min VWAP - cumulative formula applied directly to 1-min bars from kti
  2. 5-min VWAP - 1-min bars aggregated to 5-min OHLCV bars (open=first, high=max, low=min, close=last, volume=sum), then cumulative formula applied to the 5-min stream

At each 5-min timestamp emitted by the engine, the 1-min VWAP value at the corresponding 1-min bar was looked up (pad method). The two VWAPs were compared in absolute and percentage terms.

2.1 Why this comparison matters

If the 1-min and 5-min VWAPs diverge significantly, then the choice of bar cadence affects the band geometry, which affects compression detection, which affects state classification. Tight agreement means the engine's tuning (designed for 5-min) is stable when the underlying bar stream is 1-min aggregated to 5-min - which is the data path for Stage B.

3. Cross-check results

6,264
comparison points
0.023%
median pct diff
0.54%
p99 pct diff
3.13%
max pct diff (outlier)

3.1 Distribution interpretation

BucketCountInterpretation
diff ≤ 0.05%~4,625 (74%)Effectively identical; mechanism-stable
diff 0.05% - 0.50%~1,639 (26%)Sub-percent drift; concentrated in early-session bars and thin-volume periods
diff > 0.50%~63 (1%)Outliers; investigated below

3.2 Outlier analysis

The 3.13% max outlier was traced to thinly-traded pre-market bars where:

This is not a method bug; it is the structural consequence of cumulative VWAP being a path-dependent statistic that responds differently to different temporal granularities of the same underlying trades. For mechanism work (which fires on +5 / +10 / +15 / +25 min snaps around an RTH entry), the outlier window is irrelevant - those snaps occur well past the early-session noise.

4. Choice: 1-min source, 5-min engine

The Stage A pilot adopts:

  1. Fetch: 1-min bars from kti (or Liberator for older trades)
  2. Aggregate: 1-min → 5-min OHLCV (open=first, high=max, low=min, close=last, volume=sum)
  3. Compute: Run VCET v1.1 on the 5-min aggregated stream (engine is tuned for 5-min cadence)
  4. Cross-check: Recompute VWAP independently on the 1-min stream as a sanity reference

This pattern preserves engine tuning (compression lookback, slope length, channel lookback are all in bar units; tuning is calibrated for 5-min bars) while sourcing from the highest-fidelity bar stream available.

4.1 Alternative considered: native 1-min engine run

Running the VCET engine directly on 1-min bars (with cbo_lookback scaled to 100 bars = 100 minutes) was considered. Rejected because:

A native 1-min engine variant could be a future research path but is not required for Stage B.

5. Liberator's own bar-VWAP as a third cross-check

Liberator includes a per-bar vwap field. This is a third independent reference: it is the bar-level (within-minute) VWAP, computed by CloudQuant from raw trade ticks. Stage B should validate the recomputed cumulative session VWAP against Liberator's bar-level VWAP at the same time - if they agree, the method is triply-validated. This validation was not done in the pilot but is in the open work for Stage A.

⚠ Stage A.1 update (2026-06-07): native VWAP cross-check is BLOCKED

The Liberator native-VWAP cross-check planned for Stage A.1 §3 cannot run because Liberator minute_bars entitlement was revoked between 2026-06-05 15:00 ET and 2026-06-07 19:55 ET. See parity report for details.

The 1-min vs 5-min self-consistency cross-check in §3 (median 0.023%, p99 0.54%) stands. The triple-validation against Liberator's bar-level vwap field is queued for re-run once entitlement is restored.

6. Volume basis: kti vs Liberator

The Liberator validation showed that close prices match exactly across kti and Liberator, but volume differs by ~5-10% per bar (Liberator includes more off-exchange / odd-lot trades). This affects VWAP because:

vwap = sum(src * volume) / sum(volume)

If volume differs by a uniform ratio, VWAP is approximately preserved. If volume differs symbol-specifically or time-specifically, VWAP can drift. Stage A only spot-checked one pair (NVDA 6/2); a broader study is recommended before Stage B production.

7. Open Stage A work

  1. Liberator-vs-recomputed-VWAP cross-check at the bar level (use Liberator's vwap field as a third reference)
  2. Volume-drift characterization across 20+ kti/Liberator overlap pairs
  3. Outlier root-cause on the 3.13% max diff - is it consistently early-session, or is there a thinly-traded class of symbols where the cumulative VWAP method has known drift?
  4. Pre-market policy - the session-active gate excludes early bars; trades like NVDA 2026-06-02 05:58 ET (pre-market) cannot be classified today. Decide whether to relax the gate or label such trades as insufficient_data_premkt.

8. Summary table

QuestionAnswer
What VWAP formula?Cumulative typical-price VWAP per session (TZ=US/Eastern)
What SD formula?sqrt(max(cum_pv2/cum_v - vwap^2, 0)); clip-at-zero for numerical safety
What session anchor?Eastern Time date
Are extended hours included?Yes (filtered downstream by session-active gate, not at the VWAP computation layer)
What bar cadence for the engine?5-min (engine is tuned at this cadence; aggregated from 1-min source)
What bar cadence for the cross-check?1-min independent recompute (Stage A pilot)
How close do 1-min and 5-min VWAPs match?Median 0.023%; p99 0.54%; max 3.13% (outlier)
Is the drift large enough to affect state classification?No - all observed drift is well below any state-machine threshold
Is kti's price data identical to Liberator's?Yes - OHLC matches exactly on overlapping date sampled (NVDA 6/2)
Is kti's volume identical to Liberator's?No - kti is ~5-10% lower (exchange-only vs all-venue)

Links