AI-powered cryptocurrency trading platform with autonomous trading capabilities, integrating Gemini 2.5 Pro for decision-making and Binance API for execution.
- AI-Powered Trading: Integration with Gemini 2.5 Pro for trading decisions
- Risk Management: 5% position sizing, dynamic stop-loss/take-profit, daily loss limits
- Real-time Monitoring: Live price tracking and position management
- Multi-Exchange Support: Binance (primary), Bitkub (future expansion)
- Comprehensive Logging: Trade history, AI decisions, and performance tracking
- Mobile Alerts: Trade notifications and system monitoring
- Database Storage: SQLite for persistent trade and decision history
- Node.js 18+
- npm or yarn
- Binance API credentials
- Gemini API key
# Clone the repository
git clone <repository-url>
cd AI-Trading
# Install dependencies
npm install
# Copy environment configuration
cp .env.example .env
# Edit .env with your API keys and configuration
nano .envRequired environment variables:
# Exchange API Configuration
BINANCE_API_KEY=your_binance_api_key_here
BINANCE_API_SECRET=your_binance_api_secret_here
# AI Configuration
GEMINI_API_KEY=your_gemini_api_key_here
# Risk Management
RISK_PER_TRADE_PERCENTAGE=5
MAX_DAILY_LOSS_PERCENTAGE=10
MAX_CONCURRENT_POSITIONS=3
# Trading Configuration
TRADING_ENABLED=false # Start with false for testing
MIN_TRADE_AMOUNT_USD=10# Build the TypeScript project
npm run build
# Run MVP tests
npm run test
# Test the system
npm run dev# Start in development mode with file watching
npm run dev
# Run the test suite
npm run test# Build the project
npm run build
# Start the bot
npm start# Run the MVP validation test
npx ts-node src/scripts/test-mvp.ts- Trading Bot (
src/index.ts): Main application orchestrator - Binance Service (
src/services/binance.service.ts): Exchange API integration - Risk Service (
src/services/risk.service.ts): Risk management and position sizing - Database (
src/models/database.ts): SQLite data persistence - Logger (
src/utils/logger.ts): Comprehensive logging system
- Position Sizing: 5% risk per trade with dynamic calculation
- Stop Loss: Volatility-based dynamic stops
- Take Profit: 2:1 risk/reward ratio
- Daily Limits: Maximum daily loss percentage enforcement
- Emergency Controls: Manual kill switch and circuit breakers
- Decision Making: Gemini 2.5 Pro for trading signals
- Signal Processing: Entry/exit point determination
- Confidence Scoring: AI decision confidence tracking
- Learning Loop: Decision logging for performance analysis
- Real-time Data: WebSocket price feeds
- Historical Storage: Market data persistence
- Trade History: Complete trade logging with P&L tracking
- Performance Metrics: Win rate, profit factor, drawdown analysis
- Paper Trading Mode: Test strategies without real money
- Position Limits: Maximum concurrent positions enforcement
- Daily Loss Limits: Automatic trading halt on excessive losses
- Emergency Stop: Manual override for immediate trading cessation
- Error Handling: Comprehensive error recovery and logging
- API Rate Limiting: Respect exchange API limits
RISK_PER_TRADE_PERCENTAGE: Percentage of portfolio risked per trade (default: 5%)MAX_DAILY_LOSS_PERCENTAGE: Maximum daily loss before trading stops (default: 10%)MAX_CONCURRENT_POSITIONS: Maximum number of open positions (default: 3)DEFAULT_STOP_LOSS_PERCENTAGE: Default stop loss percentage (default: 2%)DEFAULT_TAKE_PROFIT_PERCENTAGE: Default take profit percentage (default: 4%)
TRADING_ENABLED: Enable/disable live trading (start withfalse)MIN_TRADE_AMOUNT_USD: Minimum trade size in USD (default: $10)MAX_TRADES_PER_HOUR: Maximum trades per hour (default: 10)POSITION_CHECK_INTERVAL_SECONDS: Position monitoring frequency (default: 30s)
- Trade Logs: All trades with execution details
- AI Decision Logs: AI reasoning and confidence scores
- Risk Management Logs: Risk violations and safety triggers
- Performance Logs: P&L tracking and system health
- Trade Notifications: Entry/exit confirmations
- Stop Loss Alerts: When stop levels are triggered
- Daily P&L: End-of-day performance summaries
- System Alerts: Errors and emergency stop activation
src/
├── config/ # Configuration management
├── models/ # Database models and operations
├── services/ # Core business logic
│ ├── binance.service.ts
│ └── risk.service.ts
├── types/ # TypeScript type definitions
├── utils/ # Utility functions
│ └── logger.ts
├── scripts/ # Utility scripts
│ └── test-mvp.ts
└── index.ts # Main application entry point
- Implement service logic in
src/services/ - Add database operations in
src/models/ - Define types in
src/types/ - Add logging with
src/utils/logger.ts - Update configuration in
src/config/
- Start with paper trading or very small amounts
- Thoroughly test all configurations before live trading
- Monitor the system closely during operation
- Keep API keys secure and never commit them to version control
- Understand all risk management features before enabling live trading
MIT License - see LICENSE file for details.
- Fork the repository
- Create a feature branch
- Implement your changes with tests
- Submit a pull request
Built with ❤️ for automated cryptocurrency trading