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.

Wallet Manager ships with an interactive REPL that evaluates raw JavaScript against a live Binance spot account — no server to start, no REST client to configure. The steps below take you from a fresh clone to your first balance check and price fetch in under five minutes.
1

Prerequisites

Before you begin, make sure you have the following:
  • Node.js 18 or later — the REPL relies on readline and native ESM.
  • A Binance account with a Spot API key and secret. To create one, go to API Management in your Binance account settings and generate a new key.
When creating the API key, enable Spot & Margin Trading permission. Read-only keys can run the fetch* commands but will fail on any commit* call. IP restriction is strongly recommended for production keys.
2

Clone and install

Clone the repository and install dependencies:
git clone https://github.com/backtest-kit/wallet-manager
cd wallet-manager
npm install
The project uses Rollup to bundle src/index.ts into build/index.mjs. The npm start script runs the build automatically before launching the REPL, so no separate build step is needed.
3

Configure credentials

Create a .env file in the project root with your Binance API credentials:
CC_BINANCE_API_KEY=your_api_key_here
CC_BINANCE_API_SECRET=your_api_secret_here
npm start loads this file via dotenv before the REPL process starts. The variable names CC_BINANCE_API_KEY and CC_BINANCE_API_SECRET are read directly by WalletPrivateService when it initializes the node-binance-api client.
.env contains live credentials that authorize real orders on your Binance account. Never commit this file to version control. Add .env to your .gitignore if it is not already there.
4

Start the REPL

Launch the REPL with:
npm start
This runs npm run build (Rollup) first, then starts the interactive prompt:
repl =>
The prompt accepts raw JavaScript expressions. await is supported at the top level — no async wrapper needed. Objects are pretty-printed as JSON; primitives are printed as-is. Type exit to quit.
5

First commands

Try these read-only commands to confirm your credentials work and inspect your account:
repl => await wallet.walletPublicService.fetchPrice("SOLUSDT")
77.56

repl => await wallet.walletPublicService.fetchFiat("SOLUSDT")
150.32

repl => await wallet.walletPublicService.fetchBalance("SOLUSDT")
{
  "quantity": 0,
  "usdt": 0
}

repl => await wallet.walletPublicService.fetchOrders("SOLUSDT", 5)
[...]

repl => exit
CommandWhat it returns
fetchPrice("SOLUSDT")Current market price as a number
fetchFiat("SOLUSDT")Total account USDT balance (free + locked)
fetchBalance("SOLUSDT"){ quantity, usdt } — coin holdings (including amounts locked in open orders) and their USDT value
fetchOrders("SOLUSDT", N)Last N orders (FILLED / CANCELED / NEW) with side, price, quantities, and timestamps
If the REPL prints a credentials error on the first await, double-check that the .env file is in the project root (the same directory as package.json) and that both variable names are spelled correctly.
6

Two globals available

The REPL injects two globals into every expression you type:wallet — the service container, identical to the exported wallet object from src/index.ts. It has two properties:
  • wallet.walletPublicService — the recommended interface. Validates arguments, serializes calls per symbol via an execution queue, and emits a structured audit log record after every commit* call. Use this for all order placement and inspection.
  • wallet.walletPrivateService — the raw layer underneath. No validation, no queueing. Useful for inspecting TTL cache state or calling clear() to flush cached order and PnL data. Not recommended for order placement.
fs — Node’s built-in fs module, injected so you can dump results to disk without importing anything:
repl => const orders = await wallet.walletPublicService.fetchOrders("SOLUSDT", 50)
repl => fs.writeFileSync("orders.json", JSON.stringify(orders, null, 2))
This is handy for capturing large order histories or PnL arrays for offline analysis.

Next Steps

REPL Guide

Explore all read and mutating commands — commitBuy, commitSell, commitTrade, commitCancel — with full examples and expected outputs.

Order Management

Understand the cancel-verify-sell pattern, poll-with-timeout loop, and market fallback so you can build a correct broker adapter from scratch.

Build docs developers (and LLMs) love