Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/backtest-kit/wallet-manager/llms.txt

Use this file to discover all available pages before exploring further.

The Wallet Manager REPL is a lightweight interactive shell that gives you direct, programmatic access to a live Binance spot account. It is the fastest way to inspect balances, examine order history, place entries, and flatten positions by hand — without involving the trading engine at all. Use it when you need to reconcile a symbol manually, debug a broker adapter flow against a real account, or run one-off trades outside of any automated strategy.

Starting the REPL

Run the single npm start command from the wallet-manager directory. It builds the Rollup bundle first, loads .env via dotenv, and then launches the REPL process:
npm start
Before running, ensure your .env file is present with valid Binance credentials:
CC_BINANCE_API_KEY=your_api_key_here
CC_BINANCE_API_SECRET=your_api_secret_here

Prompt Behavior

The prompt evaluates raw JavaScript. await is fully supported at the top level — every expression is implicitly awaited. Object and array results are pretty-printed as indented JSON. Scalar results (numbers, strings) are printed as-is. Type exit to terminate the session cleanly.
repl => await wallet.walletPublicService.fetchPrice("SOLUSDT")
77.56
repl => await wallet.walletPublicService.fetchBalance("SOLUSDT")
{
  "quantity": 2.5,
  "usdt": 193.90
}
repl => exit
If an expression throws, the error is printed and the prompt returns — the REPL does not exit.

Two Globals

Two objects are injected into the global scope at startup. wallet — the service container. It exposes two layers:
GlobalPurposeWhen to use
wallet.walletPublicServicePer-symbol execution queue, input validation, structured audit log after every commit* callDefault — use this one
wallet.walletPrivateServiceRaw layer with no validation, no queue, and no audit logDebugging and introspection only
fs — Node’s built-in fs module. Useful for saving results to disk between sessions:
fs.writeFileSync("out.json", JSON.stringify(result, null, 2))

Audit Log

Every trading commit* call (commitBuy, commitSell, commitTrade, commitCancel) routed through walletPublicService emits a structured console.log record immediately after the operation completes, regardless of whether it succeeded or failed. commitReload does not emit a log entry — it only flushes caches. The record always contains at minimum:
{
  "symbol": "SOLUSDT",
  "action": "buy",
  "amountUSDT": 20,
  "averagePrice": 77.56,
  "date": "2025-01-15T10:32:00.000Z",
  "status": "success"
}
The action field is one of "buy", "sell", "trade", or "cancel". The status field is "success" when the call returned normally and "failed" when it threw. For commitTrade, the record includes two additional fields — takeProfitPrice and stopLossPrice — alongside the base fields above. The walletPrivateService.clear() cache flush is always called in the finally block after every trading commit, so subsequent reads reflect the post-trade state.

Per-Symbol Queue

walletPublicService serializes all operations on the same symbol through a queued() execution queue. Each symbol gets its own independent queue instance, memoized by symbol string. If you fire two concurrent commit* calls on "SOLUSDT", the second call waits for the first to finish before it executes — they are never parallelized. Calls on different symbols run concurrently. This prevents the classic broker-adapter race condition where a sell order is placed while a pending buy still holds USDT in lock, or where two partial sells compete against the same coin balance.

Next Steps

Read Commands

Inspect live prices, balances, order history, and PnL without placing any orders.

Mutating Commands

Execute guarded buys, sells, OCO bracket trades, and full-flatten cancels.

Build docs developers (and LLMs) love