TON DeFi market research and trading CLI — built for AI Agents.
TON AI Agent Hackathon · Track 1: Agent Infrastructure
Website: tonquant.com · npm:
npm install -g tonquant
A command-line tool that lets AI Agents (like OpenClaw) and developers perform quantitative research, backtest strategies, and inspect DeFi markets on the TON blockchain.
Key features:
- Agent-driven research loop:
autoresearch runchains data→factor→backtest→report automatically - Full quant pipeline: OHLCV data, RSI/MACD/volatility factors, momentum backtesting
--jsonoutput for AI agent consumption- Human-readable colored terminal output for developers
- STON.fi DEX integration (prices, pools, swap simulation)
- TonAPI integration (wallet balance, transaction history)
- Encrypted mnemonic storage (AES-256-GCM)
# Install (requires Bun on PATH — https://bun.sh)
npm install -g tonquant
# Try it out
tonquant trending --limit 5
tonquant price TON
tonquant pools USDT/TON
tonquant research NOT --jsontonquant ships with its bundled quant backend in the published package. Support commands and quant commands work after install without manually setting TONQUANT_QUANT_CLI.
| Command | Description |
|---|---|
tonquant autoresearch run --asset TON/USDT |
Full research loop: data→factor→backtest→report |
tonquant data fetch TON/USDT |
Fetch OHLCV market data |
tonquant data list |
List cached datasets |
tonquant factor compute --factors rsi,macd,volatility |
Compute technical factors |
tonquant factor list |
List available factors |
tonquant backtest run --strategy momentum |
Run strategy backtest |
tonquant preset list |
List strategy presets |
tonquant preset show momentum-ton |
Show preset details |
| Command | Description |
|---|---|
tonquant price <symbol> |
Token price and details |
tonquant pools <A>/<B> |
Pool liquidity and fees |
tonquant trending |
Top tokens by liquidity |
tonquant research <symbol> |
Market research summary |
tonquant init --mnemonic '...' |
Configure wallet |
tonquant balance [--all] |
Wallet balance with USD |
tonquant swap <from> <to> <amount> |
Simulate DEX swap |
tonquant history |
Transaction history |
Add --json to any command for structured JSON output.
See skill/SKILL.md for full command reference, JSON schemas, and Agent workflows.
CLI Layer (commander)
Phase 0: price | pools | trending | init | balance | swap | research | history
Phase 1: data | factor | backtest | preset | autoresearch
↓
Quant API Layer (src/quant/api/) Query Layer (queries.ts)
runDataFetch | runFactorCompute | fetchPriceData | fetchPoolData | ...
runBacktest | runPresetShow ↓
↓ Service Layer
Quant Runner (src/quant/runner/) stonfi.ts | tonapi.ts | wallet.ts
subprocess spawn → JSON stdio ↓
↓ Cache Layer (cache.ts)
Quant Backend (quant-backend/) ↓
data | factor | backtest | preset External APIs
↓ STON.fi v1 | TonAPI v2
Orchestrator (src/quant/orchestrator.ts)
preset → data → factor → backtest → report
| Component | Technology |
|---|---|
| Runtime | Bun |
| Language | TypeScript (strict) |
| CLI | Commander |
| Validation | Zod |
| TON SDK | @ton/ton, @ton/crypto, @ton/core |
| DEX | STON.fi HTTP API v1 |
| Wallet API | TonAPI v2 |
| Terminal UI | chalk, cli-table3 |
| Linting | Biome |
| Testing | bun:test (135 tests, 80%+ coverage) |
TonQuant is designed as an OpenClaw skill. The skill/SKILL.md file teaches any MCP-compatible Agent how to:
- Discover tokens (
trending) - Research before trading (
research,price,pools) - Simulate trades (
swap) - Monitor portfolio (
balance --all)
All commands support --json for structured parsing.
bun test # Run tests
bun test --coverage # With coverage report
bun run typecheck # TypeScript check
bun run lint # Biome linting
bun run dev # Run CLI in dev modeMIT