The design decisions that make it trustworthy enough to watch real money.
determinism
Record → replay → verify
Every session is recorded tick-for-tick and can be replayed byte-for-byte, proving the math never drifted.
# identical engine, any source
state = engine.cycle(Replay(tape))
assert replay(day) == recording(day)
Why it matters: correctness becomes a test, not a hope.
single source of truth
One definition of the math
OBI, CVD classification, VWAP, ATR, confluence — one pure module, golden-vector tested. The live engine, the analyzer, and the reports all call it.
# the only place buy/sell is decided
def classify(px, bid, ask):
return +1 if px>=ask # buy
else -1 if px<=bid # sell
Why it matters: the screen and the research can't disagree.
resilience
Runs unattended for days
A never-die loop survives any single bad cycle, auto-reconnects through TWS's nightly bounce, and rolls a fresh recording every session.
while alive:
try: cycle()
except: log(); carry_on
reconnect_if_dropped()
Why it matters: it's watching when it counts — including overnight.
exact, anchored
Tick-true VWAP & CVD
No "give me a VWAP" call — both are accumulated from the raw tape so they line up perfectly, anchored to the 9:30 cash open and seeded from history on a mid-session start.
pv += price*size; v += size
vwap = pv / v ✓ exact
Why it matters: the textbook version reads stale off-hours. This one doesn't.
self-monitoring
The watcher watches itself
Tiered, time-aware feed health: during cash hours a slow tape flips it yellow in 5s and red in 15s — looser overnight, where gaps are normal.
LIVE # flowing
STALE # slowing · 5s
DEAD # stopped · 15s
Why it matters: a served file can read "200 OK" over a dead feed. Not anymore.
the contract
Read-only, enforced
The code imports nothing related to placing, modifying, or routing an order — and a test guards it. Paired with TWS's read-only API.
# the one rule, in code
no placement · no routing
it only ever watches
Why it matters: the thing on your screen can't cost you by acting.