deepbook
v0.3.0
Published
Terminal trading interface for DeepBook on Sui
Maintainers
Readme
DeepBook TUI
A terminal trading interface for DeepBook — Sui's native central limit order book protocol. View live market data, place spot and margin orders, and manage positions entirely from the terminal.
Mainnet only.
Features
- Live orderbook depth with braille-rendered bar charts
- OHLCV price charts with multiple timeframes
- Spot and margin trading (up to 4x leverage)
- Open positions tracking with one-key close
- Wallet balance management and SUI/token transfers
- Full keyboard navigation — no mouse needed
Requirements
- Node.js 20+
- Python 3.11+
- A Sui wallet (Ed25519 keypair)
Install
npm install -g deepbookOr run without installing globally:
npx deepbookRun
deepbookOn first launch, the CLI:
- checks for Python 3.11+
- creates a virtualenv at
~/.deepbook/venv - installs Python dependencies from the packaged
requirements.txt - launches the TUI
On macOS, deepbook opens the app in a new Terminal/iTerm window by default. Use inline mode to stay in the current terminal:
deepbook --inlineThe app will prompt you to import or create a wallet on first launch. The private key is stored in macOS Keychain, and public account metadata is stored at ~/.deepbook/account.json.
If Python dependency installation fails, you may need system build tools for pynacl:
# macOS
xcode-select --install
# Ubuntu
sudo apt install python3-dev libsodium-devDevelopment
# Install TS sidecar deps once on a fresh clone
cd ts && npm ci && cd ..
# Auto-reload on file changes (recommended)
watchfiles "python3 app/main.py" app/
# Or use the dev script to open in a sized terminal
bash dev.sh # Terminal.app
bash dev.sh --iterm # iTerm2Validate syntax:
python3 -m py_compile $(rg --files app -g '*.py')Architecture
app/
├── main.py # Textual app shell + TS sidecar orchestration
├── ui/ # Trade/account panels, focus helpers, overlays, onboarding
├── state/ # Account storage, executor bridge, state readers/writers
└── shared/ # Config, logging, biometrics, keychain, JSON helpers
ts/
├── src/startup.ts # One-time startup sync (pools, pyth, wallet coins)
├── src/poller-main.ts # Long-lived poller entrypoint
├── src/poller.ts # On-chain/indexer/Pyth reads -> state files
├── src/executor-main.ts # One-shot execution entrypoint
└── src/executor*.ts # PTB construction, execution, manager updatesData flows through three layers:
- Startup + Poll (
ts/src/startup.ts,ts/src/poller.ts) — fetches from indexer + Sui RPC + Pyth, writes normalized JSON to~/.deepbook/state/ - UI (
ui/) — reads from disk on a 1-second interval, renders to terminal - Execute (
app/state/executor.py+ts/src/executor*.ts) — authenticates, builds PTBs, submits transactions, updates local state
Keyboard shortcuts
| Key | Action |
|-----|--------|
| 1 | Trade view |
| 2 | Account view |
| m | Markets sidebar |
| l | Latency overlay |
| r | Refresh |
| q | Quit |
| Arrow keys | Navigate between panels |
| Enter | Confirm / submit |
| Esc | Close overlay |
License
MIT
