open-nof1.ai is an AI-powered cryptocurrency automated trading system that deeply integrates large language model intelligence with quantitative trading practices. Built on an Agent framework, the system achieves truly intelligent trading by granting AI complete autonomy in market analysis and trading decisions.
The system follows a minimal human intervention design philosophy, abandoning traditional hardcoded trading rules and allowing AI models to autonomously learn and make decisions based on raw market data. It integrates with Binance Futures (supporting both testnet and mainnet), provides complete perpetual contract trading capabilities, covers mainstream cryptocurrencies such as BTC, ETH, SOL, and supports full automation from data collection, intelligent analysis, risk management to trade execution.
- Overview
- Architecture
- Key Features
- Quick Start
- Project Structure
- Configuration
- Commands Reference
- Production Deployment
- Troubleshooting
- Development Guide
- API Documentation
- Contributing
- License
┌─────────────────────────────────────────────────────────┐
│ Trading Agent (AI) │
│ (DeepSeek V3.2 / Gork4 / Claude) │
└─────────────────┬───────────────────────────────────────┘
│
├─── Market Data Analysis
├─── Position Management
└─── Trade Execution Decisions
┌─────────────────┴───────────────────────────────────────┐
│ VoltAgent Core │
│ (Agent Orchestration & Tool Routing) │
└─────────┬───────────────────────────────────┬───────────┘
│ │
┌─────────┴──────────┐ ┌───────────┴───────────┐
│ Trading Tools │ │ Binance Futures Client│
│ │ │ │
│ - Market Data │◄───────────┤ - Order Management │
│ - Account Info │ │ - Position Query │
│ - Trade Execution │ │ - Market Data Stream │
└─────────┬──────────┘ └───────────────────────┘
│
┌─────────┴──────────┐
│ LibSQL Database │
│ │
│ - Account History │
│ - Trade Signals │
│ - Agent Decisions │
└────────────────────┘
| Component | Technology | Purpose |
|---|---|---|
| Framework | VoltAgent | AI Agent orchestration and management |
| AI Provider | OpenAI Compatible API | Supports OpenRouter, OpenAI, DeepSeek and other compatible providers |
| Exchange | Binance Futures | Cryptocurrency trading (testnet & mainnet) |
| Database | LibSQL (SQLite) | Local data persistence |
| Web Server | Hono | High-performance HTTP framework |
| Language | TypeScript | Type-safe development |
| Runtime | Node.js 20+ | JavaScript runtime |
- Data-Driven: Provides raw market data to AI without preprocessing or subjective judgments
- Autonomous Decision-Making: AI has complete authority in analysis and trading decisions, without hardcoded strategy constraints
- Multi-Dimensional Analysis: Aggregates multi-timeframe data (5m, 15m, 1h, 4h) for comprehensive market view
- Transparent and Traceable: Records every decision process for backtesting analysis and strategy optimization
- Continuous Learning: System automatically accumulates trading experience and continuously optimizes decision models
- Model Support: DeepSeek V3.2, Grok4, Claude 4.5, Gemini Pro 2.5
- Data Inputs: Real-time prices, volume, candlestick patterns, technical indicators
- Autonomous Analysis: No pre-configured trading signals
- Multi-Timeframe: Aggregates data across multiple time windows
- Risk Management: AI-controlled position sizing and leverage management
- Supported Assets: BTC, ETH, SOL, BNB, XRP, DOGE, GT, TRUMP, ADA, WLFI
- Contract Type: USDT-settled perpetual futures
- Leverage Range: 1x to 10x (configurable)
- Order Types: Market orders, stop-loss, take-profit
- Position Direction: Long and short positions
- Real-time Execution: Sub-second order placement via Binance Futures API
- Web Dashboard: Accessible at
http://localhost:3100 - Account Metrics: Balance, equity, unrealized PnL
- Position Overview: Current holdings, entry prices, leverage
- Trade History: Complete transaction log with timestamps
- AI Decision Log: Transparency into model reasoning
- Technical Indicators: Visualization of market data and signals
- Automated Stop-Loss: Configurable percentage-based exits
- Take-Profit Orders: Automatic profit realization
- Position Limits: Maximum exposure per asset
- Leverage Control: Configurable maximum leverage
- Trade Throttling: Minimum interval between trades
- Audit Trail: Complete database logging of all actions
- Testnet Support: Risk-free strategy validation
- Process Management: PM2 integration for reliability
- Containerization: Docker support for isolated deployment
- Auto-Recovery: Automatic restart on failures
- Logging: Comprehensive error and info logging
- Health Monitoring: Built-in health check endpoints
- Node.js >= 20.19.0
- npm or pnpm package manager
- Git version control
# Clone repository
git clone <repository-url>
cd open-nof1.ai
# Install dependencies
npm install
Create .env file in project root:
# Server Configuration
PORT=3100
# Trading Parameters
TRADING_INTERVAL_MINUTES=5 # Trading loop interval
MAX_LEVERAGE=10 # Maximum leverage multiplier
INITIAL_BALANCE=2000 # Initial capital in USDT
# Database
DATABASE_URL=file:./.voltagent/trading.db
# Binance API Credentials (use testnet first!)
BINANCE_API_KEY=your_api_key_here
BINANCE_API_SECRET=your_api_secret_here
BINANCE_USE_TESTNET=true
# AI Model Provider (OpenAI Compatible API)
OPENAI_API_KEY=your_api_key_here
OPENAI_BASE_URL=https://openrouter.ai/api/v1 # Optional, supports OpenRouter, OpenAI, DeepSeek, etc.
AI_MODEL_NAME=deepseek/deepseek-v3.2-exp # Model nameAPI Key Acquisition:
- OpenRouter: https://openrouter.ai/keys
- OpenAI: https://platform.openai.com/api-keys
- DeepSeek: https://platform.deepseek.com/api_keys
- Binance Futures Testnet: https://testnet.binancefuture.com/en/futures/BTCUSDT
- Binance API Management: https://www.binance.com/en/my/settings/api-management
npm run db:init# Development mode with hot reload
npm run dev
# Production mode
npm run trading:startNavigate to http://localhost:3100 in your browser.
open-nof1.ai/
├── src/
│ ├── index.ts # Application entry point
│ ├── agents/
│ │ └── tradingAgent.ts # AI trading agent implementation
│ ├── api/
│ │ └── routes.ts # HTTP API endpoints for monitoring
│ ├── database/
│ │ ├── init.ts # Database initialization logic
│ │ ├── schema.ts # Database schema definitions
│ │ └── sync-from-gate.ts # Exchange data sync (legacy name, now Binance)
│ ├── scheduler/
│ │ └── tradingLoop.ts # Trading cycle orchestration
│ ├── services/
│ │ ├── binanceClient.ts # Binance Futures API client
│ │ ├── gateClient.ts # Legacy alias for Binance client
│ │ └── multiTimeframeAnalysis.ts # Multi-timeframe data aggregator
│ ├── tools/
│ │ └── trading/ # VoltAgent tool implementations
│ │ ├── accountManagement.ts # Account query and management
│ │ ├── marketData.ts # Market data retrieval
│ │ └── tradeExecution.ts # Order placement and management
│ ├── types/
│ │ └── gate.d.ts # TypeScript type definitions
│ └── utils/
│ └── timeUtils.ts # Time/date utility functions
├── public/ # Web dashboard static files
│ ├── index.html # Dashboard HTML
│ ├── app.js # Dashboard JavaScript
│ └── style.css # Dashboard styles
├── scripts/ # Operational scripts
│ ├── init-db.sh # Database setup script
│ ├── kill-port.sh # Service shutdown script
│ └── sync-from-gate.sh # Data sync script (legacy name, now Binance)
├── .env # Environment configuration
├── .voltagent/ # Data storage directory
│ └── trading.db # SQLite database file
├── ecosystem.config.cjs # PM2 process configuration
├── package.json # Node.js dependencies
├── tsconfig.json # TypeScript configuration
└── Dockerfile # Container build definition
| Variable | Description | Default | Required |
|---|---|---|---|
PORT |
HTTP server port | 3141 | No |
TRADING_INTERVAL_MINUTES |
Trading loop interval in minutes | 5 | No |
MAX_LEVERAGE |
Maximum leverage multiplier | 10 | No |
INITIAL_BALANCE |
Initial capital in USDT | 2000 | No |
DATABASE_URL |
SQLite database file path | file:./.voltagent/trading.db | No |
BINANCE_API_KEY |
Binance API key | - | Yes |
BINANCE_API_SECRET |
Binance API secret | - | Yes |
BINANCE_USE_TESTNET |
Use Binance Futures testnet | true | No |
OPENAI_API_KEY |
OpenAI compatible API key | - | Yes |
OPENAI_BASE_URL |
API base URL | https://openrouter.ai/api/v1 | No |
AI_MODEL_NAME |
Model name | deepseek/deepseek-v3.2-exp | No |
ACCOUNT_DRAWDOWN_WARNING_PERCENT |
Account drawdown warning threshold (%) | 10 | No |
ACCOUNT_DRAWDOWN_NO_NEW_POSITION_PERCENT |
Drawdown threshold to stop opening new positions (%) | 15 | No |
ACCOUNT_DRAWDOWN_FORCE_CLOSE_PERCENT |
Drawdown threshold to force close all positions (%) | 20 | No |
The system supports any OpenAI API compatible provider:
OpenRouter (Recommended, supports multiple models):
OPENAI_BASE_URL=https://openrouter.ai/api/v1
AI_MODEL_NAME=deepseek/deepseek-v3.2-exp # or x-ai/grok-4-fast, anthropic/claude-4.5-sonnetOpenAI:
OPENAI_BASE_URL=https://api.openai.com/v1
AI_MODEL_NAME=gpt-4o # or gpt-4o-miniDeepSeek:
OPENAI_BASE_URL=https://api.deepseek.com/v1
AI_MODEL_NAME=deepseek-chat # or deepseek-coderSupported models (via different providers):
openai/gpt-4o-mini- Cost-effective optionopenai/gpt-4o- High-quality reasoninganthropic/claude-4.5-sonnet- Strong analytical capabilitiesgoogle/gemini-pro-2.5- Multimodal support
To change models, modify the configuration in src/agents/tradingAgent.ts.
# Development mode with hot reload
npm run dev
# Type checking
npm run typecheck
# Linting
npm run lint
# Auto-fix linting issues
npm run lint:fix# Start trading system
npm run trading:start
# Stop trading system
npm run trading:stop
# Restart trading system
npm run trading:restart# Initialize database schema
npm run db:init
# Reset database (clear all data)
npm run db:reset
# Check database status
npm run db:status
# Sync data from Binance (legacy script name)
npm run db:sync
# Sync position data
npm run db:sync-positions# Use quick start script (recommended)
npm run docker:start
# Stop container
npm run docker:stop
# View logs
npm run docker:logs
# Build image
npm run docker:build
# Using Docker Compose
npm run docker:up # Start development environment
npm run docker:down # Stop development environment
npm run docker:restart # Restart container
# Production environment
npm run docker:prod:up # Start production environment
npm run docker:prod:down # Stop production environment# Start daemon process
npm run pm2:start
# Start in development mode
npm run pm2:start:dev
# Stop process
npm run pm2:stop
# Restart process
npm run pm2:restart
# View logs
npm run pm2:logs
# Real-time monitoring
npm run pm2:monit
# List all processes
npm run pm2:list
# Delete process
npm run pm2:delete# Build for production
npm run build
# Run production build
npm startPM2 provides robust process management for long-running Node.js applications.
Installation and Setup:
# 1. Install PM2 globally
npm install -g pm2
# 2. Start application
npm run pm2:start
# 3. Enable startup script
pm2 startup
pm2 save
# 4. Monitor logs
npm run pm2:logsPM2 Configuration (ecosystem.config.cjs):
module.exports = {
apps: [
{
name: 'open-nof1.ai',
script: 'tsx',
args: '--env-file=.env ./src',
instances: 1,
autorestart: true,
watch: false,
max_memory_restart: '1G',
env: {
NODE_ENV: 'production',
TZ: 'Asia/Shanghai'
}
}
]
};Build and Run:
# Build Docker image
docker build -t open-nof1.ai:latest .
# Run container
docker run -d \
--name open-nof1.ai \
-p 3141:3141 \
--env-file .env \
--restart unless-stopped \
open-nof1.ai:latest
# View logs
docker logs -f open-nof1.ai
# Stop container
docker stop open-nof1.ai
# Remove container
docker rm open-nof1.aiDocker Compose (optional):
version: '3.8'
services:
trading:
build: .
container_name: open-nof1.ai
ports:
- "3141:3141"
env_file:
- .env
restart: unless-stopped
volumes:
- ./.voltagent:/app/.voltagentError: database is locked
Solution:
# Stop all running instances
npm run trading:stop
# Or forcefully kill
pkill -f "tsx"
# Remove database lock files
rm -f .voltagent/trading.db-shm
rm -f .voltagent/trading.db-wal
# Restart
npm run trading:startError: BINANCE_API_KEY and BINANCE_API_SECRET must be set in environment variables
Solution:
# Verify .env file
cat .env | grep BINANCE_API
# Edit configuration
nano .envError: EADDRINUSE: address already in use :::3141
Solution:
# Method 1: Use stop script
npm run trading:stop
# Method 2: Manually kill process
lsof -ti:3141 | xargs kill -9
# Method 3: Change port in .env
# Set PORT=3142Cause: Candlestick data format mismatch
Solution:
# Pull latest updates
git pull
# Reinstall dependencies
npm install
# Restart system
npm run trading:restartError: OpenAI API error or connection failure
Solution:
- Verify
OPENAI_API_KEYis correct - Confirm
OPENAI_BASE_URLis configured correctly- OpenRouter:
https://openrouter.ai/api/v1 - OpenAI:
https://api.openai.com/v1 - DeepSeek:
https://api.deepseek.com/v1
- OpenRouter:
- Ensure API key has sufficient credits
- Check network connectivity and firewall settings
- Verify the service provider's status
# View real-time terminal logs
npm run trading:start
# View PM2 logs
npm run pm2:logs
# View historical log files
tail -f logs/trading-$(date +%Y-%m-%d).log
# View PM2 error logs
tail -f logs/pm2-error.log# Check database status
npm run db:status
# Enter SQLite interactive mode
sqlite3 .voltagent/trading.db
# SQLite commands
.tables # List all tables
.schema account_history # View table schema
SELECT * FROM account_history ORDER BY timestamp DESC LIMIT 10;
.exit # Exit SQLite| Endpoint | Method | Description |
|---|---|---|
/api/account |
GET | Current account status and balance |
/api/positions |
GET | Active positions |
/api/trades |
GET | Trade history |
/api/decisions |
GET | AI decision logs |
/api/health |
GET | System health check |
Real-time data streaming available for:
- Account updates
- Position changes
- New trade executions
- AI decision events
Critical: Always test thoroughly on testnet before mainnet deployment.
# Configure in .env
BINANCE_USE_TESTNET=trueTestnet advantages:
- Zero financial risk with virtual funds
- Complete simulation of real trading environment
- Validate AI strategy effectiveness
- Test system reliability under various conditions
When transitioning to mainnet:
- Start with minimal capital (recommended: 100-500 USDT)
- Monitor performance for several days
- Gradually scale capital based on proven results
- Set appropriate stop-loss percentages
# Backup database
cp .voltagent/trading.db .voltagent/trading.db.backup-$(date +%Y%m%d)
# Automated backup script
#!/bin/bash
backup_dir="backups"
mkdir -p $backup_dir
cp .voltagent/trading.db "$backup_dir/trading-$(date +%Y%m%d-%H%M%S).db"- Regularly review web dashboard metrics
- Analyze AI decision logs for patterns
- Monitor error logs and system alerts
- Adjust parameters based on market conditions
- Set conservative maximum leverage (recommended: 3-5x)
- Define maximum position size per trade
- Diversify across multiple assets
- Avoid trading during extreme market volatility
Warning: Ensure thorough testnet validation before mainnet deployment.
# 1. Stop the system
# Press Ctrl+C
# 2. Edit .env file
nano .env
# 3. Update configuration
BINANCE_USE_TESTNET=false
BINANCE_API_KEY=your_mainnet_api_key
BINANCE_API_SECRET=your_mainnet_api_secret
# 4. Restart system
npm run trading:start- VoltAgent Documentation
- OpenRouter Model Catalog
- OpenAI API Reference
- DeepSeek API Documentation
- Binance Futures API Reference
- Binance Futures Testnet
This system is provided for educational and research purposes only. Cryptocurrency trading carries substantial risk and may result in financial loss.
- Always test strategies on testnet first
- Only invest capital you can afford to lose
- Understand and accept all trading risks
- AI decisions do not guarantee profitability
- Users assume full responsibility for all trading activities
- No warranty or guarantee of system performance
- Past performance does not indicate future results
This project is licensed under the GNU Affero General Public License v3.0 (AGPL-3.0).
- Free to use: You may use this software for any purpose
- Open source requirement: Any modifications or derivative works must be released under AGPL-3.0
- Network use: If you provide this software as a service over a network, you must make the source code available
- No warranty: Software is provided "as is" without warranty of any kind
See the LICENSE file for complete terms.
We chose AGPL-3.0 to ensure:
- The trading community benefits from all improvements
- Transparency in financial software
- Prevention of proprietary forks
- Protection of user freedoms
Contributions are welcome! Please follow these guidelines:
- Use GitHub Issues for bug reports and feature requests
- Provide detailed reproduction steps
- Include system information and logs
- Check for existing issues before creating new ones
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes following Conventional Commits
- Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Follow existing TypeScript code style
- Add tests for new functionality
- Update documentation as needed
- Ensure all tests pass
- Run linter before committing
Follow Conventional Commits specification:
<type>[optional scope]: <description>
[optional body]
[optional footer]
Types:
feat: New featurefix: Bug fixdocs: Documentation changesstyle: Code style changes (formatting, etc.)refactor: Code refactoringperf: Performance improvementstest: Test additions or modificationschore: Build process or auxiliary tool changesci: CI/CD configuration changes
