- Removed MIN_TIME_BETWEEN_TRADES (no cooldown needed) - Removed TELEGRAM_BOT_TOKEN/CHAT_ID (n8n handles notifications) - Changed default LEVERAGE from 10x to 5x (safer) - Changed MAX_DAILY_DRAWDOWN from -150 to -50 (safer) - Clarified Pyth is FREE - no API key needed - Updated risk calculations for 5x leverage - Removed all unnecessary variables - Total: 136 lines (cleaner and focused)
156 lines
4.5 KiB
Plaintext
156 lines
4.5 KiB
Plaintext
# Trading Bot v4 - Environment Variables Template
|
|
# Copy this file to .env.local and fill in your values
|
|
#
|
|
# IMPORTANT: Never commit .env.local to git!
|
|
|
|
# ================================
|
|
# REQUIRED - DRIFT PROTOCOL
|
|
# ================================
|
|
|
|
# Your Solana wallet private key (base58 format)
|
|
# Get from: Phantom → Settings → Export Private Key
|
|
DRIFT_WALLET_PRIVATE_KEY=your_base58_private_key_here
|
|
|
|
# Drift environment (mainnet-beta for production, devnet for testing)
|
|
DRIFT_ENV=mainnet-beta
|
|
|
|
# API secret key for authenticating n8n requests
|
|
# Generate with: openssl rand -hex 32
|
|
# ⚠️ MUST match API_SECRET_KEY in n8n environment variables
|
|
API_SECRET_KEY=your_random_secret_key_here
|
|
|
|
# ================================
|
|
# REQUIRED - SOLANA RPC ENDPOINT
|
|
# ================================
|
|
|
|
# Solana RPC URL (get free key at https://helius.dev)
|
|
# Helius free tier: 100,000 requests/day
|
|
SOLANA_RPC_URL=https://mainnet.helius-rpc.com/?api-key=YOUR_HELIUS_API_KEY
|
|
|
|
# Alternative RPC providers:
|
|
# QuickNode: https://solana-mainnet.quiknode.pro/YOUR_ENDPOINT/
|
|
# Alchemy: https://solana-mainnet.g.alchemy.com/v2/YOUR_ALCHEMY_KEY
|
|
# Ankr: https://rpc.ankr.com/solana
|
|
|
|
# ================================
|
|
# REQUIRED - PYTH NETWORK (Price Feeds)
|
|
# ================================
|
|
|
|
# Pyth Hermes WebSocket endpoint
|
|
# FREE - No API key needed!
|
|
PYTH_HERMES_URL=https://hermes.pyth.network
|
|
|
|
# ================================
|
|
# TRADING CONFIGURATION
|
|
# ================================
|
|
|
|
# Position size in USD (default: 50 for testing)
|
|
# With 5x leverage: $50 position = $250 notional value
|
|
MAX_POSITION_SIZE_USD=50
|
|
|
|
# Leverage multiplier (1-20, default: 5)
|
|
LEVERAGE=5
|
|
|
|
# Risk parameters (as percentages)
|
|
# Stop Loss: Close 100% of position when price drops this much
|
|
STOP_LOSS_PERCENT=-1.5
|
|
|
|
# Take Profit 1: Close 50% of position at this profit level
|
|
TAKE_PROFIT_1_PERCENT=0.7
|
|
|
|
# Take Profit 2: Close remaining 50% at this profit level
|
|
TAKE_PROFIT_2_PERCENT=1.5
|
|
|
|
# Move SL to breakeven when profit reaches this level
|
|
BREAKEVEN_TRIGGER_PERCENT=0.4
|
|
|
|
# Risk limits
|
|
# Stop trading if daily loss exceeds this amount (USD)
|
|
MAX_DAILY_DRAWDOWN=-50
|
|
|
|
# Maximum trades per hour (prevents overtrading)
|
|
MAX_TRADES_PER_HOUR=6
|
|
|
|
# Maximum acceptable slippage (percentage)
|
|
SLIPPAGE_TOLERANCE=1.0
|
|
|
|
# ================================
|
|
# OPTIONAL - DEVELOPMENT
|
|
# ================================
|
|
|
|
# Node environment
|
|
NODE_ENV=production
|
|
|
|
# Log level (debug, info, warn, error)
|
|
LOG_LEVEL=info
|
|
|
|
# Enable dry run mode (simulate trades without executing)
|
|
DRY_RUN=false
|
|
|
|
# API server port
|
|
PORT=3000
|
|
|
|
# ================================
|
|
# SETUP CHECKLIST
|
|
# ================================
|
|
|
|
# [ ] 1. Copy this file to .env.local
|
|
# [ ] 2. Get Solana wallet private key from Phantom
|
|
# [ ] 3. Get free Helius RPC key: https://helius.dev
|
|
# [ ] 4. Generate API_SECRET_KEY: openssl rand -hex 32
|
|
# [ ] 5. Set same API_SECRET_KEY in n8n environment variables
|
|
# [ ] 6. Set MAX_POSITION_SIZE_USD=50 for testing
|
|
# [ ] 7. Start bot: npm run dev (or use Docker)
|
|
# [ ] 8. Import n8n-workflow-simple.json to n8n
|
|
# [ ] 9. Configure TradingView alert webhook
|
|
# [ ] 10. Test with small position first!
|
|
|
|
# ================================
|
|
# EXPECTED RISK PER TRADE
|
|
# ================================
|
|
|
|
# With default settings:
|
|
# - Position Size: $50
|
|
# - Leverage: 5x
|
|
# - Notional Value: $250
|
|
# - Max Loss (SL): $1.875 (-1.5% on 5x)
|
|
# - TP1 Gain: $0.875 (+0.7% on 5x, 50% position)
|
|
# - TP2 Gain: $1.875 (+1.5% on 5x, remaining 50%)
|
|
# - Full Win: $2.75 total profit
|
|
|
|
# ================================
|
|
# n8n ENVIRONMENT VARIABLES
|
|
# ================================
|
|
|
|
# You need to set these in n8n (Settings → Environment Variables):
|
|
# - TRADING_BOT_API_URL=http://your-server:3000
|
|
# - API_SECRET_KEY=same_as_above
|
|
# - TELEGRAM_CHAT_ID=your_telegram_chat_id
|
|
#
|
|
# Note: Telegram notifications are handled by n8n, not by v4 bot
|
|
|
|
# ================================
|
|
# SECURITY NOTES
|
|
# ================================
|
|
|
|
# ⚠️ Never commit .env.local to git
|
|
# ⚠️ Use a dedicated trading wallet with limited funds
|
|
# ⚠️ Start with small position sizes ($50-100)
|
|
# ⚠️ Keep private keys secure
|
|
# ⚠️ Rotate API_SECRET_KEY regularly
|
|
|
|
# ================================
|
|
# GETTING API KEYS
|
|
# ================================
|
|
|
|
# Helius RPC: https://helius.dev (free tier available)
|
|
# Phantom Wallet: Download from https://phantom.app
|
|
# Random secret: openssl rand -hex 32
|
|
# Pyth Network: No API key needed - it's free!
|
|
|
|
|
|
# Getting API Keys:
|
|
# - Helius RPC: https://helius.dev (free: 100k requests/day)
|
|
# - Telegram Bot: @BotFather on Telegram
|
|
# - Random secret: openssl rand -hex 32
|