Complete autonomous trading engine for Binance with WebSocket real-time, OCO orders, Kelly Criterion position sizing, trailing stops, circuit breakers, daily performance reports, AND NOW adaptive strategy mixing, memory persistence, and intelligent performance alerts. Self-learning trading bot that improves over time.
Instalar com Codex ou Claude Copie este prompt, cole no Codex, Claude ou outro assistente e deixe que ele revise a página da skill e instale para você.
Um comando direto ignora o prompt de revisão. Verifique a origem antes de executá-lo.
Complete autonomous trading engine for Binance with WebSocket real-time, OCO orders, Kelly Criterion position sizing, trailing stops, circuit breakers, daily performance reports, AND NOW adaptive strategy mixing, memory persistence, and intelligent performance alerts. Self-learning trading bot that improves over time.
version
2.3.0
author
Georges Andronescu (Wesley Armando)
license
MIT
homepage
https://github.com/georges91560/crypto-executor
repository
https://github.com/georges91560/crypto-executor
source
https://github.com/georges91560/crypto-executor
metadata
{"openclaw":{"emoji":"⚡","requires":{"bins":["python3"],"env":["BINANCE_API_KEY","BINANCE_API_SECRET"],"optional_env":["TELEGRAM_BOT_TOKEN","TELEGRAM_CHAT_ID"]},"install":"pip install websocket-client --break-system-packages","install_notes":"On shared hosting (Hostinger, cPanel): --break-system-packages is required. On standard servers/VPS: prefer virtualenv → python3 -m venv venv && source venv/bin/activate && pip install websocket-client","primaryEnv":"BINANCE_API_KEY","external_dependencies":[{"name":"crypto-sniper-oracle","source":"https://github.com/georges91560/crypto-sniper-oracle","path":"/workspace/skills/crypto-sniper-oracle/crypto_oracle.py","optional":true,"purpose":"Order book imbalance and VWAP signals via subprocess","security":"Audit code before installation — executes as subprocess"}],"network_behavior":{"makes_requests":true,"endpoints_allowed":["https://api.binance.com/api/v3/*","wss://stream.binance.com:9443/ws/*","https://api.telegram.org/bot*"],"requires_credentials":true,"uses_websocket":true},"security_level":"L3 - Financial Execution (Real Money)"}}
Crypto Executor v2.3 — PRODUCTION READY ⚡
🎯 WHAT IT DOES
Professional autonomous trading bot with COMPLETE feature set:
Purpose: Provides order book imbalance, VWAP, and microstructure analysis
Execution: Called via subprocess during market scanning
Security: MUST be audited before installation (external code execution)
What it does:
Fetches Binance market data
Calculates order book metrics
Returns JSON signals
NO credential requirements
NO network calls except Binance
Installation instructions in CONFIGURATION.md
🤖 Pre-Installation Check (Terminal / Hostinger)
Why pre-install? The script is 1722 lines. Pre-installing it on the server means the AI agent never needs to recreate it from scratch — it launches in seconds and loads its learned memory immediately. Overwriting an existing install would erase learned_config.json and performance_metrics.json — the bot's brain.
Always run this check first:
# Check if already installedls /workspace/skills/crypto-executor/executor.py
# ✅ Already installed → just launch:source /etc/crypto-executor/credentials.env
python3 /workspace/skills/crypto-executor/executor.py
# ❌ Not installed → full install (run once):mkdir -p /workspace/skills/crypto-executor /workspace/reports/daily /workspace/config_history
cd /workspace/skills
git clone https://github.com/georges91560/crypto-executor.git crypto-executor-repo
# SECURITY: pin a specific commit instead of HEAD — verify tag on GitHub first# git checkout <commit-hash-or-tag>cp crypto-executor-repo/executor.py /workspace/skills/crypto-executor/executor.py # filename is lowercase
pip install websocket-client --break-system-packages
# On VPS/standard server: prefer → python3 -m venv venv && source venv/bin/activate && pip install websocket-client# Verify before launch
python3 -c "
import os; from pathlib import Path
checks = {
'executor.py': Path('/workspace/skills/crypto-executor/executor.py').exists(),
'oracle': Path('/workspace/skills/crypto-sniper-oracle/crypto_oracle.py').exists(),
'API_KEY': bool(os.getenv('BINANCE_API_KEY')),
'API_SECRET': bool(os.getenv('BINANCE_API_SECRET')),
}
[print(('✅' if v else '❌') + ' ' + k) for k,v in checks.items()]
print('READY — run executor.py' if all(checks.values()) else 'FIX ABOVE FIRST')
"
Full step-by-step guide with explanations:CONFIGURATION.md
🔥 COMPLETE FEATURES
1. WebSocket Real-Time Streaming
# With websocket-client installed (recommended):
pip install websocket-client --break-system-packages
# On VPS/standard server: prefer → python3 -m venv venv && source venv/bin/activate && pip install websocket-client# → Sub-100ms updates via wss://stream.binance.com:9443/ws/# → Auto-reconnect on disconnect# → Ping keepalive every 20s# Without websocket-client (fallback automatic):# → REST polling every 1s# → No config needed, bot works normally# Benefits vs v1.0:
- 300x faster position monitoring
- Instant stop loss execution
- bid/ask spread available in cache
2. OCO Orders (One-Cancels-Other)
# Binance manages TP/SL automatically
Entry: Market BUY executed
↓
OCO order created instantly:
├─ Take Profit: Binance sells at TP
└─ Stop Loss: Binance sells at SL
# When TP hits → SL cancels# When SL hits → TP cancels# Zero lag, managed by Binance# v2.3 addition: OCO monitoring# Bot detects when Binance closes position# → Updates portfolio, Kelly, performance metrics instantly
Protection window:
v1.0: Up to 5 minutes unprotected
v2.3: <1 second protection ✅
3. Kelly Criterion Position Sizing
# Adaptive position sizing based on performance
kelly = (win_rate × avg_win - (1 - win_rate) × avg_loss) / avg_win
# Example:
Win rate: 85%
Avg win: +0.3%
Avg loss: -0.5%
Kelly = (0.85 × 0.003 - 0.15 × 0.005) / 0.003
= 0.60 (60% of capital suggested)
# Use 50% Kelly (conservative default)
Position size = 60% × 0.5 × signal_confidence
# Adapts automatically as performance changes!# Default: 60% (prudent start, no history)
# Level 1: Daily Loss Limit
Daily loss > 2%
→ Pause trading for2 hours
→ Auto-resume
# Level 2: Weekly Loss Limit
Weekly loss > 5%
→ Reduce position sizes by 50%
→ Conservative mode active
# Level 3: Drawdown Pause
Drawdown > 7%
→ Pause trading for48 hours
→ Manual review required
# Level 4: Kill Switch
Drawdown > 10%
→ STOP ALL TRADING
→ Manual restart only
Maximum possible loss: 10% (kill switch prevents catastrophe)
6. Daily Performance Reports
# Generated at 9am UTC every day# Sent via Telegram
Report includes:
├─ Total equity
├─ Daily P&L ($, %)
├─ Number of trades
├─ Win rate
├─ Sharpe ratio
├─ Drawdown %
├─ Strategy mix active
└─ Status (on track / below target)
Example report:
📊 DAILY PERFORMANCE REPORT
2026-02-28 09:00 UTC
💰 PORTFOLIO
Total: $10,543.20
Cash: $3,200.00 USDT
Positions: 3 open
Day P&L: +$243.20 (+2.36%)
Drawdown: 1.2%
📈 TRADING
Trades Today: 12
Win Rate: 91.7%
🎯 STATUS
✅ On Track
Entry: BTC/ETH ratio divergence > 2σ
Target: Mean reversion (+1%)
Stop: -1%
Hold: Hours to days
Win rate: 70-80%
9. Performance Analytics
# Tracked metrics:
- Total trades
- Winning trades / Losing trades
- Average win / Average loss
- Win rate (updated on every close)
- Kelly fraction (recalculated)
- Sharpe ratio (annualized)
- Max drawdown
- ROI (daily, weekly, monthly)
# Used for:
- Kelly position sizing (real-time)
- Strategy allocation adjustment
- Risk limit calibration
- Adaptive mixing decisions
📊 PERFORMANCE IMPROVEMENTS
Metric
v1.0
v2.3 Production
Improvement
Market scan
5-10s
0.5s
10-20x faster
TP/SL detection
5 min
<1s
300x faster
Trade entry
2-3s
0.5s
4-6x faster
Position sizing
Fixed
Kelly adaptive
Optimal growth
Profit capture
Fixed TP
Trailing stops
+50-200%
Risk protection
Basic
4-level breakers
10% max loss
Visibility
Logs only
Daily reports + Sharpe
Full analytics
Order rejection
Frequent
None (LOT_SIZE)
100% fill rate
Symbols scanned
5
10
2x opportunity
💰 EXPECTED PERFORMANCE
Conservative Profile
Capital: $5,000-$10,000
Strategy mix: Scalping 80%, Momentum 20%
Position size: Kelly 50% (adaptive)
Daily: 50-100 trades | Win rate 88-92% | ROI +0.5% to +1.2%
Monthly: ROI 10-20% | Max drawdown 3-5% | Sharpe 2.5-3.5
Balanced Profile
Capital: $10,000-$25,000
Strategy mix: Scalping 70%, Momentum 25%, Stat Arb 5%
Position size: Kelly 50%
Daily: 100-200 trades | Win rate 85-90% | ROI +0.8% to +1.8%
Monthly: ROI 15-30% | Max drawdown 5-7% | Sharpe 2.0-3.0
Aggressive Profile
Capital: $50,000+
Strategy mix: All strategies active
Position size: Kelly 60%
Daily: 150-250 trades | Win rate 82-88% | ROI +1.0% to +2.5%
Monthly: ROI 20-40% | Max drawdown 7-10% | Sharpe 1.8-2.5
📊 DAILY PERFORMANCE REPORT
[Full report at 9am UTC]
⚙️ CONFIGURATION
Risk Limits (Environment Variables)
MAX_POSITION_SIZE_PCT=12 # Max 12% per trade
DAILY_LOSS_LIMIT_PCT=2 # Pause at -2% daily
WEEKLY_LOSS_LIMIT_PCT=5 # Reduce at -5% weekly
DRAWDOWN_PAUSE_PCT=7 # Pause at 7% drawdown
DRAWDOWN_KILL_PCT=10 # Kill switch at 10%