chart/tests
Chris Amow 52e657fb1e Stream real-time /ES ticks so the candle moves between minute closes
CHART_FUTURES emits a bar only once its minute is over, so the chart stepped
once a minute and sat still in between, which reads as a dead feed.
LEVEL_ONE_FUTURES carries real trades on the same socket and the same login — no
extra REST call, no extra rate limit — and reports delayed: False on this
account. It was verified back in M6 and never subscribed to. It is now, building
a forming bar for the current minute that the authoritative CHART_FUTURES bar
then supersedes.

Three constraints shaped it, each a real bug avoided:

- Tick bars never reach the aggregator. It accumulates with current.v +=
  incoming.v, so re-sending the same forming minute would add its volume into
  every higher timeframe again on every update. Runtime.on_bar returns early for
  an unclosed bar: store, set price, broadcast, stop.
- Emissions are throttled, SCHWAB_TICK_SECONDS default 1.0, because /ES trades
  many times a second and each emission is a store write plus a broadcast to
  every open socket. Negative drops the Level 1 subscription entirely.
- A tick for a minute CHART_FUTURES has already closed is dropped, or a late
  trade would overwrite a settled exchange bar with a partial one.

Bid-only updates are skipped rather than carried forward: a bid is not a trade
and must not extend a candle's high or low. Alerts stay on closed bars — a level
is judged on a settled bar, not a price that may not last the minute — which
needed no change, since on_bar already gated on closed.

Verified against the live socket: 15 forming bars and 2 closed bars in 100
seconds, the closed bar superseding each forming minute. Verified in a browser:
the last candle's high and low visibly extend within the minute, no console
errors. 85 tests pass, four of them new.

The plan gains the cold-restart options asked for: make seeding non-quadratic
first, then persist cooldowns, then persist bars.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-10 06:21:35 -05:00
..
fixtures Add implementation plan for /ES multi-timeframe confluence chart 2026-08-09 20:31:40 -05:00
test_aggregator.py Implement M2 session-aware aggregation 2026-08-09 20:41:36 -05:00
test_alerts.py Stop re-alerting when price crosses a level 2026-08-10 01:51:54 -05:00
test_asset_versioning.py Version static assets so a fixed bug stops reproducing in an open tab 2026-08-10 04:29:56 -05:00
test_auth.py Guard that the OAuth callback stays reachable under CHART_AUTH_TOKEN 2026-08-10 04:50:12 -05:00
test_bar_space.py Price trendlines across bars, add one-shot alerts, collapse layers, drop 1h MAs 2026-08-10 04:15:05 -05:00
test_confluence.py Fix trendline deletion while typing, audio leak, prefs drift, cluster payload 2026-08-10 00:17:40 -05:00
test_horizontals.py Add prior-day levels and session VWAP; fix alert repetition they exposed 2026-08-10 00:36:21 -05:00
test_manual_lines.py Remove the 4h timeframe 2026-08-10 00:43:47 -05:00
test_moving_averages.py Implement M3 projected daily moving averages 2026-08-09 20:44:11 -05:00
test_price_alerts.py Add a price alert input 2026-08-10 02:09:14 -05:00
test_replay.py Implement M0 Yahoo market data and replay 2026-08-09 20:36:13 -05:00
test_runtime_alerts.py Move alert evaluation server-side so push works without a browser open 2026-08-10 00:48:03 -05:00
test_schwab_callback.py Add the OAuth callback endpoint at /api/qt 2026-08-10 04:45:31 -05:00
test_schwab_source.py Stream real-time /ES ticks so the candle moves between minute closes 2026-08-10 06:21:35 -05:00
test_session.py Remove the 4h timeframe 2026-08-10 00:43:47 -05:00
test_store.py Implement M1 live one-minute chart 2026-08-09 20:38:50 -05:00
test_vwap.py Add prior-day levels and session VWAP; fix alert repetition they exposed 2026-08-10 00:36:21 -05:00
test_yahoo.py Implement M0 Yahoo market data and replay 2026-08-09 20:36:13 -05:00