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.
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
| Metric | Value |
|---|---|
| Total AI Agents | 39 |
| Agent Run Interval | 60 seconds |
| Dashboard Refresh | 30 seconds (no page reload) |
| Signal Confirmation | 3 consecutive cycles required |
| Signal Expiry | 8 hours after creation |
| INR Rate Refresh | Every 4 hours (live from open.er-api.com) |
| Prediction Sources | 9 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).
All 40 Agents
| # | Agent Name | Purpose | Interval |
|---|---|---|---|
| 1 | Scanner | Fetches OHLCV data from Binance for all coins | 60s |
| 2 | Technical | Calculates RSI, MACD, Bollinger Bands, ATR, EMA for all timeframes | 120s |
| 3 | News | Fetches crypto news and scores sentiment with AI | 600s |
| 4 | Regime | Detects market regime (bull/bear/neutral/crash/recovery) | 180s |
| 5 | Fear & Greed | Fetches Alternative.me Fear & Greed Index | 3600s |
| 6 | BTC Dominance | Tracks Bitcoin and Ethereum dominance from CoinGecko | 3600s |
| 7 | Futures | Collects open interest, funding rate, liquidation data | 120s |
| 8 | Whale | Detects large wallet transactions via Whale Alert API | 300s |
| 9 | DEX Discovery | Finds trending DEX pairs via DEXScreener/GeckoTerminal | 300s |
| 10 | Risk Manager | Enforces drawdown limits, daily loss limits, exposure caps | 60s |
| 11 | Portfolio | Snapshots portfolio equity, exposure, drawdown | 300s |
| 12 | Strategy Engine | Adjusts strategy weights based on recent performance | 300s |
| 13 | Backtester | Runs historical backtests on active strategies | 3600s |
| 14 | Walk-Forward | Walk-forward validation to prevent overfitting | 3600s |
| 15 | Evaluator | Scores each strategy's IC, Sharpe, win rate | 300s |
| 16 | Weighting | Bayesian strategy weight updates | 300s |
| 17 | Decision | Creates signals after 3 confirmation cycles | 60s |
| 18 | Data Quality | Flags stale or anomalous data in any table | 300s |
| 19 | Health Monitor | Tracks agent uptime, errors, last execution | 60s |
| 20 | Research | AI-driven market research using LLM (Gemini/GPT-4) | 3600s |
| 21 | Feature Store | Builds and caches ML feature vectors | 300s |
| 22 | Paper Trading | Executes and closes paper trades based on signals | 60s |
| 23 | CoinGlass | Fetches OI, funding rate, L/S ratio from CoinGlass | 120s |
| 24 | Social Sentiment | Scans Reddit for coin mentions and scores sentiment | 600s |
| 25 | Feature Importance | Ranks which features best predict price moves | 3600s |
| 26 | Multi-Timeframe | Aligns 5m/15m/1h/4h/1D trend signals | 120s |
| 27 | Strategy Marketplace | Manages strategy plugin marketplace | 3600s |
| 28 | RL Agent | Reinforcement learning position optimizer | 300s |
| 29 | Futures Advisor | Advises on futures contracts using funding rate + OI | 120s |
| 30 | Kalman Filter | Kalman-filtered price estimates to reduce noise | 120s |
| 31 | HMM Regime | Hidden Markov Model for market state detection | 300s |
| 32 | Portfolio Optimizer | Mean-variance + Kelly criterion position sizing | 3600s |
| 33 | Research Journal | AI auto-generates trade rationale journal entries | 3600s |
| 34 | Daily Reporter | Sends daily performance report at 6AM UTC | daily |
| 35 | Feature Drift | Detects when input feature distributions shift (PSI) | 3600s |
| 36 | Correlation | Tracks inter-coin correlation to reduce portfolio risk | 3600s |
| 37 | CoinSwitch | Fetches live INR buy/sell quotes from CoinSwitch Pro | 120s |
| 38 | GARCH | GARCH(1,1) volatility forecasting for position sizing | 300s |
| 39 | Live Alert Agent | Sends Telegram alerts for high-confidence signals in real time | 60s |
| 40 | Signal Broadcaster | Dispatches high/critical scanner alerts to Telegram subscribers | 60s |
Unified Prediction Weights
The Unified Prediction Engine merges outputs from all agents. Each source is given a weight based on its reliability and recency.
| Source | Weight | Agent(s) | Why |
|---|---|---|---|
| Signal | 27% | Agent 17 | Highest weight — only created after 3 confirmed cycles |
| Technical | 22% | Agent 2 | RSI, MACD, Bollinger Bands — most direct price signal |
| Multi-Timeframe | 13% | Agent 26 | Cross-timeframe trend alignment increases conviction |
| CoinGlass | 9% | Agent 23 | Funding rate and L/S ratio predict short squeezes |
| Whale | 7% | Agent 8 | Smart money accumulation/distribution signals |
| Fear & Greed | 7% | Agent 5 | Alternative.me index — always available, no API key needed |
| Social | 6% | Agent 24 | Reddit/social sentiment as contrarian indicator |
| Regime | 5% | Agent 4 | Global market context (bull/bear macro environment) |
| BTC Dominance | 4% | Agent 6 | High 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:
- Loads all active coins
- Fetches the latest row from each agent's output table using bulk queries
- Scores each source on a 0–100 bullish scale
- Calculates a weighted average, redistributing weight from missing sources
- Returns:
bull_pct,bear_pct,confidence,recommendation
| Bull Score | Recommendation |
|---|---|
| ≥ 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.
| Command | Description |
|---|---|
/start | Welcome message + subscribe to alerts |
/predict | Top 5 unified AI predictions |
/signals | Active trading signals |
/top | Top 5 high-confidence BUY coins |
/portfolio | Portfolio snapshot |
/news | Latest 3 news articles |
/help | Command list |
| anything else | AI-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.