LynchzDEV
ai-auto-trader-ahh
Go

An advanced crypto futures trading platform featuring multi-agent AI debate consensus, real-time backtesting, and automated execution on Binance.

Last updated Jun 3, 2026
14
Stars
3
Forks
5
Issues
0
Stars/day
Attention Score
50
Language breakdown
No language data available.
โ–ธ Files click to expand
README

Passive Income Ahh

GitHub stars GitHub forks GitHub issues GitHub contributors GitHub license

An advanced AI-powered cryptocurrency futures trading platform that leverages multi-agent debate consensus, comprehensive backtesting, and real-time portfolio management to automate trading strategies on Binance Futures.

Key Features

Core Trading

  • Multi-AI Debate System: Multiple AI personas (Bull, Bear, Analyst, Contrarian, Risk Manager) debate and reach consensus on trading decisions
  • Advanced Decision Engine: Integrates OpenRouter to access top-tier LLMs (DeepSeek, Claude, GPT-4) with Chain-of-Thought reasoning
  • Comprehensive Backtesting: Test strategies against historical Binance data with detailed metrics (Sharpe ratio, max drawdown, win rate, profit factor)
  • Real-time Trading: Automated, low-latency execution on Binance Futures with Testnet and Mainnet support
  • Bracket Orders: Atomic execution of Entry + Stop Loss + Take Profit orders
  • WebSocket Real-time Updates: Sub-second position monitoring via Binance User Data Stream (1.13ms average latency vs 30-60s REST polling)

Risk Management (15+ Layers)

Entry Safety (7 Layers)

  • EMA Spread Gate: Requires โ‰ฅ0.6% EMA spread for entries - blocks weak/choppy trends
  • Momentum Exhaustion Detection: Blocks extended price + opposite MACD histogram entries
  • Wick Rejection Pattern: Blocks when 3+ of 5 candles show rejection wicks
  • Volume Decline Detection: Blocks when volume < 60% of 5-candle average
  • Resistance/Support Buffer: Blocks entries within 0.5% of 40-candle high/low
  • RSI Extreme Blocking: Blocks LONG if RSI >75, SHORT if RSI <25
  • Counter-Trend Prevention: LONG requires Price > EMA9, SHORT requires Price < EMA9

Multi-Timeframe Confirmation (4 Checks)

  • Trend Direction: Higher TF EMA9 vs EMA21 must align
  • Price Action: Price must respect higher TF EMA21
  • MACD Momentum: Higher TF histogram sign must support trade
  • Trend Strength: Higher TF EMA spread must be โ‰ฅ0.4%

Open Interest Analysis (v3.52.0+)

  • OI + Price Interpretation: Real money flow analysis revealing if trends are backed by new capital
  • Top Trader Long/Short Ratio: Crowding detection warns when >70% of traders are on one side
  • Falling Knife Protection: Blocks LONG entries during detected Long Liquidation cascades
  • Rocket Short Protection: Blocks SHORT entries during detected Short Squeezes

Position Management

  • Hard Validation: Enforced 3:1 minimum risk/reward ratio
  • Noise Zone Protection: Block closing positions between -1.5% and +1.5% PnL to prevent panic selling
  • Trailing Stop Loss: Automatically lock profits at +1% with 0.5% trailing distance
  • Smart Loss Cut: Force close losers after extended hold time (30+ minutes with >1% loss)
  • Max Hold Duration: Automatically close positions held longer than 4 hours
  • Drawdown Protection: Close positions if drawdown from peak exceeds 40%
  • Emergency Shutdown: Halt trading if balance drops below configured threshold ($60 default)
  • Guaranteed Profit Lock: Automatically protect gains once threshold is reached (v3.48.0+)
  • Daily Loss Limits: Stop trading after reaching daily loss threshold (15% default)

Dynamic Features

  • Smart Find: AI-recommended volatile trading pairs with auto-refresh and OI-based discovery
  • Turbo Mode: High-frequency scalping with dynamic coin discovery
  • Copy Trading Mode: Monitor positions without executing trades
  • Live Strategy Reload: Apply configuration changes without restarting
  • Signal Confirmation: Wait for price stability and AI re-confirmation before executing medium-confidence trades
  • Bilingual Support: English and Chinese AI prompts

Modern Dashboard

  • Glassmorphism UI: Sleek React + TailwindCSS interface
  • Real-time Logs: Live streaming of server logs via SSE
  • Equity Curve: Visual portfolio growth tracking
  • Strategy Ranking: Compare strategy performance with interactive charts

