AB Trade-X Bot Architecture

High-level visual map of how a TradingView alert becomes validated, routed, executed, tracked, and reported across Tradovate/Lucid, Rithmic/Bulenox, and Kraken/Breakout.

Static documentation only | no bot controls changed

Signal To Trade Flow

The normal production path
1. TradingView PineAlerts send JSON: action, symbol, strategy, secret, price, TP/SL, script_id, source_symbol.
Pine-owned exits
2. ngrok -> FastAPIExternal webhook reaches local Mac Mini on the active lane port.
src/main.py
3. Fast GatesSecret, JSON schema, strategy, script ID, source symbol, allowlist, lane, exit profile.
fail closed
4. Strategy GuardRegistry selects the guard, checks session window, consumes diagnostic fire count.
REGISTRY
5. Account RouterFilters by lane, target accounts, runtime disabled state, allowed_symbols, group gates.
fanout
6. Broker AdapterTradovate OSO, Rithmic three orders, or Kraken REST/UI bracket execution.
live orders
7. State + ReportsActive trade state, broker monitors, JSONL trade log, daily reporting attribution.
audit trail

Runtime Lanes

Same code, different broker scope

combined

port 8000

Tradovate + Rithmic + Kraken. Current single-process production behavior.

MES/MNQBTC/ETH

futures

port 8000

Tradovate-only futures lane. Rejects crypto signals.

Lucid/Abe

buler

port 8003

Rithmic/Bulenox futures lane. Current policy is guarded MES-only.

Rithmic

breakout

port 8002

Kraken/Breakout crypto lane. Rejects non-crypto signals.

UI executor

Broker Branches

Where the router sends approved accounts

Tradovate / Lucid + Abe

RESTOSO bracket
  • Auth token is initialized at startup and refreshed on 401.
  • Entry + TP + SL are submitted through one placeOSO call.
  • Live quote guards reject stale MNQ/MES alert prices.
  • Runner manager tracks OSO child IDs after placement.

Rithmic / Bulenox

WebSocketprotobuf
  • Sessions connect lazily per account and stay alive with heartbeat.
  • Pre-entry market-data quote guard validates alert freshness.
  • Current bracket is three naked orders: entry, SL, TP.
  • Reader loop resolves gateway ACKs and tracks exchange notifications.

Kraken / Breakout

UI executorREST fallback
  • Crypto alerts use Pine absolute TP/SL prices.
  • Risk sizing turns max dollar risk into BTC/ETH quantity.
  • Single-position and daily loss gates protect the eval account.
  • UI or REST monitor clears state and logs outcomes when flat.

Operational Swimlane

One signal across system layers
External
TradingViewPine alert JSON
ngrokPublic tunnel
Mac MiniLocal FastAPI process
Broker APIsTradovate, Rithmic, Kraken
ReportsEmail/journal builders
Validation
WebhookPayloadpydantic schema
Secretshared key
Script/source gateshard futures checks
StrategyGuardsession + fire count
Risk rulescaps and kill switches
Execution
Account filterlane, target, runtime, allowed_symbols
Qty/tickscontract caps or crypto qty
Concurrent fanoutasync tasks per account
Broker adapterplace bracket
Monitorrunner, OCA, state cleanup
Persistence
data/trades.jsonlaudit log
fire_counts.jsondiagnostic counts
rithmic_state.jsonBuler state
kraken_state.jsonBreakout state
runtime_disabled*.jsonaccount gates