Live mode runs the same engine, the same MCP tools, and the same Telegram feed as paper mode — the only difference is thatDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/backtest-kit/ai-trading-mcp/llms.txt
Use this file to discover all available pages before exploring further.
modules/live.module.ts replaces the paper broker with a hardened Binance spot adapter that places real orders. Every open_position call routes to a real Binance account; fills, brackets, and closes all settle on-exchange.
Prerequisites
Set your Binance API credentials as environment variables before starting the process:process.env. The authenticated spot client (getSpotExchange) is initialised lazily on the first order attempt — if the credentials are missing or invalid, the ccxt call will fail and the error will be typed and surfaced to the engine.
Launch Command
--live activates the spot broker adapter, --entry points to the strategy file, and --ui serves the dashboard on port 60050. The MCP HTTP bridge starts on 127.0.0.1:60051 as usual.
What Changes vs Paper Mode
| Component | Paper | Live |
|---|---|---|
| Exchange module | modules/paper.module.ts | modules/live.module.ts |
| Market data client | Public ccxt Binance (no auth) | Public ccxt Binance (no auth) |
| Order execution client | None — fills simulated | Authenticated ccxt Binance spot |
| Broker adapter | Engine-internal simulation | Broker.useBrokerAdapter(...) |
| API credentials needed | No | Yes |
| Real money at risk | No | Yes |
Exchange Setup in the Live Module
The live module registers the sameccxt-exchange schema for market data as paper mode — a public client for candles, order book, and price formatting:
getSpotExchange client — initialized with BINANCE_API_KEY and BINANCE_API_SECRET — handles all order operations exclusively inside the broker adapter. Market data and order execution are intentionally separate clients.
The Spot Broker Adapter
The live module installs a battle-tested spot broker viaBroker.useBrokerAdapter(). It was written after a real incident post-mortem and addresses the failure modes that naive spot adapters trip over on Binance.
commit_buy — Guaranteed Entry
A limit buy is posted with
clientOrderId = signalId. The adapter polls up to 10 × 10 seconds for a fill. If the order hasn’t filled at the deadline, it cancels (handling the fill-at-cancel-time race correctly) and tops up any unfilled remainder with a market order. The entry is guaranteed to complete; no resting order is ever left on the book.commit_trade — OCO Brackets
Take-profit and stop-loss are placed as a single OCO order (
privatePostOrderOco), not as two independent sell orders. Two independent sells against the same coin balance on Binance spot is the root cause of InsufficientFunds cascade failures — the first sell freezes the coins, the second dies. One OCO = one freeze, both levels atomically guarded.Idempotent Recovery via clientOrderId
Before every entry attempt, the adapter queries Binance by
origClientOrderId = signalId. If a prior POST already executed (crash before brackets, lost network response), the adapter checks free + used balance (not just free — coins inside an OCO freeze show free ≈ 0) and skips the buy entirely if the position is confirmed. If a prior order is still NEW or PARTIALLY_FILLED, it cancels first (freeing the clientOrderId) before re-entering.commit_cancel — Verified Close
On close, the adapter runs a cancel sweep across all open orders for the symbol (up to 10 rounds, 1 s between each cancel). It then runs a second verification loop that proves the book is empty before selling — selling over a live sell order causes
InsufficientFunds. Finally it sells the entire free balance of the base asset, sweeping any orphaned tranches along. Dust below minNotional is treated as a confirmed close.Adapter Tuning Constants
| Constant | Value | Meaning |
|---|---|---|
FILL_POLL_INTERVAL_MS × FILL_POLL_ATTEMPTS | 10 s × 10 | Limit entry gets ~100 s to fill before the market top-up fires |
CANCEL_SETTLE_MS | 2 s | Wait after cancel before re-reading filled quantity |
CANCEL_ROUNDS | 10 | Cancel-sweep retries when clearing the book on close |
STOP_LIMIT_SLIPPAGE | 0.995 | Stop-limit price parked 0.5 % below the SL trigger |
TRADE_SELL_LOWER_PERCENT | 0.999 | Close limit priced 0.1 % under market to fill fast |
Error Classification
The adapter mapsccxt exceptions to engine-typed errors so the engine can decide retry policy:
ccxt.NetworkError→OrderTransientError— bounded retry with the samesignalIdccxt.ExchangeError→OrderRejectedError— permanent drop, no retry
What the Agent Does Not Control
Even in live mode, Claude’s vocabulary is exactly three tools. The following are engine-computed and cannot be overridden by the model, the prompt, or anything in the Telegram feed:- Position size — computed from engine-side cost configuration and available USDT balance (capped at 98 % of free USDT to leave room for fees)
- Take-profit price — engine-computed at signal creation
- Stop-loss price — engine-computed at signal creation
- Symbol eligibility — enforced by
CC_SYMBOL_LIST; any symbol outside the whitelist is rejected before the broker is ever called
modules/live.module.ts source file.