A trading bot in a browser tab is a bot with a fatal flaw: it dies when the tab does. Close the laptop, drop the Wi-Fi, let the machine sleep — the strategy stops mid-position and nobody finds out until the loss shows up.
So I moved the engine to the server.
The browser hands off its OAuth material and the server opens its own authorized WebSocket to the broker, running the identical strategy loop. Closing the tab, sleeping the machine, losing the connection — none of it matters any more. Only pressing Stop stops it.
|
A bot nobody watches has nobody to notice it went quiet. Every way the loop can stall has to be self-detected, because the two worst stalls raise no error at all — from the outside they look identical to "the condition was met and nothing traded." So the engine watchdogs itself every 15 seconds. |
The failure modes that taught me this:
|
How each one gets caught
| Stall | Why it's invisible | Detection |
|---|---|---|
| Dead tick stream | Keepalive can't catch it — the subscription is dead but the connection under it is healthy and answering | No ticks for 45s rebuilds the connection |
| Half-open TCP | readyState stays OPEN indefinitely, no close event ever fires |
Nothing back for 70s means dead, full stop |
| Stalled settlement | The in-flight lock blocks every later signal, so trading ends without an error | Re-query the contract directly; write it off past 10 min |
Transient vs. genuine rejections. A RateLimit backs off and carries on. An
InsufficientBalance stops, because it will repeat identically. Conflating the two once
killed live sessions on their first network blip — a bot on 1-tick contracts signals twice
a second and burns any fixed retry budget long before a rate limit clears.
Strategy definitions are shared, not copied. The server imports the same catalogue the browser does, so a bot cannot trade one rule on screen and a different one in production.
|
Drag-and-drop strategy building in Blockly, compiled to a live execution engine — no code required from the trader. Server-side execution mode, self-healing WebSocket transport, and a simulated ledger that mirrors the real path exactly, with the buy removed.
|
Client management — Next.js, Prisma, copy-trading token flows Signals tooling — real-time market signal components Trading dashboards — chart adapters over live tick streams |