chore: Organize workspace structure - move docs, workflows, scripts to subdirectories
Organization: - Created docs/ with setup/, guides/, history/ subdirectories - Created workflows/ with trading/, analytics/, telegram/, archive/ subdirectories - Created scripts/ with docker/, setup/, testing/ subdirectories - Created tests/ for TypeScript test files - Created archive/ for unused reference files Moved files: - 17 documentation files → docs/ - 16 workflow JSON files → workflows/ - 10 shell scripts → scripts/ - 4 test files → tests/ - 5 unused files → archive/ Updated: - README.md with new file structure and documentation paths Deleted: - data/ (empty directory) - screenshots/ (empty directory) Critical files remain in root: - telegram_command_bot.py (active bot - used by Dockerfile) - watch-restart.sh (systemd service dependency) - All Dockerfiles and docker-compose files - All environment files Validation: Containers running (trading-bot-v4, telegram-trade-bot, postgres) API responding (positions endpoint tested) Telegram bot functional (/status command tested) All critical files present in root No code changes - purely organizational. System continues running without interruption. Recovery: git revert HEAD or git reset --hard cleanup-before
This commit is contained in:
36
scripts/docker/docker-build.sh
Executable file
36
scripts/docker/docker-build.sh
Executable file
@@ -0,0 +1,36 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Trading Bot v4 - Docker Build Script
|
||||
# Builds production-ready Docker image
|
||||
|
||||
set -e
|
||||
|
||||
echo "🐳 Building Trading Bot v4 Docker Image..."
|
||||
echo ""
|
||||
|
||||
# Navigate to v4 directory
|
||||
cd "$(dirname "$0")"
|
||||
|
||||
# Check if .env exists
|
||||
if [ ! -f ".env" ]; then
|
||||
echo "⚠️ Warning: .env file not found!"
|
||||
echo " Creating from .env.example..."
|
||||
cp .env.example .env
|
||||
echo " ✅ .env created. Please edit it with your credentials."
|
||||
echo ""
|
||||
fi
|
||||
|
||||
# Build with BuildKit for better performance
|
||||
export DOCKER_BUILDKIT=1
|
||||
|
||||
echo "📦 Building image with BuildKit..."
|
||||
docker-compose build --progress=plain
|
||||
|
||||
echo ""
|
||||
echo "✅ Build complete!"
|
||||
echo ""
|
||||
echo "Next steps:"
|
||||
echo " 1. Edit .env file with your credentials"
|
||||
echo " 2. Run: docker-compose up -d"
|
||||
echo " 3. Check logs: docker-compose logs -f"
|
||||
echo ""
|
||||
14
scripts/docker/docker-logs.sh
Executable file
14
scripts/docker/docker-logs.sh
Executable file
@@ -0,0 +1,14 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Trading Bot v4 - Docker Logs Script
|
||||
# Shows real-time logs from all containers
|
||||
|
||||
set -e
|
||||
|
||||
cd "$(dirname "$0")"
|
||||
|
||||
echo "📋 Trading Bot v4 Logs"
|
||||
echo "Press Ctrl+C to exit"
|
||||
echo ""
|
||||
|
||||
docker-compose logs -f --tail=100 trading-bot
|
||||
43
scripts/docker/docker-start.sh
Executable file
43
scripts/docker/docker-start.sh
Executable file
@@ -0,0 +1,43 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Trading Bot v4 - Docker Start Script
|
||||
# Starts the trading bot in production mode
|
||||
|
||||
set -e
|
||||
|
||||
echo "🚀 Starting Trading Bot v4..."
|
||||
echo ""
|
||||
|
||||
# Navigate to v4 directory
|
||||
cd "$(dirname "$0")"
|
||||
|
||||
# Check if .env exists
|
||||
if [ ! -f ".env" ]; then
|
||||
echo "❌ Error: .env file not found!"
|
||||
echo " Run: cp .env.example .env"
|
||||
echo " Then edit .env with your credentials"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if image exists
|
||||
if ! docker images | grep -q "trading-bot"; then
|
||||
echo "📦 Image not found. Building..."
|
||||
./docker-build.sh
|
||||
fi
|
||||
|
||||
# Start services
|
||||
echo "🐳 Starting containers..."
|
||||
docker-compose up -d
|
||||
|
||||
echo ""
|
||||
echo "✅ Trading Bot started!"
|
||||
echo ""
|
||||
echo "Status:"
|
||||
docker-compose ps
|
||||
echo ""
|
||||
echo "View logs:"
|
||||
echo " docker-compose logs -f trading-bot"
|
||||
echo ""
|
||||
echo "Stop bot:"
|
||||
echo " docker-compose down"
|
||||
echo ""
|
||||
24
scripts/docker/docker-stop.sh
Executable file
24
scripts/docker/docker-stop.sh
Executable file
@@ -0,0 +1,24 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Trading Bot v4 - Docker Stop Script
|
||||
# Safely stops all containers
|
||||
|
||||
set -e
|
||||
|
||||
echo "🛑 Stopping Trading Bot v4..."
|
||||
echo ""
|
||||
|
||||
cd "$(dirname "$0")"
|
||||
|
||||
# Stop containers
|
||||
docker-compose stop
|
||||
|
||||
echo ""
|
||||
echo "✅ Containers stopped"
|
||||
echo ""
|
||||
echo "To remove containers:"
|
||||
echo " docker-compose down"
|
||||
echo ""
|
||||
echo "To remove containers and volumes:"
|
||||
echo " docker-compose down -v"
|
||||
echo ""
|
||||
24
scripts/setup/GET_BOT_TOKEN.sh
Executable file
24
scripts/setup/GET_BOT_TOKEN.sh
Executable file
@@ -0,0 +1,24 @@
|
||||
#!/bin/bash
|
||||
# One-time setup to get your Telegram Bot Token
|
||||
# Run this and follow the instructions
|
||||
|
||||
echo "🤖 Telegram Bot Setup Instructions"
|
||||
echo "===================================="
|
||||
echo ""
|
||||
echo "1. Open Telegram on your phone"
|
||||
echo "2. Search for '@BotFather'"
|
||||
echo "3. Start a chat with BotFather"
|
||||
echo "4. Send this message: /newbot"
|
||||
echo "5. BotFather will ask for a name - choose anything like 'My Trading Bot'"
|
||||
echo "6. BotFather will ask for a username - must end in 'bot', like 'mytrading_bot'"
|
||||
echo "7. BotFather will give you a TOKEN that looks like:"
|
||||
echo " 123456789:ABCdefGHIjklMNOpqrsTUVwxyz"
|
||||
echo ""
|
||||
echo "8. Copy that token and run:"
|
||||
echo " nano .env.telegram-bot"
|
||||
echo ""
|
||||
echo "9. Replace 'your_bot_token_here' with your actual token"
|
||||
echo ""
|
||||
echo "10. Save (Ctrl+O, Enter, Ctrl+X)"
|
||||
echo ""
|
||||
echo "Then run: ./setup_telegram_bot.sh"
|
||||
64
scripts/setup/complete_telegram_setup.sh
Executable file
64
scripts/setup/complete_telegram_setup.sh
Executable file
@@ -0,0 +1,64 @@
|
||||
#!/bin/bash
|
||||
# Complete Telegram Trading Bot Setup
|
||||
|
||||
echo "🤖 Telegram Trading Bot - Complete Setup"
|
||||
echo "=========================================="
|
||||
echo ""
|
||||
|
||||
# Step 1: Check if workflow is imported
|
||||
echo "📋 Step 1: n8n Workflow"
|
||||
echo "-----------------------"
|
||||
echo "1. Open n8n: http://10.0.0.48:8098"
|
||||
echo "2. Import telegram-manual-trade-FINAL.json"
|
||||
echo "3. Connect the last node '➡️ Connect to Check Risk Node' to your Money Machine's 'Check Risk' node"
|
||||
echo "4. Activate the workflow"
|
||||
echo ""
|
||||
read -p "Done? (y/n) " -n 1 -r
|
||||
echo ""
|
||||
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
||||
echo "❌ Complete step 1 first"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Step 2: Get bot token
|
||||
echo ""
|
||||
echo "🤖 Step 2: Telegram Bot Token"
|
||||
echo "------------------------------"
|
||||
echo "Run: ./GET_BOT_TOKEN.sh for instructions"
|
||||
echo ""
|
||||
echo "Or if you already have a bot token:"
|
||||
read -p "Paste your bot token here: " BOT_TOKEN
|
||||
|
||||
if [ -z "$BOT_TOKEN" ]; then
|
||||
echo "❌ Bot token required"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Update .env file
|
||||
sed -i "s|TELEGRAM_BOT_TOKEN=.*|TELEGRAM_BOT_TOKEN=$BOT_TOKEN|" .env.telegram-bot
|
||||
|
||||
echo "✅ Bot token saved to .env.telegram-bot"
|
||||
|
||||
# Step 3: Build and start
|
||||
echo ""
|
||||
echo "🚀 Step 3: Starting Telegram Bot Container"
|
||||
echo "-------------------------------------------"
|
||||
|
||||
docker-compose -f docker-compose.telegram-bot.yml --env-file .env.telegram-bot up -d --build
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
echo ""
|
||||
echo "✅ SUCCESS! Telegram bot is running!"
|
||||
echo ""
|
||||
echo "📱 Test it now:"
|
||||
echo " Open Telegram and send to your chat (579304651):"
|
||||
echo " • buy sol"
|
||||
echo " • sell btc"
|
||||
echo " • buy eth"
|
||||
echo ""
|
||||
echo "📊 View logs: docker logs -f telegram-trade-bot"
|
||||
echo ""
|
||||
else
|
||||
echo "❌ Failed to start container"
|
||||
echo "Check logs: docker logs telegram-trade-bot"
|
||||
fi
|
||||
60
scripts/setup/setup_telegram_bot.sh
Executable file
60
scripts/setup/setup_telegram_bot.sh
Executable file
@@ -0,0 +1,60 @@
|
||||
#!/bin/bash
|
||||
# Setup Telegram Trade Bot
|
||||
|
||||
echo "🤖 Telegram Trade Bot Setup"
|
||||
echo "============================"
|
||||
echo ""
|
||||
|
||||
# Check if .env.telegram-bot exists
|
||||
if [ ! -f .env.telegram-bot ]; then
|
||||
echo "❌ .env.telegram-bot not found!"
|
||||
echo "Create it with your bot token and webhook URL"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Source the env file
|
||||
source .env.telegram-bot
|
||||
|
||||
# Check required vars
|
||||
if [ "$TELEGRAM_BOT_TOKEN" = "your_bot_token_here" ]; then
|
||||
echo "❌ Please set TELEGRAM_BOT_TOKEN in .env.telegram-bot"
|
||||
echo ""
|
||||
echo "Steps:"
|
||||
echo "1. Message @BotFather on Telegram"
|
||||
echo "2. Send /newbot"
|
||||
echo "3. Follow instructions to get your bot token"
|
||||
echo "4. Put the token in .env.telegram-bot"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ "$N8N_WEBHOOK_URL" == *"your-n8n-url"* ]]; then
|
||||
echo "❌ Please set N8N_WEBHOOK_URL in .env.telegram-bot"
|
||||
echo ""
|
||||
echo "Steps:"
|
||||
echo "1. Import telegram-manual-trade-FINAL.json into n8n"
|
||||
echo "2. Activate the workflow"
|
||||
echo "3. Copy the webhook URL from the first node"
|
||||
echo "4. Put the URL in .env.telegram-bot"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "✅ Configuration looks good!"
|
||||
echo ""
|
||||
echo "📱 Chat ID: $TELEGRAM_CHAT_ID"
|
||||
echo "🔗 Webhook: $N8N_WEBHOOK_URL"
|
||||
echo ""
|
||||
echo "Building and starting bot..."
|
||||
echo ""
|
||||
|
||||
# Build and start
|
||||
docker-compose -f docker-compose.telegram-bot.yml --env-file .env.telegram-bot up -d --build
|
||||
|
||||
echo ""
|
||||
echo "✅ Bot started!"
|
||||
echo ""
|
||||
echo "Test it by sending to your Telegram chat:"
|
||||
echo " buy sol"
|
||||
echo " sell btc"
|
||||
echo " buy eth"
|
||||
echo ""
|
||||
echo "View logs: docker logs -f telegram-trade-bot"
|
||||
22
scripts/testing/send_trade.sh
Executable file
22
scripts/testing/send_trade.sh
Executable file
@@ -0,0 +1,22 @@
|
||||
#!/bin/bash
|
||||
# Quick script to trigger manual trades via n8n webhook
|
||||
# Usage: ./send_trade.sh "buy SOL"
|
||||
# ./send_trade.sh "sell BTC"
|
||||
|
||||
WEBHOOK_URL="https://YOUR_N8N_URL/webhook/manual-trade"
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
echo "Usage: $0 \"buy SOL\" or \"sell BTC\""
|
||||
exit 1
|
||||
fi
|
||||
|
||||
COMMAND="$1"
|
||||
|
||||
echo "📤 Sending command: $COMMAND"
|
||||
|
||||
curl -X POST "$WEBHOOK_URL" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{\"text\": \"$COMMAND\"}"
|
||||
|
||||
echo ""
|
||||
echo "✅ Command sent!"
|
||||
73
scripts/testing/test-exit-orders.sh
Executable file
73
scripts/testing/test-exit-orders.sh
Executable file
@@ -0,0 +1,73 @@
|
||||
#!/bin/bash
|
||||
# Test script to execute a tiny trade and verify exit orders are placed on-chain
|
||||
|
||||
echo "🧪 Testing exit order placement with tiny position..."
|
||||
echo "📊 Current settings:"
|
||||
echo " Position: \$10 (base)"
|
||||
echo " Leverage: 5x"
|
||||
echo " Notional: \$50"
|
||||
echo ""
|
||||
|
||||
# API endpoint and credentials
|
||||
API_URL="http://localhost:3001/api/trading/execute"
|
||||
API_KEY="2a344f0149442c857fb56c038c0c7d1b113883b830bec792c76f1e0efa15d6bb"
|
||||
|
||||
# Trade request payload
|
||||
PAYLOAD='{
|
||||
"symbol": "SOLUSDT",
|
||||
"direction": "long",
|
||||
"timeframe": "5",
|
||||
"signalStrength": "strong"
|
||||
}'
|
||||
|
||||
echo "🚀 Sending trade execution request..."
|
||||
echo ""
|
||||
|
||||
# Execute the request
|
||||
RESPONSE=$(curl -s -X POST "$API_URL" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer $API_KEY" \
|
||||
-d "$PAYLOAD")
|
||||
|
||||
echo "📨 Response:"
|
||||
echo "$RESPONSE" | jq '.' 2>/dev/null || echo "$RESPONSE"
|
||||
echo ""
|
||||
|
||||
# Check if successful
|
||||
if echo "$RESPONSE" | jq -e '.success' > /dev/null 2>&1; then
|
||||
echo "✅ Trade executed successfully!"
|
||||
|
||||
# Extract signatures
|
||||
POSITION_ID=$(echo "$RESPONSE" | jq -r '.positionId')
|
||||
EXIT_SIGS=$(echo "$RESPONSE" | jq -r '.exitOrderSignatures[]?' 2>/dev/null)
|
||||
|
||||
echo ""
|
||||
echo "📝 Transaction details:"
|
||||
echo " Entry TX: $POSITION_ID"
|
||||
|
||||
if [ -n "$EXIT_SIGS" ]; then
|
||||
echo " Exit orders placed:"
|
||||
echo "$EXIT_SIGS" | while read -r sig; do
|
||||
echo " - $sig"
|
||||
done
|
||||
|
||||
echo ""
|
||||
echo "🔍 Verify on Drift:"
|
||||
echo " https://app.drift.trade/"
|
||||
echo ""
|
||||
echo "🔍 Verify on Solscan:"
|
||||
echo "$EXIT_SIGS" | while read -r sig; do
|
||||
echo " https://solscan.io/tx/$sig"
|
||||
done
|
||||
else
|
||||
echo " ⚠️ No exit order signatures in response"
|
||||
fi
|
||||
else
|
||||
echo "❌ Trade execution failed!"
|
||||
ERROR=$(echo "$RESPONSE" | jq -r '.error // .message')
|
||||
echo " Error: $ERROR"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "📊 Check container logs for details:"
|
||||
echo " docker logs trading-bot-v4 --tail 100"
|
||||
19
scripts/testing/trade.sh
Executable file
19
scripts/testing/trade.sh
Executable file
@@ -0,0 +1,19 @@
|
||||
#!/bin/bash
|
||||
# Send manual trade command
|
||||
# Usage: ./trade.sh buy sol
|
||||
# ./trade.sh sell btc
|
||||
|
||||
COMMAND="$1 $2"
|
||||
|
||||
if [ -z "$COMMAND" ]; then
|
||||
echo "Usage: $0 <buy|sell> <sol|btc|eth>"
|
||||
echo "Example: $0 buy sol"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
curl -X POST http://10.0.0.48:8098/webhook/3371ad7c-0866-4161-90a4-f251de4aceb8 \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{\"body\": \"$COMMAND\"}"
|
||||
|
||||
echo ""
|
||||
echo "✅ Trade command sent: $COMMAND"
|
||||
Reference in New Issue
Block a user