An autonomous crypto futures trading bot powered by the SLC Execution Blueprint (Structure β Level β Confirmation). Monitors Binance Futures via WebSocket, delivering real-time signals to Discord with self-improving ML filtering.
ββββββββββββββββββββββββββββββββββββββββββββββββββββ
β index.ts β
β (Binance Engine Bootstrap) β
ββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β BinanceProvider (WebSocket) β
β β Zero-delay candle close β
ββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β SignalEngine v2 β
β ββββββββββββββββββββββββββββββββββββββββββββ β
β β SLC Strategy (ONLY strategy) β β
β β ββ Stage 1: 4H Structure (EMA 21/50) β β
β β ββ Stage 2: 15m Supply/Demand Zones β β
β β ββ Stage 3: Stochastic (5,3,3) β β
β ββββββββββββββββββββββββββββββββββββββββββββ€ β
β β ML Filter (Multi-Dimensional Brain) β β
β β ββ Pattern win-rate (base) β β
β β ββ Volume confidence (+/- bonus) β β
β β ββ Session performance (time-of-day) β β
β β ββ Loss streak protection β β
β ββββββββββββββββββββββββββββββββββββββββββββ β
β β β
β TradeTracker (SL/TP/Breakeven/Trailing/MFE/MAE) β
β β β
β ββ DatabaseManager (SQLite) ββββββββββββββββββ β
β β active_trades β crash recovery β β
β β virtual_trades β ML learning data β β
β βββββββββββββββββββββββββββββββββββββββββββββββ β
β β β
β Discord Notifier (Signals / Trades / Results) β
β β β
β OrderExecutor (Binance Testnet Demo Trading) β
ββββββββββββββββββββββββββββββββββββββββββββββββββββ
- SLC-Only Strategy β 3-stage mechanical system (Structure β Level β Confirmation). No fallback strategies.
- 50 Symbols β Monitors top 50 Binance Futures pairs by volume
- Multi-Timeframe β 4H macro trend + 15m precision entries
- Volume-Weighted Zones β Supply/Demand scored by institutional volume (π₯ = 1.5x+ avg)
- Crash Recovery β Active trades persist in SQLite; recovers on restart
- Self-Improving ML β 4-factor scoring: pattern win rate, volume confidence, session performance, streak protection
- MFE/MAE Tracking β Records best and worst unrealized PnL per trade (answers "should I take partial profits?")
- Demo Trading β Real orders on Binance Testnet (fake USDT, zero risk)
- ATR Trailing Stops β Auto-tightens SL using 1.5x ATR after breakeven
- Graceful Shutdown β SIGINT/SIGTERM saves state before exit
- Exponential Reconnect β WebSocket reconnection with backoff (5s β 60s max)
| Component | Technology |
|---|---|
| Language | TypeScript (ESNext) |
| Runtime | Node.js 20+ |
| Database | SQLite (WAL mode) |
| Indicators | technicalindicators (EMA, ADX, ATR, Stochastic) |
| WebSocket | ws library |
| HTTP | axios |
| Notifications | Discord Webhooks |
src/
βββ index.ts # Entry point β Binance-only bootstrap
βββ backtest.ts # CLI backtesting entry point
βββ engines/
β βββ SignalEngine.ts # Core SLC orchestration + trade lifecycle
β βββ BacktestEngine.ts # Historical data replay + statistics
βββ strategies/
β βββ SLCStrategy.ts # SLC Blueprint (Structure/Level/Confirmation)
βββ providers/
β βββ MarketProvider.ts # OHLCV interface
β βββ BinanceProvider.ts # Binance Futures WebSocket + REST
βββ services/
β βββ MLAnalyzer.ts # Multi-dimensional ML signal filter
β βββ DatabaseManager.ts # SQLite (trade history + crash recovery)
β βββ VirtualTradeTracker.ts # SL/TP/Trailing/MFE/MAE management
β βββ OrderExecutor.ts # Binance testnet order placement
β βββ SymbolService.ts # Top-50 volume symbol discovery
β βββ CurrencyService.ts # USDT formatting
β βββ DiscordNotifier.ts # Discord webhook sender
npm installCreate a .env file:
# Binance Futures API
BINANCE_API_KEY=your_testnet_api_key
BINANCE_SECRET_KEY=your_testnet_secret_key
BINANCE_TESTNET=true # Use testnet (demo)
# Demo Trading
ENABLE_TESTNET_ORDERS=true # Place real orders with fake money
# Symbol Count (default: 50)
SYMBOL_COUNT=50
# Discord Webhooks
BINANCE_SIGNALS_WEBHOOK_URL=https://discord.com/api/webhooks/...
BINANCE_TRADES_WEBHOOK_URL=https://discord.com/api/webhooks/...
BINANCE_RESULTS_WEBHOOK_URL=https://discord.com/api/webhooks/...npx tsc && node dist/index.jsValidate the SLC strategy against historical data before trusting signals.
npx tsc && node dist/backtest.js BTCUSDT 3 # 3-month backtest
node dist/backtest.js ETHUSDT 6 # 6-month backtestnode dist/backtest.js --multi 3 # Test 8 symbols over 3 months=======================================================
π BACKTEST REPORT: BTCUSDT
=======================================================
Total Trades: 12
Wins / Losses / BE: 7 / 4 / 1
Win Rate: 58.3% β Above 55% is good
Total PnL: +4.21%
Avg Win: +0.89%
Avg Loss: -0.42%
Profit Factor: 3.71 β Above 1.5 is profitable
Max Drawdown: -1.23% β How much you'd lose at worst
Max Consec. Losses: 2
=======================================================
| Metric | Good | Bad |
|---|---|---|
| Win Rate | >55% | <45% |
| Profit Factor | >1.5 | <1.0 |
| Max Drawdown | <5% | >10% |
| Avg Win / Avg Loss | >1.5 | <1.0 |
Note: SLC is a sniper strategy. Expect 0-3 signals per day across 50 symbols. This is by design β fewer trades = higher conviction.
- Go to Binance Futures Testnet
- Log in with GitHub
- Go to API Management β Create API key
- Copy the API Key and Secret Key
BINANCE_API_KEY=your_testnet_api_key
BINANCE_SECRET_KEY=your_testnet_secret_key
BINANCE_TESTNET=true
ENABLE_TESTNET_ORDERS=truenpx tsc && node dist/index.js
# Output: π SignalEngine v2 Online
# [Config] Orders: β
Demo Trading ENABLEDENABLE_TESTNET_ORDERS=true + BINANCE_TESTNET=true
β β
Demo orders with fake USDT (safe)
ENABLE_TESTNET_ORDERS=true + BINANCE_TESTNET=false
β π BLOCKED (requires ENABLE_LIVE_ORDERS=true)
ENABLE_TESTNET_ORDERS not set
β Signals only, no orders placed
The bot uses a self-improving feedback loop with 4-factor ML scoring:
- ML Filter approves all signals (needs 20+ trades per pattern)
- Every trade is logged with rich metadata: zone strength, volume score, stochastic values, session, MFE/MAE
- Let it run undisturbed β it's building its knowledge base
The ML brain starts making decisions based on:
| Factor | What It Does |
|---|---|
| Pattern Win Rate | Base approval check (>50%) |
| Volume Confidence | Zones with 1.5x+ avg volume get a 5% threshold reduction (more permissive) |
| Session Performance | Auto-penalizes time-of-day windows with historically bad results |
| Streak Protection | After 3+ consecutive losses, temporarily raises approval threshold |
- Every trade result updates the ML brain
- Bad patterns get filtered out automatically
- Good sessions get rewarded
- The approval threshold dynamically adjusts per signal
- Run 24/7 for at least 1 week before trusting results
- Never delete
trade_history.dbβ it's the bot's memory - Check
maxFavorablecolumn β if trades consistently hit +1.5R before reverting, consider adding partial TP - Query the database to see ML insights:
sqlite3 trade_history.db "SELECT timeOfDay, COUNT(*), ROUND(AVG(CASE WHEN outcome='WIN' THEN 1.0 ELSE 0.0 END)*100,1) as win_rate FROM virtual_trades GROUP BY timeOfDay"
If the bot crashes or restarts while trades are active:
- Active trades are persisted to SQLite (
active_tradestable) - On restart, the bot loads them back into memory
- SL/TP/trailing management resumes immediately
- Discord notification: "π Recovered N active trades from last session"
Note: If price blew through SL/TP while the bot was offline, the trade closes at the first available price. For demo trading, Binance testnet SL/TP orders handle this automatically.
The bot needs 24/7 uptime with stable internet for WebSocket connections.
| Spec | Minimum | Recommended |
|---|---|---|
| CPU | 1 vCPU | 2 vCPU |
| RAM | 512 MB | 1 GB |
| Storage | 1 GB SSD | 5 GB SSD |
| OS | Ubuntu 22.04+ | Ubuntu 24.04 LTS |
| Node.js | v20+ | v22 LTS |
| Provider | Plan | ~Cost/Month |
|---|---|---|
| Hetzner (Best Value) | CX22 | ~β¬4/mo (~βΉ380) |
| Oracle Cloud | Free Tier (ARM) | Free forever |
| Contabo | VPS S | ~β¬6/mo (~βΉ570) |
| DigitalOcean | Basic Droplet | $6/mo (~βΉ500) |
# 1. SSH into VPS
ssh root@your-vps-ip
# 2. Install Node.js
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
sudo apt install -y nodejs
# 3. Clone & Setup
git clone https://github.com/your-user/SignalEngine.git
cd SignalEngine && npm install && npx tsc
# 4. Configure
cp .env.example .env && nano .env
# 5. Run with PM2 (auto-restart)
npm install -g pm2
pm2 start dist/index.js --name signal-engine
pm2 save && pm2 startup| Variable | Required | Description |
|---|---|---|
BINANCE_API_KEY |
β | Binance Futures API key (testnet or mainnet) |
BINANCE_SECRET_KEY |
β | Binance Futures secret |
BINANCE_TESTNET |
β | true for demo trading (default: false) |
ENABLE_TESTNET_ORDERS |
β | true to place orders on testnet |
ENABLE_LIVE_ORDERS |
β | true to unlock mainnet (DANGER) |
SYMBOL_COUNT |
β | Number of top-volume symbols to monitor (default: 50) |
BINANCE_SIGNALS_WEBHOOK_URL |
β | Discord signals channel |
BINANCE_TRADES_WEBHOOK_URL |
β | Discord trades channel |
BINANCE_RESULTS_WEBHOOK_URL |
β | Discord results channel |
| Channel | Purpose | Examples |
|---|---|---|
| #signals | New SLC signals | π― SLC SIGNAL β BTC/USDT with checklist, market data |
| #trades | Trade lifecycle | π― TRADE OPENED, π‘οΈ BREAKEVEN, π TRAILING |
| #results | Outcomes | π WIN (+1.82%), π LOSS (-0.45%), π RECOVERED |
USE AT YOUR OWN RISK. This software is provided "as is" and for educational/demonstration purposes only. The creator(s) and contributor(s) of this project assume no responsibility or liability for any financial losses, damages, or unintended consequences resulting from the use of this software. By using this bot, you acknowledge that cryptocurrency trading carries significant risk and you are solely responsible for any trades or decisions made.
This project is licensed under the MIT License.