A production-ready system that connects TradingView alerts to Claude AI for automated trading decisions, with optional execution via Binance API.
- ✅ TradingView webhook ingestion
- ✅ MCP-compatible API endpoints
- ✅ Claude AI decision engine
- ✅ Binance API trade execution
- ✅ Telegram notifications (optional)
- ✅ Comprehensive logging
- ✅ Input validation and security
- ✅ In-memory queue system
- ✅ Error handling and retries
-
Install dependencies:
npm install
-
Configure environment:
cp .env.example .env # Edit .env with your API keys -
Run the server:
npm start # Or for development: npm run dev
WEBHOOK_SECRET=your_webhook_secret_here
ANTHROPIC_API_KEY=your_anthropic_api_key_here
BINANCE_API_KEY=your_binance_api_key_here
BINANCE_API_SECRET=your_binance_api_secret_here
API_KEY=your_api_key_for_protection_hereTELEGRAM_BOT_TOKEN=your_telegram_bot_token_here
TELEGRAM_CHAT_ID=your_chat_id_here
MAX_TRADE_SIZE=0.001
PORT=3000POST /webhook/tradingview- Receive TradingView alerts
All MCP endpoints require x-api-key header with your API_KEY.
GET /mcp/get-signal- Get latest signalPOST /mcp/analyze- Analyze signal with ClaudePOST /mcp/send-order- Execute tradePOST /mcp/log- Manual loggingPOST /mcp/auto-trade- Full automation (analyze + execute)GET /mcp/market-data/:symbol?- Get real-time market dataPOST /mcp/ask-claude- Ask Claude questions about market with live data
- Create a new alert in TradingView
- Set Webhook URL:
https://your-domain.com/webhook/tradingview?secret=YOUR_WEBHOOK_SECRET - Set Message format to JSON:
{
"symbol": "{{ticker}}",
"price": {{close}},
"signal": "{{strategy.order.action}}",
"rsi": {{rsi}},
"timeframe": "{{interval}}"
}- Add header:
x-webhook-secret: YOUR_WEBHOOK_SECRET
Ask Claude questions about live market data:
# Get current market data
curl -H "x-api-key: YOUR_API_KEY" http://localhost:3000/mcp/market-data/BTCUSDT
# Ask Claude about market conditions
curl -X POST -H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"question":"What is the current market sentiment?", "symbol":"BTCUSDT"}' \
http://localhost:3000/mcp/ask-claudeClaude now has access to:
- Real-time price and 24h statistics
- Order book (top bids/asks)
- Recent trades
- Price chart data (last 10 hours)
- Technical analysis
- TradingView sends signal → stored in memory
- Call
/mcp/get-signalto get latest signal - Call
/mcp/analyzeto get AI decision - Call
/mcp/send-orderto execute trade
Use /mcp/auto-trade to automatically analyze and execute trades based on signals.
# Get signal
curl -H "x-api-key: YOUR_API_KEY" http://localhost:3000/mcp/get-signal
# Analyze
curl -X POST -H "x-api-key: YOUR_API_KEY" http://localhost:3000/mcp/analyze
# Send order
curl -X POST -H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"symbol":"BTCUSDT","side":"BUY","quantity":0.001}' \
http://localhost:3000/mcp/send-order
# Auto trade
curl -X POST -H "x-api-key: YOUR_API_KEY" http://localhost:3000/mcp/auto-trade- Webhook endpoints validate secret keys
- MCP endpoints require API key authentication
- Input validation on all payloads
- No secrets exposed in logs
All activities are logged to logs/trading.log and console:
- Incoming signals
- AI decisions
- Executed trades
- Errors
TradingView → Webhook → Signal Store → Claude AI → Decision → Binance API → Trade
↓
Telegram Notifications
src/
├── routes/
│ ├── webhook.js
│ └── mcp.js
├── services/
│ ├── claude.js
│ ├── binance.js
│ ├── telegram.js
│ ├── logger.js
│ └── signalStore.js
└── utils/
└── validate.js
- Maximum trade size configurable
- Only executes BUY/SELL, skips on SKIP
- Comprehensive error handling
- Queue system prevents concurrent executions
- express: Web server
- @anthropic-ai/sdk: Claude AI integration
- axios: HTTP requests
- node-telegram-bot-api: Telegram notifications
- dotenv: Environment configuration
ISC