Broker sessions rest while nothing needs them

A firm's client used to stay logged in around the clock, renewing on a fixed
timer overnight and at weekends. Now, once a firm has nothing open, nothing
pending and nothing left to trade before its next session for a random
15–45 minutes, its client disconnects and the dashboard shows it Resting.
It logs back in a random 20–50 minutes before the next session opens, at a
check-in every 3–7 Central daytime hours, or at once when trading starts, a
manual leg, copy trade, manual order or AutoBuyer run needs it. Token
renewals fall at random points (Tradovate 15–45 min before expiry, TopstepX
every 45–150 min). Settings → Trading → Rest idle broker sessions
(session_rest) turns it off.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Brandon Li
2026-10-21 13:28:47 -05:00
co-authored by Claude Opus 5.5
parent 6dd2528fe2
commit 5eb0ea7760
18 changed files with 872 additions and 41 deletions
+19 -2
View File
@@ -184,8 +184,9 @@ It is read-only unless `DX_CONFIRM=yes DX_ACCOUNT=<code>` are set too, which
adds one minimum-size live round trip.
`npm run check` runs the pure-logic checks (fees, stops, sizing, trading
hours, the DXtrade selector, the futures draw and instrument lists), plus local
HTTP/WebSocket checks against a temporary database.
hours, session rest times, the DXtrade selector, the futures draw and
instrument lists), plus local HTTP/WebSocket checks against a temporary
database.
### Outbound user agent
@@ -203,6 +204,22 @@ Use `brokerWebSocket` or `signalrWebSocket` from `lib/outbound-proxy.ts` for bro
sockets, and `directWebSocket` for control sockets. All share the same user agent;
the broker proxy still applies only to broker traffic.
### Broker session rest
A firm's broker session is logged out while nothing needs it, rather than kept
up around the clock (`lib/clients.ts`, session rest). Once a firm has nothing
open, nothing pending and nothing left to trade before its next session (the
weekend, the daily break, or a trade date whose accounts are all done) for a
random 15–45 minutes, its client disconnects. The dashboard shows it as
*Resting* with its accounts as last synced. A fresh login comes a random 20–50
minutes before the firm's next session opens, and a long rest is broken by a
check-in every 3–7 hours of the Central daytime. Starting trading, a manual leg,
a copy trade, a manual order or an AutoBuyer run logs a resting firm back in at
once. While logged in, tokens are renewed at random points (Tradovate 15–45
minutes before expiry, TopstepX every 45–150 minutes) rather than on a fixed
timer. Settings → Trading → *Rest idle broker sessions* (`session_rest`) turns
it off; `/api/health` lists each resting firm and when it is back.
---
## The master dashboard