Real-time trading co-pilot with WebSocket streaming and live commentary
An interactive AI trading assistant that integrates with Binance through Claude Code's MCP protocol. Get real-time market analysis, automated scanning, and live trading with continuous narration - all while you maintain full control.
- 📡 WebSocket Streaming: Live 1-minute candle data with <100ms latency
- 🔍 Market Scanner: Find hot pairs by volume, momentum, and volatility
- 📊 Breakout Detection: Identify pairs near 24h highs with strong momentum
- 💹 Live Price Updates: Continuous market data without API rate limits
- 🎯 Live Commentary: Claude narrates everything in real-time
- ⚡ Instant Execution: <200ms trade execution from command
- 🎮 Full Control: Interrupt anytime with ESC key
- 🛡️ Risk Management: Built-in position limits and stop-losses
- 🤖 Continuous Monitoring: Watch 1-min charts with auto-analysis
- 📈 Momentum Strategy: Simple but effective scalping strategy
- 💼 Position Tracking: Real-time P&L and performance metrics
- 🚨 Emergency Controls: Instant position closure on demand
You: "Find the hottest trading pair and trade it on 1-minute chart"
Claude: 🔍 Scanning all Binance pairs...
Claude: Found 237 USDT pairs, filtering by volume...
Claude: 🔥 Top 5 hottest pairs:
Claude: 1. 📈 SOL/USDT: $98.60 (+5.1%) Vol: $890M Score: 9.2
Claude: 2. 📈 BTC/USDT: $43,250 (+3.2%) Vol: $2.1B Score: 8.7
Claude: 3. 📈 MATIC/USDT: $0.92 (+6.2%) Vol: $380M Score: 8.5
Claude:
Claude: ✨ Selected: SOL/USDT (Score: 9.2)
Claude: 🎯 Starting 1-minute trading on SOL/USDT...
Claude: 📡 Connected to WebSocket stream
Claude: 👀 Watching 1-minute candles...
Claude:
Claude: 💹 $98.62 | Vol: 45,230
Claude: 💹 $98.70 | Vol: 52,340
Claude:
Claude: 📊 1-min candle closed: $98.72
Claude: 📈 Change: +$0.12 (+0.12%)
Claude: 📊 Volume: 48,120 (1.1x avg)
Claude: ⚪ Momentum: NEUTRAL (mixed)
Claude:
Claude: 💹 $98.85 | Vol: 78,450
Claude:
Claude: 📊 1-min candle closed: $98.87
Claude: 📈 Change: +$0.15 (+0.32%)
Claude: 📊 Volume: 82,340 (2.8x avg)
Claude: 🟢 Momentum: BULLISH (5 green candles)
Claude:
Claude: 🚀 BULLISH SIGNAL DETECTED!
Claude: • Price momentum: +0.32%
Claude: • Volume spike: 2.8x average
Claude: • Trend: Strong upward
Claude:
Claude: 💡 Entering LONG position...
Claude: 💼 Entering LONG position on SOL/USDT...
Claude: Quantity: 0.1, Est. price: $98.87
Claude: ✅ LONG position opened at $98.89
Claude: Position ID: a7b3c2f1
Claude:
Claude: 💹 $98.95 | Vol: 65,230
Claude: 💚 Position P&L: +$0.06 (+0.06%)
Claude: 💹 $99.10 | Vol: 72,450
Claude: 💚 Position P&L: +$0.21 (+0.21%)
[You press ESC to interrupt]
You: "Close the position now"
Claude: 🔒 Closing LONG position on SOL/USDT...
Claude: ✓ Position closed at $99.08
Claude: Entry: $98.89 → Exit: $99.08
Claude: P&L: +$0.19 (+0.19%)
- Python 3.11 or higher
- Binance account
- Claude Code with MCP support
- Clone the repository
git clone https://github.com/rekon307/binance_flashbot.git
cd binance_flashbot- Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install dependencies
pip install -r requirements.txt- Configure API credentials
cp .env.example .env
# Edit .env and add your Binance API credentials- Go to Binance API Management
- Create a new API key
- Enable: ✅ Spot & Margin Trading
- Disable: ❌ Enable Withdrawals (CRITICAL!)
- Optional: Add IP whitelist for extra security
- Copy API Key and Secret to
.envfile
For risk-free testing with fake money:
- Go to Binance Testnet
- Create testnet account
- Generate testnet API keys
- Get free testnet funds from faucet
- Set
BINANCE_ENVIRONMENT=testnetin.env
python src/mcp_server.pyAdd this MCP server to your Claude Code settings:
{
"mcpServers": {
"binance-flashbot": {
"command": "python",
"args": ["/path/to/binance_flashbot/src/mcp_server.py"]
}
}
}You: "What's hot in the market right now?"
Claude will scan all pairs and report the hottest ones by volume and momentum.
You: "Trade SOL on the 1-minute chart"
Claude will:
- Connect to live market data
- Continuously narrate price movements
- Analyze each 1-min candle
- Execute trades on signals
- Report all actions in real-time
You can interrupt anytime by pressing ESC and giving new instructions.
You: "Buy 0.01 BTC at market price"
You: "Close position a7b3c2f1"
You: "Show my open positions"
You: "Emergency! Close all positions NOW!"
- ✅ Position Size Limits: Max $100 per position (configurable)
- ✅ Stop Loss: Auto-close at -0.5% loss
- ✅ Take Profit: Auto-close at +1.0% profit
- ✅ Daily Loss Limit: Max $50 daily loss (configurable)
- ✅ API Restrictions: Withdrawal disabled, IP whitelisted
- ✅ Emergency Stop: Close all positions instantly
Edit .env to adjust risk parameters:
MAX_POSITION_SIZE_USDT=100.0 # Max $ per position
MAX_DAILY_LOSS_USDT=50.0 # Max $ loss per day
STOP_LOSS_PERCENTAGE=0.5 # Auto-close at -0.5%⚠️ You can lose 100% of trading capital⚠️ Start with testnet before using real money⚠️ Only trade money you can afford to lose⚠️ 1-minute scalping is extremely high-risk
⚠️ Network latency affects execution speed⚠️ WebSocket disconnections can happen⚠️ Market volatility can exceed stop-losses⚠️ API rate limits can result in bans
- ✅ Never commit .env file to Git
- ✅ API keys must have withdrawal disabled
- ✅ Use IP whitelist on API keys
- ✅ Rotate API keys every 30-90 days
Claude has access to these tools:
get_current_price(symbol)- Current market priceget_24h_stats(symbol)- 24h volume, high, low, changeget_order_book(symbol)- Current bids and asks
find_hot_pairs()- Scan and rank all pairsfind_breakouts()- Find pairs breaking outstart_trading_on_1min(symbol)- Trade with live commentary
enter_long(symbol, quantity)- Enter long positionenter_short(symbol, quantity)- Enter short positionclose_position(position_id)- Close specific positionemergency_close_all()- Close all positions NOW
get_account_balance()- View balancesget_open_positions()- View open positionsget_trading_stats()- Performance statistics
find_and_trade_hot_pair()- Complete workflow: scan → select → trade
┌─────────────┐
│ Claude Code │
└──────┬──────┘
│ MCP Protocol
▼
┌─────────────────────┐
│ MCP Server │
│ (FastMCP) │
└─────────┬───────────┘
│
┌─────┴─────┬─────────┬──────────┐
▼ ▼ ▼ ▼
┌────────┐ ┌─────────┐ ┌─────┐ ┌─────────┐
│WebSocket│ │ Scanner │ │Exec │ │ Trader │
└────┬───┘ └────┬────┘ └──┬──┘ └────┬────┘
│ │ │ │
└──────────┴──────────┴─────────┘
│
┌─────▼──────┐
│Binance API │
└────────────┘
Run tests:
pytest tests/Test on Binance testnet first:
# Set in .env
BINANCE_ENVIRONMENT=testnetMIT License - see LICENSE file
This software is for educational purposes only. Cryptocurrency trading carries substantial risk of loss. You are solely responsible for any trading decisions and their outcomes. The authors assume no liability for financial losses incurred through use of this software.
Important:
- Cryptocurrency trading may be restricted in your jurisdiction
- Automated trading may require specific licenses
- Tax implications vary by country - consult a tax professional
- You are responsible for compliance with local laws
Contributions welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
- Binance - Exchange API
- FastMCP - MCP framework
- python-binance - Python client
- Anthropic - Claude Code
Remember: Start with testnet, use small amounts, and never trade more than you can afford to lose! 🎯