A previous post traced the macroscopic shape of the system — five flows, five trust questions. This one traces the path. One tick arrives over a WebSocket. Milliseconds later, an order is on its way to the broker. Here is every step in between.
The chain, at a glance
Inside a single RealtimeTrader GenServer, the path from tick to broker is a sequence of handle_info clauses and private helpers. The interesting design choices are in which steps run on partial candles versus completed bars, and in what gets pushed off the callback chain.
Broker WebSocket
│
▼
MarketDataSource (per session)
│ Phoenix.PubSub broadcast
│ {:partial_candle, candle}
│ {:new_candle, candle}
▼
RealtimeTrader.handle_info/2
│
├─ partial → enrich_bar/3 → broadcast to UI → stop
│
└─ new → enrich_bar/3 → CandleManager.add_or_replace/3
│
├─ {:new, candles} → maybe_run_strategy
└─ {:replaced, _, idx} → update state, stop
│
▼
Strategy.Context built
│
▼
strategy.decide_action/2
│
▼
{:nothing | :submit_order
| :modify_orders | :cancel_orders, ...}
│
▼
DecisionHandler.handle_decision/3
│
▼
AccountManager.submit_order/2
│
▼
Broker
The rest of this post is that diagram, unrolled, with the real code at each step.
Discussion
Create a free account to join the conversation.