DEV Community

ILIA CHERKASOV
ILIA CHERKASOV

Posted on

I built a Multi-Agent AI Trading Signal Bot for OKX Futures in Python

For the past few weeks I've been building something more ambitious than my usual bots — an AI-powered crypto futures signal system for OKX.

Not an auto-trader. A smart analyst that thinks, then asks you to decide.

What it does

torgBot scans 60 OKX perpetual swap pairs every 5 minutes, detects chart patterns, scores them 0–10, and sends a Telegram signal with:

  • Candlestick chart PNG (mplfinance)
  • Entry price, Stop Loss, TP1 / TP2 / TP3
  • R:R ratio, funding rate, Fear & Greed index
  • Full AI analysis text

The multi-agent architecture

This is the part I'm most proud of. Four agents work together:

  • News Agent — checks if any crypto news could impact the trade
  • Whale Watcher — detects large player activity via OI and funding
  • Analyst Agent — scores the pattern quality (0–10)
  • Orchestrator — combines all inputs and makes the final GO/SKIP call
# Simplified orchestrator logic
decision = orchestrator.evaluate(
    pattern_score=analyst.score,
    whale_signal=whale_watcher.signal,
    news_risk=news_agent.risk_level,
    market_context={"btc_trend": btc, "fg": fear_greed}
)
Enter fullscreen mode Exit fullscreen mode

Pattern detection (5 types)

  • Double Bottom / Double Top
  • Head & Shoulders
  • Bull / Bear Flags
  • ABCD Pattern

Each pattern gets scored on: R:R ratio · Volume · HTF confirmation · Fibonacci levels · Open Interest · Funding Rate

Real-time dashboard

Built a WebSocket dashboard (port 8766) that shows all agents working in real time — which pairs are being scanned, what each agent decided, and why.

Tech stack

  • Python 3.11, aiogram 3.x
  • ccxt → OKX perpetual swaps
  • Cerebras qwen-3-235b (LLM reasoning)
  • Google Gemini (visual chart analysis)
  • mplfinance + matplotlib (chart generation)
  • APScheduler (scan every 5 min)
  • aiosqlite (trade tracking)

Example signal output

СЕТАП: EWY/USDT PERP · 4H Long
Pattern: Double Bottom (forming) | Score: 9.2/10

Price:     176.9200
BUY LIMIT: 173.9600  (-1.7%)
Stop:      171.1766  (-1.6%)
TP1:       192.1000  (+10.4%)
TP2:       203.3105  (+16.9%)
TP3:       221.4505  (+27.3%)

R:R 1:6.5 | Horizon: 5–14 days
F&G: 25 — Extreme Fear | Mode: Trend

AI: Pattern confirmed. Analyst recommends entry.
Market in trend mode, no news or whale risks.

Analytics. Decision is yours.
Enter fullscreen mode Exit fullscreen mode

Key design decision

The bot never trades automatically. It analyzes, scores, explains — and always ends with: "Decision is yours."

I believe AI should assist traders, not replace their judgment.

What's next

  • Backtesting module
  • Multi-exchange support (Binance, Bybit)
  • Portfolio tracker integration

The full source is available on Gumroad if you want to run your own instance: torgBot OKX

Happy to answer questions about the architecture or any part of the implementation!

Top comments (1)

Collapse
 
pythonbotdev profile image
ILIA CHERKASOV

Quick FAQ from early DMs:

🔹 Does it auto-trade? No — by design. The bot finds setups and
scores them, you make every entry decision manually.

🔹 Why OKX? Best perpetual liquidity, clean API via ccxt, and the
funding/OI data is reliable.

🔹 Cerebras + Gemini, why both? Cerebras qwen-3-235b handles fast
reasoning on text/numbers (news, scoring logic). Gemini handles
visual analysis of the candlestick chart PNG — it actually "sees"
the pattern.

🔹 What's the win rate? I don't publish numbers because results
depend on which signals you take and your risk management. The
bot is an analyst, not a guarantee.

Happy to dive deeper into any specific part — agent communication,
pattern detection logic, or the dashboard architecture.