Skip to content

rekon307/Flashbot

Repository files navigation

Binance Flashbot 🚀

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.

GitHub Python Binance

🌟 Features

Real-Time Market Intelligence

  • 📡 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

Interactive Trading

  • 🎯 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

Intelligent Automation

  • 🤖 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

🎬 Example Conversation

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%)

🚀 Quick Start

Prerequisites

  • Python 3.11 or higher
  • Binance account
  • Claude Code with MCP support

Installation

  1. Clone the repository
git clone https://github.com/rekon307/binance_flashbot.git
cd binance_flashbot
  1. Create virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
  1. Install dependencies
pip install -r requirements.txt
  1. Configure API credentials
cp .env.example .env
# Edit .env and add your Binance API credentials

Binance API Setup

⚠️ IMPORTANT SECURITY STEPS:

  1. Go to Binance API Management
  2. Create a new API key
  3. Enable: ✅ Spot & Margin Trading
  4. Disable: ❌ Enable Withdrawals (CRITICAL!)
  5. Optional: Add IP whitelist for extra security
  6. Copy API Key and Secret to .env file

Testnet Setup (Recommended First)

For risk-free testing with fake money:

  1. Go to Binance Testnet
  2. Create testnet account
  3. Generate testnet API keys
  4. Get free testnet funds from faucet
  5. Set BINANCE_ENVIRONMENT=testnet in .env

Running the Server

python src/mcp_server.py

Configure in Claude Code

Add this MCP server to your Claude Code settings:

{
  "mcpServers": {
    "binance-flashbot": {
      "command": "python",
      "args": ["/path/to/binance_flashbot/src/mcp_server.py"]
    }
  }
}

📖 Usage

Finding Hot Markets

You: "What's hot in the market right now?"

Claude will scan all pairs and report the hottest ones by volume and momentum.

Trading with Live Commentary

You: "Trade SOL on the 1-minute chart"

Claude will:

  1. Connect to live market data
  2. Continuously narrate price movements
  3. Analyze each 1-min candle
  4. Execute trades on signals
  5. Report all actions in real-time

You can interrupt anytime by pressing ESC and giving new instructions.

Manual Trading

You: "Buy 0.01 BTC at market price"
You: "Close position a7b3c2f1"
You: "Show my open positions"

Emergency Controls

You: "Emergency! Close all positions NOW!"

🛡️ Risk Management

Built-in Safety Features

  • 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

Configuration

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%

⚠️ Critical Warnings

Financial Risk

  • ⚠️ 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

Technical Risks

  • ⚠️ Network latency affects execution speed
  • ⚠️ WebSocket disconnections can happen
  • ⚠️ Market volatility can exceed stop-losses
  • ⚠️ API rate limits can result in bans

Security

  • 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

🔧 Available Tools

Claude has access to these tools:

Market Data

  • get_current_price(symbol) - Current market price
  • get_24h_stats(symbol) - 24h volume, high, low, change
  • get_order_book(symbol) - Current bids and asks

Market Scanning

  • find_hot_pairs() - Scan and rank all pairs
  • find_breakouts() - Find pairs breaking out
  • start_trading_on_1min(symbol) - Trade with live commentary

Trading

  • enter_long(symbol, quantity) - Enter long position
  • enter_short(symbol, quantity) - Enter short position
  • close_position(position_id) - Close specific position
  • emergency_close_all() - Close all positions NOW

Account

  • get_account_balance() - View balances
  • get_open_positions() - View open positions
  • get_trading_stats() - Performance statistics

Combined Workflows

  • find_and_trade_hot_pair() - Complete workflow: scan → select → trade

📊 Architecture

┌─────────────┐
│ Claude Code │
└──────┬──────┘
       │ MCP Protocol
       ▼
┌─────────────────────┐
│   MCP Server        │
│  (FastMCP)          │
└─────────┬───────────┘
          │
    ┌─────┴─────┬─────────┬──────────┐
    ▼           ▼         ▼          ▼
┌────────┐ ┌─────────┐ ┌─────┐ ┌─────────┐
│WebSocket│ │ Scanner │ │Exec │ │ Trader  │
└────┬───┘ └────┬────┘ └──┬──┘ └────┬────┘
     │          │          │         │
     └──────────┴──────────┴─────────┘
                  │
            ┌─────▼──────┐
            │Binance API │
            └────────────┘

🧪 Testing

Run tests:

pytest tests/

Test on Binance testnet first:

# Set in .env
BINANCE_ENVIRONMENT=testnet

📝 License

MIT License - see LICENSE file

⚖️ Legal Disclaimer

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

🤝 Contributing

Contributions welcome! Please:

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests
  5. Submit a pull request

📞 Support

🙏 Acknowledgments


Remember: Start with testnet, use small amounts, and never trade more than you can afford to lose! 🎯

About

Real-time trading co-pilot with WebSocket streaming and live commentary

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages