feat: Complete Phase 2 - Autonomous Trading System
- Add Pyth Network price monitoring (WebSocket + polling fallback) - Add Position Manager with automatic exit logic (TP1/TP2/SL) - Implement dynamic stop-loss adjustment (breakeven + profit lock) - Add real-time P&L tracking and multi-position support - Create comprehensive test suite (3 test scripts) - Add 5 detailed documentation files (2500+ lines) - Update configuration to $50 position size for safe testing - All Phase 2 features complete and tested Core Components: - v4/lib/pyth/price-monitor.ts - Real-time price monitoring - v4/lib/trading/position-manager.ts - Autonomous position management - v4/app/api/trading/positions/route.ts - Query positions endpoint - v4/test-*.ts - Comprehensive testing suite Documentation: - PHASE_2_COMPLETE_REPORT.md - Implementation summary - v4/PHASE_2_SUMMARY.md - Detailed feature overview - v4/TESTING.md - Testing guide - v4/QUICKREF_PHASE2.md - Quick reference - install-phase2.sh - Automated installation script
This commit is contained in:
133
install-phase2.sh
Executable file
133
install-phase2.sh
Executable file
@@ -0,0 +1,133 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Phase 2 Installation Script
|
||||
# Installs dependencies and validates setup
|
||||
|
||||
echo "🚀 Trading Bot v4 - Phase 2 Installation"
|
||||
echo "=========================================="
|
||||
echo ""
|
||||
|
||||
# Check if in correct directory
|
||||
if [ ! -d "v4" ]; then
|
||||
echo "❌ Error: Must run from project root directory"
|
||||
echo " Expected to see v4/ folder"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "📦 Step 1: Installing dependencies..."
|
||||
echo ""
|
||||
|
||||
# Install main dependencies
|
||||
npm install @pythnetwork/price-service-client
|
||||
|
||||
echo ""
|
||||
echo "✅ Dependencies installed"
|
||||
echo ""
|
||||
|
||||
echo "📝 Step 2: Checking environment configuration..."
|
||||
echo ""
|
||||
|
||||
# Check for .env.local
|
||||
if [ ! -f ".env.local" ]; then
|
||||
echo "⚠️ Warning: .env.local not found"
|
||||
echo " Creating from example..."
|
||||
|
||||
if [ -f "v4/.env.example" ]; then
|
||||
cp v4/.env.example .env.local
|
||||
echo "✅ Created .env.local from v4/.env.example"
|
||||
echo " Please edit .env.local with your credentials"
|
||||
else
|
||||
echo "❌ Error: v4/.env.example not found"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "✅ .env.local exists"
|
||||
fi
|
||||
|
||||
# Check required variables
|
||||
echo ""
|
||||
echo "Checking required environment variables..."
|
||||
|
||||
required_vars=("DRIFT_WALLET_PRIVATE_KEY" "SOLANA_RPC_URL" "API_KEY")
|
||||
missing_vars=()
|
||||
|
||||
for var in "${required_vars[@]}"; do
|
||||
if ! grep -q "^${var}=" .env.local || grep -q "^${var}=$" .env.local || grep -q "^${var}=your_" .env.local; then
|
||||
missing_vars+=("$var")
|
||||
echo "❌ $var not configured"
|
||||
else
|
||||
echo "✅ $var configured"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ${#missing_vars[@]} -gt 0 ]; then
|
||||
echo ""
|
||||
echo "⚠️ Missing configuration for:"
|
||||
for var in "${missing_vars[@]}"; do
|
||||
echo " - $var"
|
||||
done
|
||||
echo ""
|
||||
echo "Please edit .env.local and set these variables"
|
||||
echo ""
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "📝 Step 3: Validating TypeScript setup..."
|
||||
echo ""
|
||||
|
||||
# Check tsconfig.json
|
||||
if [ ! -f "tsconfig.json" ]; then
|
||||
echo "❌ Error: tsconfig.json not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "✅ TypeScript configuration found"
|
||||
echo ""
|
||||
|
||||
echo "📝 Step 4: Checking test scripts..."
|
||||
echo ""
|
||||
|
||||
# Check test files exist
|
||||
test_files=("v4/test-price-monitor.ts" "v4/test-position-manager.ts" "v4/test-full-flow.ts")
|
||||
for file in "${test_files[@]}"; do
|
||||
if [ -f "$file" ]; then
|
||||
echo "✅ $file exists"
|
||||
else
|
||||
echo "❌ $file missing"
|
||||
fi
|
||||
done
|
||||
|
||||
echo ""
|
||||
echo "=========================================="
|
||||
echo "🎉 Phase 2 Installation Complete!"
|
||||
echo "=========================================="
|
||||
echo ""
|
||||
|
||||
if [ ${#missing_vars[@]} -eq 0 ]; then
|
||||
echo "✅ Ready to test! Run:"
|
||||
echo ""
|
||||
echo " cd v4"
|
||||
echo " npx tsx test-price-monitor.ts"
|
||||
echo ""
|
||||
echo "See TESTING.md for full testing guide"
|
||||
else
|
||||
echo "⚠️ Almost ready! Next steps:"
|
||||
echo ""
|
||||
echo "1. Edit .env.local and set:"
|
||||
for var in "${missing_vars[@]}"; do
|
||||
echo " - $var"
|
||||
done
|
||||
echo ""
|
||||
echo "2. Then run tests:"
|
||||
echo " cd v4"
|
||||
echo " npx tsx test-price-monitor.ts"
|
||||
echo ""
|
||||
echo "See SETUP.md for configuration help"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "📚 Documentation:"
|
||||
echo " - v4/PHASE_2_COMPLETE.md - Feature overview"
|
||||
echo " - v4/TESTING.md - Testing guide"
|
||||
echo " - v4/SETUP.md - Setup instructions"
|
||||
echo ""
|
||||
Reference in New Issue
Block a user