Crypto Quant AI
v3.0 Documentation

Crypto Quant AI
Documentation

Complete technical documentation for the Crypto Quant AI platform — 40 AI agents, a unified prediction engine, INR pricing, paper trading, and a Telegram bot.

Overview

Crypto Quant AI is a full-stack quantitative trading assistant built for Indian crypto traders. Instead of showing you raw charts, it runs 40 specialized AI agents every 60 seconds and merges their outputs into a single, easy-to-understand prediction per coin.

Core Principle

Each agent is an expert in one area (news, technical analysis, whale activity, etc.). When they all agree → high confidence. When they disagree → HOLD. This is called ensemble prediction.

Key Numbers

MetricValue
Total AI Agents39
Agent Run Interval60 seconds
Dashboard Refresh30 seconds (no page reload)
Signal Confirmation3 consecutive cycles required
Signal Expiry8 hours after creation
INR Rate RefreshEvery 4 hours (live from open.er-api.com)
Prediction Sources9 weighted data sources

Architecture

Built on FastAPI + SQLAlchemy 2.0 async + PostgreSQL (Supabase). Agents run on APScheduler. The frontend is server-side rendered Jinja2 (no React/Vue dependency).

[ Data Sources ]
Binance API CoinGlass Whale Alert NewsAPI Reddit/Social CoinSwitch DEXScreener
[ 40 Agents → APScheduler ]
Scanner Technical News Whale Regime CoinGlass Decision RL Agent
[ Unified Prediction Engine ]
Signal 27% + Tech 22% + MTF 13% + CG 9% + Whale 7% + F&G 7% + Social 6% + Regime 5% + BTC.D 4%
One Score: STRONG BUY 78% Bull (Conf 56%)

All 40 Agents

#Agent NamePurposeInterval
1ScannerFetches OHLCV data from Binance for all coins60s
2TechnicalCalculates RSI, MACD, Bollinger Bands, ATR, EMA for all timeframes120s
3NewsFetches crypto news and scores sentiment with AI600s
4RegimeDetects market regime (bull/bear/neutral/crash/recovery)180s
5Fear & GreedFetches Alternative.me Fear & Greed Index3600s
6BTC DominanceTracks Bitcoin and Ethereum dominance from CoinGecko3600s
7FuturesCollects open interest, funding rate, liquidation data120s
8WhaleDetects large wallet transactions via Whale Alert API300s
9DEX DiscoveryFinds trending DEX pairs via DEXScreener/GeckoTerminal300s
10Risk ManagerEnforces drawdown limits, daily loss limits, exposure caps60s
11PortfolioSnapshots portfolio equity, exposure, drawdown300s
12Strategy EngineAdjusts strategy weights based on recent performance300s
13BacktesterRuns historical backtests on active strategies3600s
14Walk-ForwardWalk-forward validation to prevent overfitting3600s
15EvaluatorScores each strategy's IC, Sharpe, win rate300s
16WeightingBayesian strategy weight updates300s
17DecisionCreates signals after 3 confirmation cycles60s
18Data QualityFlags stale or anomalous data in any table300s
19Health MonitorTracks agent uptime, errors, last execution60s
20ResearchAI-driven market research using LLM (Gemini/GPT-4)3600s
21Feature StoreBuilds and caches ML feature vectors300s
22Paper TradingExecutes and closes paper trades based on signals60s
23CoinGlassFetches OI, funding rate, L/S ratio from CoinGlass120s
24Social SentimentScans Reddit for coin mentions and scores sentiment600s
25Feature ImportanceRanks which features best predict price moves3600s
26Multi-TimeframeAligns 5m/15m/1h/4h/1D trend signals120s
27Strategy MarketplaceManages strategy plugin marketplace3600s
28RL AgentReinforcement learning position optimizer300s
29Futures AdvisorAdvises on futures contracts using funding rate + OI120s
30Kalman FilterKalman-filtered price estimates to reduce noise120s
31HMM RegimeHidden Markov Model for market state detection300s
32Portfolio OptimizerMean-variance + Kelly criterion position sizing3600s
33Research JournalAI auto-generates trade rationale journal entries3600s
34Daily ReporterSends daily performance report at 6AM UTCdaily
35Feature DriftDetects when input feature distributions shift (PSI)3600s
36CorrelationTracks inter-coin correlation to reduce portfolio risk3600s
37CoinSwitchFetches live INR buy/sell quotes from CoinSwitch Pro120s
38GARCHGARCH(1,1) volatility forecasting for position sizing300s
39Live Alert AgentSends Telegram alerts for high-confidence signals in real time60s
40Signal BroadcasterDispatches high/critical scanner alerts to Telegram subscribers60s

