Most "AI trading desk" projects fail on the same axis: they optimise for the demo, not for the day the feed goes stale and the model is quietly wrong.
This is the architecture of a desk I built around the opposite principle — fail closed, never auto-promote, and treat the network as hostile.
No cloud lock-in. No broker token in the repo. A Mac dashboard, a VPS snapshot publisher, and a promotion gate that requires more evidence than any single good week.
The shape of the system
VPS (always on) ├── completed 15m bar snapshot publisher └── 49-feature shadow scoring │ SSH (trusted known_hosts only) ▼ Mac (local) ├── dashboard (localhost, auto port) ├── local surge inference ├── shadow observation recorder ├── outcome settler (30/60/120 min) └── weekly shadow review Three deliberate choices:
- The VPS publishes, the Mac decides. The Mac owns evidence and evaluation. The VPS does not get to promote anything.
- Snapshots are completed bars only. No partial-bar scoring, ever.
- The local dashboard degrades gracefully. Network loss pauses new predictions; it does not crash the desk.
The 49-feature shadow lane
A separate research lane — 49 features, XGBoost, horizon h2 — runs alongside the main system. It does not:
- replace the champion model file
- enable orders
- present its score as a calibrated probability
That last point is critical. A shadow score is a rank, not a probability, until it has been calibrated on enough live outcomes. Calling a raw score "72% confidence" is how research lanes turn into expensive mistakes.
SNAPSHOT_MINUTE = 15 # completed bar only HORIZONS_MIN = (30, 60, 120) MIN_SESSIONS = 10 MIN_OUTCOMES = 150 The promotion gate: fail-closed by construction
The shadow lane stays in shadow until both conditions hold:
def can_promote(state): if state.sessions < 10: return False, "need 10+ sessions" if state.outcomes < 150: return False, "need 150+ settled outcomes" if state.stale_fraction > 0.05: return False, "too many stale snapshots" if state.calibration_gap > 0.10: return False, "calibration drift" return False, "promotion requires human sign-off" # never auto Read the last line again: even when every numeric gate passes, the system still returns False. Promotion is a human action. The code can only ever block, never approve.
This inverts the usual design. Instead of "auto-promote if metrics look good," it is "auto-block unless a human overrides." The default is safety.
Gate result: BLOCK (default) Override: human, logged, reversible Stale snapshots: the silent killer
The most dangerous state in any live system is not "down." It is "up, but serving yesterday's truth."
So every snapshot carries an age. If the age exceeds the freshness budget, it becomes context only — the Mac will display it but refuse to generate a new score from it.
def score_snapshot(snap, now): age = now - snap.generated_at if age > FRESH_BUDGET: return {"status": "STALE", "score": None} # no new prediction return {"status": "FRESH", "score": model.predict(snap.features)} Consequences, on purpose:
- A stale feed cannot open a position. It can only reduce exposure.
- Historical snapshots are never replayed as if they were live. Deduplication state persists across restarts.
- Gaps produce incomplete outcomes, and incomplete outcomes are excluded — not filled with an assumption.
That last rule is why the promotion counter is honest. You cannot reach 150 outcomes by guessing at the missing ones.
The Mac side: local inference that survives the network
The launcher does a few unglamorous things that matter:
1. Verify SSH host fingerprint against known_hosts (never disable host verification) 2. Check Python 3.10/3.11 + SciPy/XGBoost imports 3. Repair the venv from requirements-mac.txt if wheels are broken 4. Pick a free localhost port (8765 default, auto-fallback) 5. Start the dashboard with bounded-backoff retries The bounded backoff is the detail people skip. When the VPS is unreachable, a naive loop hammers SSH and burns the connection limit. A bounded backoff keeps the dashboard alive, shows "stale / disconnected," and resumes cleanly when the link returns.
Design rule: the UI tells the truth about its own freshness. A dashboard that looks healthy while the data is 40 minutes old is worse than a blank screen.
The CE/PE 5-minute surge challenger
Separately from the 49-feature lane, a 5-minute surge challenger runs locally on the Mac:
- records frozen entry scores at signal time
- records subsequent observed outcomes as Parquet under
shadow_evidence - keeps deduplication state across restarts so a restart cannot double-count a signal
- never replays historical alerts
This is explicitly failed-validation research, not orders. The naming matters: a folder called shadow_evidence cannot be mistaken for a live strategy by a future maintainer at 2 a.m.
What the desk refuses to do
The list of refusals is the architecture:
[ ] No orders from the shadow lane [ ] No partial-bar scoring [ ] No auto-promotion, ever [ ] No stale snapshot -> new position [ ] No replay of historical alerts [ ] No broker token or SSH key bundled in the repo [ ] No Telegram alerts from the launcher [ ] No silent filling of missing outcomes Eight "no"s. Each one is a failure mode I have seen or caused. The value of the system is not the model — it is the boundary around the model.
The week the gate earned its keep
When a shadow lane posts a great week, the temptation is enormous. But one good week inside a 10-session / 150-outcome requirement is one data point. The gate exists precisely for the moment the numbers look exciting, because that is when discipline is hardest.
And note what the gate cannot do: it cannot promote. Even a perfect week just moves you closer to the human review. The system's best outcome is "eligible for a conversation," not "live."
The takeaway
A trading desk is not defined by its model. It is defined by what it refuses to do when the model looks great.
Local-first inference, completed-bar-only snapshots, stale-data rejection, deduplicated evidence, and a promotion gate that returns False by default — that is the difference between a research desk and a demo. Build the boundary first. The alpha is whatever survives it.
Educational research only. Not investment advice. Shakti Tiwari is NISM-Series-XII certified as an educator, not a SEBI-registered Research Analyst or Investment Adviser. Options trading carries substantial risk of loss.


