Mantle AI Trader - AI-Powered Crypto Trading Bot

๐Ÿค– Mantle AI Trader

AI-Powered Cryptocurrency Trading Bot with News Sentiment Analysis

Free Open Source Trading Bot โ€ข Bybit Integration โ€ข Real-time Signals โ€ข Backtesting Engine

License Stars Forks Issues Last Commit

Platform TypeScript AI SDK Bybit SQLite

๐Ÿ† Built for Mantle Turing Test Hackathon - $120,000 Prize Pool

Made by Rommark.Dev
--- ## ๐Ÿ“‹ Table of Contents - [Features](#-features) - [Demo](#-demo) - [Quick Start](#-quick-start) - [Installation](#-installation) - [Usage](#-usage) - [API Reference](#-api-reference) - [Configuration](#-configuration) - [Architecture](#-architecture) - [Testing](#-testing) - [Contributing](#-contributing) - [License](#-license) --- ## ๐Ÿš€ Features ### ๐Ÿค– AI-Powered Trading Signals | Feature | Description | |---------|-------------| | **Signal Generation** | AI-generated buy/sell signals with confidence scores | | **Technical Analysis** | RSI, MACD, SMA, EMA, Bollinger Bands | | **Pattern Recognition** | Doji, Hammer, Engulfing, Morning Star | | **Support/Resistance** | Automated level detection | ### ๐Ÿ“ฐ Fundamental News Analysis - **Multi-Source Aggregation**: CryptoPanic, CoinGecko, CryptoCompare - **Sentiment Scoring**: Bullish/Bearish classification (-1 to 1) - **Real-time Updates**: Live news feed integration - **Impact Assessment**: News importance scoring ### ๐Ÿ“Š Backtesting Engine - **Historical Simulation**: Test strategies on past data - **Performance Metrics**: Sharpe Ratio, Win Rate, Max Drawdown - **Strategy Optimization**: Parameter grid search - **Detailed Reports**: Trade-by-trade analysis ### ๐Ÿ’ฐ Paper Trading (Demo Mode) - **Risk-Free Testing**: Practice without real money - **Real Market Prices**: Live price simulation - **Portfolio Tracking**: P&L monitoring - **Position Management**: Stop-loss/Take-profit ### ๐Ÿ”— Exchange Integration - **Bybit API**: Full spot and futures support - **Testnet Mode**: Safe testing environment - **Order Types**: Market, Limit, Stop orders - **Position Management**: Leverage, margin, risk controls --- ## ๐ŸŽฌ Demo
๐Ÿ“ท View Screenshots ### Dashboard Overview ![Dashboard](./public/dashboard-screenshot.png) ### Signal Generation ![Signals](./public/signals-screenshot.png) ### Paper Trading ![Demo Trading](./public/demo-trading-screenshot.png)
--- ## โšก Quick Start ```bash # Clone the repository git clone https://github.com/roman-ryzenadvanced/mantle-ai-trader.git cd mantle-ai-trader # Install dependencies bun install # Setup database bun run db:push # Start the application bun run dev ``` Open [http://localhost:3000](http://localhost:3000) to access the dashboard. --- ## ๐Ÿ›  Installation ### Prerequisites | Requirement | Version | Notes | |------------|---------|-------| | Node.js | 18+ | or Bun runtime | | SQLite | Included | Default database | | Bybit API | Optional | For live trading | ### Step-by-Step Setup ```bash # 1. Clone repository git clone https://github.com/roman-ryzenadvanced/mantle-ai-trader.git # 2. Navigate to project cd mantle-ai-trader # 3. Install dependencies bun install # 4. Configure environment cp .env.example .env # Edit .env with your API keys (optional) # 5. Initialize database bun run db:push # 6. Start development server bun run dev # 7. (Optional) Start WebSocket service bun run trading-service ``` ### Docker Installation (Coming Soon) ```bash docker-compose up -d ``` --- ## ๐Ÿ“ˆ Usage ### Web Dashboard | Tab | Function | |-----|----------| | **Signals** | Generate and view AI trading signals | | **Positions** | Manage open positions and portfolio | | **Backtest** | Run strategy simulations | | **News** | View market news with sentiment | ### Supported Trading Pairs - BTCUSDT, ETHUSDT, SOLUSDT, BNBUSDT, XRPUSDT - And 100+ more via Bybit API ### Signal Example ```json { "symbol": "BTCUSDT", "action": "BUY", "confidence": 0.85, "reasoning": "Bullish trend with strong support at $44,000. RSI oversold recovery.", "stopLoss": 43500, "takeProfit": 46500, "technicalScore": 0.78, "sentimentScore": 0.65 } ``` --- ## ๐Ÿ”Œ API Reference ### Base URL ``` http://localhost:3000/api/trading ``` ### Endpoints #### Generate Signal ```http POST /signals Content-Type: application/json { "symbol": "BTCUSDT", "timeframe": "1h" } ``` #### Get Portfolio ```http GET /demo?action=portfolio ``` #### Place Demo Order ```http POST /demo Content-Type: application/json { "action": "place_order", "symbol": "BTCUSDT", "side": "BUY", "quantity": 0.01, "type": "MARKET" } ``` #### Run Backtest ```http POST /backtest Content-Type: application/json { "symbol": "BTCUSDT", "startDate": "2024-01-01", "endDate": "2024-06-01", "initialCapital": 10000 } ``` #### Get News ```http GET /news?symbol=BTC&limit=20 ``` --- ## ๐Ÿ”ง Configuration ### Environment Variables ```env # Bybit Exchange (Optional) BYBIT_API_KEY=your_api_key BYBIT_API_SECRET=your_api_secret BYBIT_TESTNET=true # News APIs (Optional) CRYPTOPANIC_API_KEY=your_key CRYPTOCOMPARE_API_KEY=your_key # Vector Database (Optional) CHROMADB_URL=http://localhost:8000 # Database DATABASE_URL="file:./prisma/data/mantle-trader.db" ``` ### Risk Management Settings | Setting | Default | Description | |---------|---------|-------------| | Risk Level | MODERATE | CONSERVATIVE, MODERATE, AGGRESSIVE | | Max Position | $1,000 | Maximum position size | | Max Leverage | 5x | Maximum leverage multiplier | | Auto Trading | Disabled | Automatic signal execution | --- ## ๐Ÿ“Š Architecture ``` mantle-ai-trader/ โ”œโ”€โ”€ ๐Ÿ“ src/ โ”‚ โ”œโ”€โ”€ ๐Ÿ“ app/ โ”‚ โ”‚ โ”œโ”€โ”€ ๐Ÿ“ api/trading/ # REST API endpoints โ”‚ โ”‚ โ”œโ”€โ”€ ๐Ÿ“„ layout.tsx # Root layout with SEO โ”‚ โ”‚ โ””โ”€โ”€ ๐Ÿ“„ page.tsx # Main dashboard โ”‚ โ”œโ”€โ”€ ๐Ÿ“ lib/ โ”‚ โ”‚ โ”œโ”€โ”€ ๐Ÿ“ trading/ โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ ๐Ÿ“ core/ # Types & Bybit client โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ ๐Ÿ“ signals/ # AI signal engine โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ ๐Ÿ“ news/ # News aggregator โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ ๐Ÿ“ backtest/ # Backtesting โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ ๐Ÿ“ demo/ # Paper trading โ”‚ โ”‚ โ””โ”€โ”€ ๐Ÿ“ vector/ # VectorDB โ”‚ โ””โ”€โ”€ ๐Ÿ“ components/ui/ # UI components โ”œโ”€โ”€ ๐Ÿ“ mini-services/ โ”‚ โ””โ”€โ”€ ๐Ÿ“ trading-service/ # WebSocket service โ”œโ”€โ”€ ๐Ÿ“ prisma/ โ”‚ โ””โ”€โ”€ ๐Ÿ“„ schema.prisma # Database schema โ”œโ”€โ”€ ๐Ÿ“ public/ # Static assets โ””โ”€โ”€ ๐Ÿ“ tests/ # Test files ``` ### Tech Stack | Category | Technology | |----------|------------| | **Framework** | Next.js 16, TypeScript 5 | | **Styling** | Tailwind CSS 4, shadcn/ui | | **Database** | Prisma ORM, SQLite | | **AI/ML** | z-ai-web-dev-sdk | | **Exchange** | Bybit API v5 | | **Real-time** | Socket.io | | **Charts** | Recharts | | **State** | Zustand, TanStack Query | --- ## ๐Ÿงช Testing ```bash # Run all tests bun test # Run unit tests bun test tests/unit/ # Run integration tests bun test tests/integration/ # Run with coverage bun test --coverage ``` ### Test Coverage | Module | Coverage | |--------|----------| | Signal Engine | 85% | | Demo Trader | 90% | | News Aggregator | 75% | --- ## ๐Ÿค Contributing Contributions are welcome! Please follow these steps: 1. ๐Ÿด Fork the repository 2. ๐ŸŒฟ Create a feature branch (`git checkout -b feature/amazing-feature`) 3. ๐Ÿ’พ Commit your changes (`git commit -m 'Add amazing feature'`) 4. ๐Ÿ“ค Push to the branch (`git push origin feature/amazing-feature`) 5. ๐Ÿ”ƒ Open a Pull Request ### Code of Conduct - Be respectful and inclusive - Write clean, documented code - Add tests for new features - Update documentation --- ## ๐Ÿ“œ License This project is licensed under the **MIT License** - see the [LICENSE](LICENSE) file for details. ``` MIT License - Free to use, modify, and distribute ``` --- ## ๐Ÿ† Mantle Turing Test Hackathon This project is built for the **Mantle Turing Test Hackathon**: | Info | Details | |------|---------| | **Prize Pool** | $120,000 cash + $103,000 API credits | | **Tracks** | AI Trading, AI Alpha & Data | | **Registration** | [mantle.to/Hackathon](https://mantle.to/Hackathon) | | **Chat** | [Telegram](https://t.me/MantleTuringTestHackathon) | ### Competition Tracks - โœ… **AI Trading** - Trading bots, strategy automation, Bybit API - โœ… **AI Alpha & Data** - Onchain analytics, anomaly detection --- ## ๐ŸŒŸ Star History Star History Chart --- ## ๐Ÿ“ž Support & Community | Platform | Link | |----------|------| | **GitHub Issues** | [Report a Bug](https://github.com/roman-ryzenadvanced/mantle-ai-trader/issues) | | **Discussions** | [GitHub Discussions](https://github.com/roman-ryzenadvanced/mantle-ai-trader/discussions) | | **Telegram** | [Mantle Hackathon Chat](https://t.me/MantleTuringTestHackathon) | | **Twitter** | [@rommarkdev](https://twitter.com/rommarkdev) | ---
Made by Rommark.Dev

โญ Star us on GitHub โ€ข ๐Ÿ› Report Bug โ€ข ๐Ÿ’ก Request Feature

Keywords: AI trading bot, cryptocurrency trading, crypto signals, Bybit API, trading automation, sentiment analysis, backtesting, paper trading, Mantle hackathon, open source trading bot, TypeScript, Next.js, algorithmic trading, DeFi, Web3