Unified Prediction Weights

The Unified Prediction Engine merges outputs from all agents. Each source is given a weight based on its reliability and recency.

SourceWeightAgent(s)Why
Signal27%Agent 17Highest weight — only created after 3 confirmed cycles
Technical22%Agent 2RSI, MACD, Bollinger Bands — most direct price signal
Multi-Timeframe13%Agent 26Cross-timeframe trend alignment increases conviction
CoinGlass9%Agent 23Funding rate and L/S ratio predict short squeezes
Whale7%Agent 8Smart money accumulation/distribution signals
Fear & Greed7%Agent 5Alternative.me index — always available, no API key needed
Social6%Agent 24Reddit/social sentiment as contrarian indicator
Regime5%Agent 4Global market context (bull/bear macro environment)
BTC Dominance4%Agent 6High BTC.D = altcoins weak; low BTC.D = alt season

Unified Prediction

The Unified Prediction engine (app/services/unified_prediction.py) runs on each API call. It:

  1. Loads all active coins
  2. Fetches the latest row from each agent's output table using bulk queries
  3. Scores each source on a 0–100 bullish scale
  4. Calculates a weighted average, redistributing weight from missing sources
  5. Returns: bull_pct, bear_pct, confidence, recommendation
Recommendation Thresholds
Bull ScoreRecommendation
≥ 72%STRONG BUY
62–72%BUY
38–62%HOLD
28–38%SELL
≤ 28%STRONG SELL

Confidence Formula

Confidence measures how far the bull score is from neutral (50%). The formula uses a ×3 multiplier so strong signals feel significant:

confidence = min( abs(bull_pct - 50) × 3, 100 )

Examples:
  72% bull  → |72-50| × 3 = 66%  confidence  (STRONG BUY)
  62% bull  → |62-50| × 3 = 36%  confidence  (BUY)
  50% bull  → |50-50| × 3 =  0%  confidence  (HOLD)
  80% bull  → |80-50| × 3 = 90%  confidence  (STRONG BUY)
    

If a source (e.g. Whale Alert, CoinGlass) is unavailable, its weight is redistributed proportionally among the active sources — the engine always produces a result even with partial data.

Signal Flow (Agent 17)

Agent 17 (Decision Agent) is the only agent that creates signals. It requires 3 consecutive cycles of the same direction before firing. This prevents noise signals.

Cycle 1: BUY → confirmation_count = 1
Cycle 2: BUY → confirmation_count = 2
Cycle 3: BUY → confirmation_count = 3 → SIGNAL CREATED ✓
Cycle 4: SELL → counter resets to 0

Signal expires: 8 hours after creation (configurable via SIGNAL_MAX_AGE_HOURS)
    

Prediction API

All APIs require the X-API-Key header.

GET /api/v1/prediction/unified

Returns merged prediction from all agents for each coin.

GET /api/v1/prediction/unified?limit=20
X-API-Key: your-api-key

Response:
{
  "status": "success",
  "count": 5,
  "data": [
    {
      "symbol": "BTCUSDT",
      "base": "BTC",
      "bull_pct": 72.4,
      "bear_pct": 27.6,
      "confidence": 66.6,
      "recommendation": "STRONG BUY",
      "sources_used": 9,
      "sources": ["Signal(STRONG_BUY,78%)", "TA(RSI=38)", "MTF(uptrend)", ...]
    }
  ]
}
    

Signals API

GET /api/v1/signals/latest

GET /api/v1/signals/latest?limit=20

Market API

GET /api/v1/market/regime/current

GET /api/v1/market/regime/current

GET /api/v1/market/fear-greed/latest

GET /api/v1/market/btc-dominance/latest

GET /api/v1/market/news?limit=20

GET /api/v1/market/whale-activity?limit=20

Telegram Bot

The bot (app/services/telegram_bot.py) runs as a background polling thread. It stores every user's Telegram chat ID in the app_users table.

CommandDescription
/startWelcome message + subscribe to alerts
/predictTop 5 unified AI predictions
/signalsActive trading signals
/topTop 5 high-confidence BUY coins
/portfolioPortfolio snapshot
/newsLatest 3 news articles
/helpCommand list
anything elseAI-powered human-like reply via Gemini

Login & Signup

Authentication uses cookie-based sessions. Passwords are hashed with PBKDF2-HMAC-SHA256 (100,000 iterations). Sessions expire after 30 days.

CAPTCHA is a simple math challenge (e.g., "3 + 7 = ?") signed with HMAC — no external service needed, no user tracking.

User Profile

Visit /profile to change your password or find your Telegram bot link. Your Telegram account is linked automatically when you send /start to the bot.