Event System
The event system connects triggers, trading groups, and execution through an event-driven model over WebSocket.
Messages are categorized into two domains:
event: Business events (signals, decisions). Persisted in theeventstable.system: Technical logs, discussion metadata, and state updates.
Event Categories
The system defines several event sub-types:
-
ImmediateEvent
- Processed immediately upon arrival at the gateway: validated, persisted, and dispatched via WebSocket.
- This is the primary flow used by triggers and trading groups today.
-
ScheduledEvent (Future)
- Contains a
trigger_attimestamp in the future. - Used for deferred execution (e.g., FOMC meeting reminders).
- Contains a
-
ConditionalEvent (Future)
- Contains a JSON
condition. - Used for market watchers (e.g., "if BTC drops below $60k").
- Contains a JSON
-
PostTradeEvent (
event_type: post_trade)- The payload format used by trading groups to send a Trade Decision back to the backend.
- Handled specially by the execution hooks if the condition domain is
trade_decision.
Database Schema Mapping
Business events are stored in the PostgreSQL events table with these key columns:
id: UUID (generated by server).type: immediate | scheduled | conditional | post_trade.source_id: The ID of the component that generated the event.priority: 1–10.targets: Array of strings determining the routing destination (e.g., a specific trading group name).title,payload,tags.
info
When sending events from a client service, you do not send the id or create_at fields. The server generates these when persisting the event.
Routing Pipeline
- Validate: The gateway checks the
typediscriminator (eventorsystem) and validates the schema. - Persist: Business events are saved to the
eventstable. - Dispatch: The gateway checks the
targetsarray against the names of currently connected WebSocket clients and pushes the event to matching connections.