Skip to main content
Mirage is a single-instrument session with a PM-style broker prompt, bots, and a countdown. Connect as a UI client, then start with mirageStartSession (same effect as clicking Start session in the broker panel). Product overview: Mirage. Shared connect and order fields: API overview.

Protocol

  1. Connect to wss://www.getavenir.co/ws
  2. { "action": "userConnected", "token": "<Clerk JWT>", "applicationType": "mirage" }
  3. Wait for orderBook (auth is async; broker greeting/confirm may appear; brokerMessages stay empty until start) and often countdown with "pending"
  4. { "action": "mirageStartSession", "sessionDurationSeconds": 60 } to start bots, countdown, and reveal the PM order
  5. Receive mirageSession with brokerMessages, then an orderBook that includes the same order
  6. Trade with placeOrder / cancelOrder / cancelAllOrders on instrument 0
  7. resetExchange or 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.