An advanced cryptocurrency trading bot system with real and simulated trading modes. Features 3 proven strategies with 60-75% win rates, real-time market data via Binance WebSockets, and a beautiful dashboard to monitor all bots.
-
Fake Trading (Simulation)
- Trades with real-time Binance prices
- Simulated orders and positions
- Perfect for testing strategies risk-free
- No real money involved
-
Real Trading (Live)
- Actual trading on Binance
- Real orders and positions
โ ๏ธ USE WITH CAUTION - REAL MONEY AT RISK
Each strategy runs as an independent bot with its own budget:
-
Grid Trading (70-75% win rate)
- Best for ranging/sideways markets
- Automated buy/sell at grid levels
- Low risk, consistent small profits
-
Mean Reversion (65-70% win rate)
- Best for ranging markets
- Uses Bollinger Bands + RSI
- 2:1 reward-risk ratio
-
Trend Following (60-65% win rate)
- Best for trending markets
- Uses EMA alignment + ADX + MACD
- Trailing stops for maximum profit
- โ Real-time BTC/USDT price via Binance WebSockets
- โ Independent bots running simultaneously
- โ Separate budgets per bot ($100 starting each)
- โ Beautiful web dashboard
- โ Real-time statistics and performance tracking
- โ Comprehensive logging system
- โ Risk management built-in
- โ Stop loss and take profit automation
- โ Position and order monitoring
cryptoBot/
โโโ src/
โ โโโ strategies/ # Trading strategies
โ โ โโโ BaseStrategy.ts
โ โ โโโ GridTradingStrategy.ts
โ โ โโโ MeanReversionStrategy.ts
โ โ โโโ TrendFollowingStrategy.ts
โ โโโ engines/ # Trading engines
โ โ โโโ FakeTradingEngine.ts
โ โ โโโ RealTradingEngine.ts
โ โโโ services/ # External services
โ โ โโโ BinanceWebSocket.ts
โ โโโ utils/ # Utilities
โ โ โโโ indicators.ts # Technical indicators
โ โ โโโ logger.ts # Logging system
โ โโโ types/ # TypeScript types
โ โ โโโ index.ts
โ โโโ TradingBot.ts # Bot coordinator
โ โโโ BotManager.ts # Multi-bot orchestrator
โ โโโ server.ts # Express API server
โ โโโ index.ts # Entry point
โโโ public/ # Dashboard UI
โ โโโ index.html
โ โโโ style.css
โ โโโ app.js
โโโ logs/ # Bot logs (auto-created)
โโโ .env # Environment configuration
โโโ package.json
โโโ tsconfig.json
- Node.js 18+ and npm
- (Optional) Binance account with API keys for real trading
-
Clone/Navigate to the repository
cd /home/user/cryptoBot -
Install dependencies (already done)
npm install
-
Configure environment
- Copy
.env.exampleto.envif needed - For fake trading: No configuration needed
- For real trading: Add your Binance API credentials to
.env
- Copy
-
Build the project
npm run build
-
Start the server
npm start
Or for development with auto-reload:
npm run dev
-
Open the dashboard
- Navigate to
http://localhost:3001 - The beautiful dashboard will open in your browser
- Navigate to
- Open the dashboard at
http://localhost:3001 - Choose your trading mode:
- Fake Trading: For risk-free simulation
- Real Trading: For live trading (requires API keys)
- Set the initial budget per bot (default: $100)
- If using real trading, enter your Binance API credentials
- Click "Initialize System"
- Click "Start All Bots" to start all 3 bots simultaneously
- Each bot will:
- Connect to Binance WebSocket
- Fetch historical data
- Begin analyzing the market
- Execute trades based on its strategy
- Select a bot from the dropdown menu
- View real-time statistics:
- Current BTC price
- Bot status
- Budget (initial & current)
- Total profit/loss
- Win rate percentage
- Open positions
- Trade history
- Stats update every 5 seconds automatically
- Click "Stop All Bots"
- All bots will:
- Close open positions
- Cancel pending orders
- Clear their logs
- Stop trading
- Click "๐ Run Backtest" button
- Wait 1-2 seconds while historical data loads
- View comprehensive results for all 3 strategies:
- Win rates
- Total profit/loss
- Number of trades
- Average win/loss percentages
- Max drawdown
- Profit factor
- Comparison table ranking strategies
Included Data:
- 90 days of sample data (included in repository)
- Ready to use immediately after deployment
Optional - Download Real Data: For more accurate backtesting with 2 years of real Binance data:
npm run download-dataThis downloads 2 years of BTC/USDT data (~180 MB) and takes 5-10 minutes.
- Trading mode selection (Fake/Real)
- Budget configuration
- API credentials input (for real trading)
- System initialization
- Start/Stop all bots
- Run backtest button (historical analysis)
- Real-time status indicator
- Quick control access
- Dropdown to select which bot to view
- Shows strategy name and expected win rate
- Current BTC Price: Live price from Binance
- Strategy: Which strategy the bot uses
- Status: Running or Stopped
- Budgets: Initial and current budget
- Total PnL: Profit/Loss with color coding
- Trade Statistics: Total, winning, losing trades
- Win Rate: Percentage of winning trades
- Open Positions & Orders: Real-time monitoring
- Drawdown: Current drawdown percentage
- Symbol, side (long/short)
- Entry price and amount
- Current price and unrealized PnL
- Stop loss and take profit levels
- Position Sizing: Max 10% of budget per trade
- Stop Losses: Automatic stop loss on every trade
- Risk Per Trade: Limited to 1-2% of capital
- Drawdown Monitoring: Tracks portfolio drawdown
- Independent Budgets: Bots don't affect each other
- START SMALL: Begin with minimum budget
- PAPER TRADE FIRST: Test with fake trading for weeks/months
- NEVER RISK MORE THAN YOU CAN LOSE: Crypto is volatile
- USE TESTNET: Consider Binance testnet before live trading
- MONITOR CLOSELY: Check bots regularly
- API SECURITY: Use API keys with trading-only permissions
- NO WITHDRAWALS: Don't give withdrawal permissions to API keys
Each bot maintains its own log file in the logs/ directory:
GridTrading-fake.log(or-real.log)MeanReversion-fake.logTrendFollowing-fake.log
Logs include:
- Initialization events
- Trade executions (BUY/SELL)
- Strategy signals
- Errors and warnings
- Performance updates
Logs are automatically cleared when you stop the bots.
# Build TypeScript to JavaScript
npm run build
# Start production server
npm start
# Start development server with auto-reload
npm run dev
# Clean build and logs
npm run clean
# Download 2 years of historical BTC data for backtesting
npm run download-data- Create a new strategy class extending
BaseStrategy - Implement the
analyze()method - Add the strategy to
BotManager.ts - Update the dashboard dropdown
Example:
import { BaseStrategy } from './BaseStrategy';
import { Candle, TradeSignal } from '../types';
export class MyStrategy extends BaseStrategy {
constructor() {
super('MyStrategy');
}
public analyze(candles: Candle[], currentPrice: number): TradeSignal {
// Your strategy logic here
return {
action: 'hold',
price: currentPrice,
reason: 'Waiting for setup'
};
}
}- Backend: Node.js, TypeScript, Express
- Frontend: Vanilla JavaScript, HTML, CSS
- Exchange: Binance API (via CCXT)
- Real-time Data: Binance WebSockets
- Indicators: Custom implementations (SMA, EMA, RSI, BB, ADX, MACD)
- Event-driven architecture
- Shared WebSocket connection
- Independent bot execution
- RESTful API for dashboard communication
- Real-time statistics updates
- WebSocket ensures minimal API calls
- 1-minute candle intervals
- Analysis runs every minute
- Dashboard updates every 5 seconds
- Low resource usage
A: Minimum $100 per bot (3 bots = $300 total) for fake trading. For real trading, start with the minimum you're willing to lose while testing.
A: Yes! Modify the BotManager.ts to create only the bots you want.
A: The WebSocket will automatically reconnect. However, you should monitor the bots and restart if needed.
A: Currently optimized for BTC/USDT. You can modify the code to support other pairs.
A: Very accurate! It uses real-time prices and realistic order execution. The only difference is no actual orders are placed on the exchange.
A: Yes! Click the "๐ Run Backtest" button in the dashboard. It works immediately with 90 days of included sample data. For more accurate testing with 2 years of real data, run npm run download-data.
MIT License - Use at your own risk
IMPORTANT: This software is for educational purposes only.
- NOT FINANCIAL ADVICE: This is not financial advice
- NO GUARANTEES: Past performance does not guarantee future results
- HIGH RISK: Cryptocurrency trading is extremely risky
- TOTAL LOSS POSSIBLE: You can lose all your invested capital
- YOUR RESPONSIBILITY: You are solely responsible for your trading decisions
- NO WARRANTY: This software is provided "as is" without warranty
Use at your own risk. The developers are not responsible for any financial losses.
Built with the Claude Skills Framework Strategies based on proven technical analysis principles Powered by Binance real-time data
Happy Trading! Remember: Start small, test thoroughly, and never risk more than you can afford to lose. ๐