Skip to content

synkfr/Signal-Engine-Futures

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

50 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ SignalEngine v2 β€” SLC-Only Crypto Futures Trading Bot

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.

Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                   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)     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Features

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

Tech Stack

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

Project Structure

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

Setup

1. Install Dependencies

npm install

2. Configure Environment

Create 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/...

3. Build & Run

npx tsc && node dist/index.js

Backtesting

Validate the SLC strategy against historical data before trusting signals.

Single Symbol

npx tsc && node dist/backtest.js BTCUSDT 3    # 3-month backtest
node dist/backtest.js ETHUSDT 6               # 6-month backtest

Multi-Symbol Batch

node dist/backtest.js --multi 3    # Test 8 symbols over 3 months

Reading Results

=======================================================
  πŸ“Š 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.

Demo Trading (Testnet)

1. Get Testnet API Keys

  1. Go to Binance Futures Testnet
  2. Log in with GitHub
  3. Go to API Management β†’ Create API key
  4. Copy the API Key and Secret Key

2. Enable in .env

BINANCE_API_KEY=your_testnet_api_key
BINANCE_SECRET_KEY=your_testnet_secret_key
BINANCE_TESTNET=true
ENABLE_TESTNET_ORDERS=true

3. Run

npx tsc && node dist/index.js
# Output: πŸš€ SignalEngine v2 Online
#         [Config] Orders: βœ… Demo Trading ENABLED

Safety Architecture

ENABLE_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

How the Bot Learns

The bot uses a self-improving feedback loop with 4-factor ML scoring:

Phase 1: Data Collection (First 1-3 Days)

  • 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

Phase 2: Pattern Learning (After ~100 Trades)

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

Phase 3: Continuous Improvement

  • Every trade result updates the ML brain
  • Bad patterns get filtered out automatically
  • Good sessions get rewarded
  • The approval threshold dynamically adjusts per signal

Training Tips

  1. Run 24/7 for at least 1 week before trusting results
  2. Never delete trade_history.db β€” it's the bot's memory
  3. Check maxFavorable column β€” if trades consistently hit +1.5R before reverting, consider adding partial TP
  4. 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"

Crash Recovery

If the bot crashes or restarts while trades are active:

  1. Active trades are persisted to SQLite (active_trades table)
  2. On restart, the bot loads them back into memory
  3. SL/TP/trailing management resumes immediately
  4. 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.

Hosting

Recommended: VPS (Virtual Private Server)

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

VPS Providers

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)

VPS Deploy

# 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

Environment Variables

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

Discord Channels

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

Disclaimer

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.

License

This project is licensed under the MIT License.

About

Crypto Futures Trading bot

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors