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 is a Binance spot wallet toolkit built for two jobs: driving the exchange by hand through an interactive REPL, and serving as the canonical reference implementation for the exchange side of a backtest-kit broker adapter. It encodes the correct order-management sequence—cancel pending orders, verify the book is clean, then sell—so you never hit an “insufficient balance” error caused by funds locked in a resting order.
Live keys, real money. Every commit* call places real orders on Binance spot. There is no dry-run mode. Always verify your intent before executing mutating commands.

Introduction

Understand the architecture, the two service layers, and why the cancel-verify-sell sequence matters.

Quickstart

Set up your API keys, install dependencies, and run your first REPL session in minutes.

REPL Guide

Explore the interactive REPL: read balances, inspect orders, and execute trades without code changes.

Broker Adapter

Wire the wallet flows into a backtest-kit broker adapter with the three rules for safe order management.

How it works

Wallet Manager wraps node-binance-api in a DI-wired service layer with two tiers:
  • WalletPublicService — the recommended entry point. Validates inputs, serializes per-symbol execution to prevent race conditions, and emits a structured audit log after every commit.
  • WalletPrivateService — the raw Binance layer underneath. TTL-cached prices (30 s), orders (10 min), and PnL (10 min). Use for debugging only.

Order Management Concepts

Learn the three patterns — cancel-verify-sell, poll-timeout-fallback, and clientOrderId reconcile — that prevent stuck positions.

API Reference

Full method signatures, parameter types, and return values for WalletPublicService.

Core flows at a glance

1

Buy

commitBuy(symbol, amountUSDT) — places a limit BUY at price × 1.001, polls for up to 100 s, then cancels and market-buys the remainder if the limit does not fill.
2

Sell

commitSell(symbol, amountUSDT) — places a limit SELL at price × 0.999, same poll loop and market-sell fallback.
3

Trade with brackets

commitTrade(symbol, amountUSDT, takeProfit, stopLoss) — buys via the commitBuy flow then immediately protects the position with an OCO (take-profit + stop-loss) sell order.
4

Flatten

commitCancel(symbol) — cancels ALL open orders on the symbol, verifies the book is clean, then sells the entire free coin balance to USDT. The safe exit path for any position.

Build docs developers (and LLMs) love