mirageStartSession (same effect as clicking Start session in the broker panel).
Product overview: Mirage. Shared connect and order fields: API overview.
Protocol
- Connect to
wss://www.getavenir.co/ws { "action": "userConnected", "token": "<Clerk JWT>", "applicationType": "mirage" }- Wait for
orderBook(auth is async; broker greeting/confirm may appear;brokerMessagesstay empty until start) and oftencountdownwith"pending" { "action": "mirageStartSession", "sessionDurationSeconds": 60 }to start bots, countdown, and reveal the PM order- Receive
mirageSessionwithbrokerMessages, then anorderBookthat includes the same order - Trade with
placeOrder/cancelOrder/cancelAllOrderson instrument0 resetExchangeor disconnect ends/logs the run as configured by the server
Starter code
Client actions
Server messages
mirageSession
Sent to the requesting socket after mirageStartSession:
Calling
mirageStartSession again while already running returns the same broker order and does not restart the clock.
countdown
value is seconds left, or "pending" before/after a session.
orderBook (Mirage extras)
In addition to the common book fields, Mirage may include:
Scoring
Past sessions can store a Mirage Score (0–1). Formula and examples: Mirage.Related
- Guide: Mirage
- Shared auth and orders: API overview