Skip to content

xodn348/AI_automated_trading

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AI Automated Trading Bot

Linux-only automated trading system for Solana blockchain with arbitrage detection, liquidation monitoring, and risk management.

⚠️ Important: This bot is designed and tested for Linux environments only. It may not work properly on macOS or Windows.

What is MEV?

MEV (Maximal Extractable Value) is a trading strategy that exploits price differences across multiple DEXes on Solana testnet. The bot executes multi-hop trades like:

SOL → Coin1 → Coin2 → Coin3 → SOL

This creates arbitrage opportunities by taking advantage of price inefficiencies between different decentralized exchanges.

Features

  • MEV Trading: Multi-hop arbitrage (SOL → Coin1 → Coin2 → Coin3 → SOL)
  • AI Trading: OpenAI integration for market analysis
  • Arbitrage Bot: Multi-DEX support with path discovery
  • Liquidation Bot: Solend protocol integration
  • Risk Management: Built-in risk assessment and limits
  • Testnet Only: Safe testing environment on Solana testnet
  • Real-time Monitoring: Continuous price monitoring and opportunity detection

Project Structure

bot/
├── src/
│   ├── arbitrage-bot/          # Arbitrage detection
│   ├── liquidation-bot/        # Liquidation monitoring
│   └── utils/                  # Utility functions
├── models/                     # AI models
├── config.toml                 # Configuration
└── package.json                # Dependencies

Installation

Prerequisites

  • Operating System: Linux (Ubuntu 18.04+, CentOS 7+, or similar)
  • Node.js (v16+)
  • Solana CLI tools
  • Anchor Framework

Setup

  1. Clone and install:
git clone https://github.com/xodn348/AI_automated_trading.git
cd AI_automated_trading
npm install
  1. Configure environment:
# Create .env file in src/arbitrage-bot/
OPENAI_API_KEY=your_openai_api_key
SOLANA_PRIVATE_KEY=your_solana_private_key
SOLANA_RPC_URL=https://api.devnet.solana.com
  1. Important: Fix wallet path issue
# Copy wallet.json to src/ directory (required for bot to start)
cp wallet.json src/wallet.json

# Or modify config.toml to use correct path
# Comment out: private_key_path = "/home/jnnj92/bot/wallet.json"

Linux Deployment

Quick Setup

# Make deployment script executable
chmod +x deploy-linux.sh

# Run deployment script
./deploy-linux.sh

Docker Deployment

# Build and run with Docker
docker-compose up -d

# Or build manually
docker build -t ai-trading-bot .
docker run -d --name ai-trading-bot ai-trading-bot

Systemd Service

# Start as system service
sudo systemctl start ai-trading-bot

# Enable auto-start
sudo systemctl enable ai-trading-bot

# Check status
sudo systemctl status ai-trading-bot

# View logs
sudo journalctl -u ai-trading-bot -f

Usage

Start Arbitrage Bot

# Main bot (requires wallet.json in src/ directory)
npm start

# AI-enhanced version
node src/arbitrage-bot/index2_ai.js

# Test bot startup (recommended first)
node -e "try { require('./src/arbitrage-bot/index.js'); console.log('Bot loaded successfully!'); } catch(e) { console.error('Error:', e.message); }"

Important Notes

  • Wallet Setup: Ensure wallet.json exists in src/ directory
  • Devnet Only: Bot currently works only on Solana devnet for safety
  • Test Mode: Bot runs in monitoring mode without executing real trades
  • API Keys: OpenAI API key required for AI features to work

Start Liquidation Bot

# Liquidation monitoring
node src/liquidation-bot/liquidation-bot.js

# Create test positions
node src/liquidation-bot/create-test-position.js

Testing

cd test-liquidation
npm test

Configuration

Edit config.toml for:

  • Network settings (RPC endpoints)
  • Trading parameters (slippage, position sizes)
  • AI settings (OpenAI configuration)
  • Risk management (stop-loss, take-profit)

Current Settings

  • Network: Solana testnet only (https://api.testnet.solana.com)
  • Trading: Test mode (no real transactions executed)
  • MEV Strategy: Multi-hop arbitrage across multiple DEXes
  • Monitoring: 30-second intervals for arbitrage opportunities
  • Safety: 1% minimum profit threshold before execution

Security

  • API keys stored in .env (not committed to Git)
  • Configurable trading limits
  • Oracle price validation
  • Slippage protection

Data Collection

Automatically collects:

  • Historical price data
  • Trading performance metrics
  • Market volatility data
  • Arbitrage opportunity logs

License

MIT License - see LICENSE file for details.

Disclaimer

For educational and research purposes only. Cryptocurrency trading involves significant risk. Use at your own risk.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published