How It Works

The system operates on an automated loop (default: 5 minutes) combining technical analysis with AI reasoning:

  • Market Analysis: Calculate hard mathematical indicators (EMA9/21 trends, RSI levels, MACD, ATR volatility, Bollinger Bands)
  • Trend Validation: Check trend strength gate - only proceed if EMA spread > 0.2%
  • AI Decision: Send structured prompt with account state, market data, and positions to LLM. The AI outputs a JSON decision with confidence, stop-loss, and take-profit levels
  • Risk Validation: Enforce minimum 3:1 reward-to-risk ratio, leverage limits, and position sizing caps
  • Noise Zone Check: Block closures in the -1.5% to +1.5% PnL zone unless confidence > 95%
  • Execution: Execute validated trades as bracket orders (Entry + SL + TP simultaneously)
  • Position Management: Track peak PnL, apply trailing stops, enforce max hold duration
For a deep dive into the math and logic, check out TRADING_ALGO.md.

Project Structure

auto-trader-ahh/
โ”œโ”€โ”€ client/                 # Frontend Application (React + Vite)
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ components/     # Reusable UI components (Charts, Layouts, etc.)
โ”‚   โ”‚   โ”œโ”€โ”€ contexts/       # React contexts (Auth, etc.)
โ”‚   โ”‚   โ”œโ”€โ”€ lib/            # API clients and utilities
โ”‚   โ”‚   โ”œโ”€โ”€ pages/          # Application views
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ Dashboard   # Real-time trader status & positions
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ Strategies  # Strategy configuration & management
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ Backtest    # Historical backtesting
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ Debate      # Multi-AI consensus arena
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ History     # Trade history & PnL
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ Equity      # Portfolio growth visualization
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ Ranking     # Strategy performance comparison
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ Config      # Global settings
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ Logs        # Real-time server logs
โ”‚   โ”‚   โ”œโ”€โ”€ types/          # TypeScript interfaces
โ”‚   โ”‚   โ””โ”€โ”€ App.tsx         # Main entry point with routing
โ”‚   โ”œโ”€โ”€ Dockerfile          # Frontend container definition
โ”‚   โ””โ”€โ”€ package.json        # Frontend dependencies
โ”‚
โ”œโ”€โ”€ server/                 # Backend Application (Go)
โ”‚   โ”œโ”€โ”€ api/                # HTTP API endpoints (net/http)
โ”‚   โ”œโ”€โ”€ backtest/           # Backtesting engine and simulation
โ”‚   โ”œโ”€โ”€ config/             # Configuration loading and validation
โ”‚   โ”œโ”€โ”€ data/               # SQLite database storage (trading.db)
โ”‚   โ”œโ”€โ”€ debate/             # Multi-agent debate and consensus
โ”‚   โ”œโ”€โ”€ decision/           # AI decision engine (NOFX-style XML parsing)
โ”‚   โ”‚   โ”œโ”€โ”€ prompt_builder  # System/user prompt construction
โ”‚   โ”‚   โ”œโ”€โ”€ parser          # XML to JSON parsing
โ”‚   โ”‚   โ””โ”€โ”€ validator       # Risk/reward validation
โ”‚   โ”œโ”€โ”€ events/             # Event hub for real-time communication
โ”‚   โ”œโ”€โ”€ exchange/           # Binance Futures API integration
โ”‚   โ”œโ”€โ”€ logger/             # Log broadcasting system (SSE)
โ”‚   โ”œโ”€โ”€ market/             # Technical indicators (EMA, RSI, MACD, ATR, etc.)
โ”‚   โ”œโ”€โ”€ mcp/                # Multi-provider AI client (OpenRouter)
โ”‚   โ”œโ”€โ”€ store/              # Database models (Strategies, Traders, Trades, etc.)
โ”‚   โ”œโ”€โ”€ trader/             # Core trading engine and execution loop
โ”‚   โ”œโ”€โ”€ main.go             # Application entry point
โ”‚   โ”œโ”€โ”€ Dockerfile          # Backend container definition
โ”‚   โ””โ”€โ”€ go.mod              # Go module definitions
โ”‚
โ”œโ”€โ”€ docker-compose.yml      # Container orchestration
โ”œโ”€โ”€ TRADING_ALGO.md         # Algorithm documentation
โ”œโ”€โ”€ RECOMMENDED_SETTINGS.md # Configuration guide
โ”œโ”€โ”€ CHANGELOG.md            # Version history
โ””โ”€โ”€ README.md               # Project documentation

Tech Stack

Backend

  • Language: Go 1.23
  • Database: SQLite
  • AI Integration: OpenRouter API (DeepSeek, Anthropic Claude, OpenAI GPT-4, Llama, etc.)
  • Exchange: Binance Futures API
  • Libraries: generic-go-binance, go-sqlite3
Frontend
  • Framework: React 18, Vite
  • Language: TypeScript
  • Styling: TailwindCSS, Framer Motion
  • Components: Shadcn/UI, Lucide Icons
  • Visualization: Recharts, D3

Getting Started

Prerequisites

  • Go 1.23+
  • Node.js 20+
  • Docker & Docker Compose (recommended)
  • Binance Futures Account (Testnet recommended for development)
  • OpenRouter API Key

Docker Quick Start (Recommended)

  • Clone the repository:
git clone https://github.com/LynchzDEV/ai-auto-trader-ahh.git
    cd ai-auto-trader-ahh
  • Configure Environment:
Create a .env file in the server/ directory:
cd server
    cp .env.example .env
Edit .env and add your keys:
API_PORT=8080
    ACCESSPASSKEY=youroptional_passkey
  • Run with Docker Compose:
cd ..
    docker compose up -d --build
  • Access the App:
* Dashboard: http://localhost:5173 * API: http://localhost:8080

Manual Installation

Backend

cd server
go mod download
go run main.go

Frontend

cd client
npm install
npm run dev

Configuration

The system is highly configurable via the Dashboard "Settings" page or server/.env.

Environment Variables

| Variable | Description | Default | |----------|-------------|---------| | OPENROUTERAPIKEY | OpenRouter API key for AI | Required | | OPENROUTER_MODEL | AI model to use | deepseek/deepseek-v3.2 | | BINANCEAPIKEY | Binance Futures API key | Required | | BINANCESECRETKEY | Binance Futures secret | Required | | BINANCE_TESTNET | Use testnet (true/false) | true | | API_PORT | Port for the Go server | 8080 | | ACCESS_PASSKEY | Optional app password | None |

Strategy Configuration

| Setting | Description | Default | |---------|-------------|---------| | Max Positions | Maximum concurrent positions | 2 | | BTC/ETH Leverage | Max leverage for BTC/ETH | 10x | | Altcoin Leverage | Max leverage for altcoins | 20x | | Min Confidence | Minimum AI confidence to trade | 85% | | Min R/R Ratio | Minimum reward-to-risk ratio | 3.0 | | Trading Interval | Minutes between trading cycles | 5 | | Daily Loss Limit | Stop trading after this loss % | 15% | | Noise Zone | PnL range to block closures | -1.5% to +1.5% |

See RECOMMENDED_SETTINGS.md for detailed configuration guides.

API Endpoints

| Method | Endpoint | Description | |--------|----------|-------------| | GET | /api/health | Health check | | GET | /api/traders | List traders | | POST | /api/traders | Create trader | | POST | /api/traders/{id}/start | Start trader | | POST | /api/traders/{id}/stop | Stop trader | | GET | /api/strategies | List strategies | | POST | /api/strategies | Create strategy | | PUT | /api/strategies/{id} | Update strategy | | GET | /api/status | Get trader status | | GET | /api/positions | Get open positions | | GET | /api/decisions | Get recent AI decisions | | GET | /api/trades | Get trade history | | GET | /api/backtest | List backtests | | POST | /api/backtest/start | Start backtest | | GET | /api/debate/sessions | List debate sessions | | POST | /api/debate/sessions | Create debate session | | GET | /api/settings | Get global settings | | PUT | /api/settings | Update global settings | | GET | /api/logs/stream | SSE log stream | | GET | /api/events | SSE event stream |

Disclaimer

This trading software is for educational and experimental purposes only. Cryptocurrency futures trading involves significant financial risk including the possibility of losing more than your initial investment. The authors and contributors are not responsible for any financial losses incurred while using this software. Use at your own risk.

License

Distributed under the MIT License. See LICENSE for more information.

๐Ÿ”— More in this category

ยฉ 2026 GitRepoTrend ยท LynchzDEV/ai-auto-trader-ahh ยท Updated daily from GitHub