Babingepet
2.0
Multi-market quantitative trading framework — BTC Futures · Altcoin · IHSG · IHSG Scanner
System Architecture
Complete component map showing all four engines, shared infrastructure, AI layers, and data flows.
BTC/USDT Engine
60-second cycle, 27 signals, 8-agent AI swarm, 12-source weighted voting decision engine.
| Agent | Persona | Model |
|---|---|---|
| gemini | Generalist | gemini-2.5-pro |
| claude | Generalist | deepseek-r1:free |
| gpt | Generalist | qwen3.6-plus:free |
| momentum | Trend follower | gemini-flash |
| contrarian_shark | Mean reversion | gemini-flash |
| flow_reader | Microstructure | gemini-flash |
| macro_sage | Macro context | gemini-flash |
| conservative_filter | Risk manager | gemini-flash |
Altcoin Engine
4-hour cycle, 15-coin universe, 8-factor composite scoring, 5-agent AI swarm with sector gating.
IHSG Engine
Indonesian Stock Exchange coverage. 40-stock universe, 2× daily sessions, intraday overlay, news validation.
| Session | WIB | UTC | Focus |
|---|---|---|---|
| Session 1 — Opening | 09:00–12:00 | 02:00–05:00 | Momentum + Volume surge |
| Session 2 — Afternoon | 13:30–15:49 | 06:30–08:49 | Mean-reversion + VWAP |
IHSG Scanner
On-demand bandarmology analysis. 5-signal composite, 51-broker intelligence database, whale-adjusted scoring.
| Tier | Count | Examples | Whale? |
|---|---|---|---|
| FOREIGN_BIG | 10 | RX, GR, CL, BK | 2× |
| FOREIGN_MID | 10 | MQ, LG, FS | 2× |
| DOMESTIC_BIG | 10 | CC, IF, NF, AI | 2× |
| DOMESTIC_MID | 13 | YP, YU, XA | — |
| RETAIL | 8 | GG, SB, BI | — |
AI Model Map
Complete mapping of AI models to functions, cost tiers, and fallback chains.
| Model | Router | Used For | Cost Tier | Fallback |
|---|---|---|---|---|
| google/gemini-2.5-pro | OpenRouter | BTC generalist · Hermes analytics agents | PAID | gemini-flash |
| google/gemini-2.5-flash | OpenRouter | BTC swarm personas · Hermes Sentinel · IHSG/Altcoin swarm | LOW | deepseek-r1 |
| deepseek/deepseek-r1:free | OpenRouter | BTC generalist "claude" slot | FREE | qwen3-plus |
| qwen/qwen3.6-plus:free | OpenRouter | BTC generalist "gpt" slot | FREE | deepseek-r1 |
| Various OpenRouter | OpenRouter | IHSG 4-agent swarm · Altcoin 5-agent swarm | LOW | gemini-flash |
| XGBoost (local) | sklearn | BTC ml_xgboost signal (0.15 weight) | FREE | edge_estimate |
Generalist weights are dynamic — derived from last 50 predictions' accuracy. Weights are NOT normalized, preserving performance differences between models. Higher historical accuracy = higher weight on next prediction.
On STRONG_BUY or STRONG_SELL (non-vetoed), spawns daemon thread → calls Gemini Flash with last 8 BTC memory cycles.
Result written as hermes_note to btc_decisions table
Hermes Integration
Self-improving AI agent framework with SQLite persistent memory, 4 analytics agents, 6 Babingepet tools, and MCP bridge.
| Agent | Schedule | Goal |
|---|---|---|
| Signal Calibration | every 6h | Audit 50 predictions + 30 decisions |
| IHSG Pre-Session S1 | 01:20 UTC | Macro + per-stock news research |
| IHSG Pre-Session S2 | 05:50 UTC | Afternoon session stance |
| Altcoin Narrative | every 4h+10min | Narrative/catalyst per coin |
| Weekly Review | Sun 13:00 UTC | Full portfolio + predictions report |
Risk Management Layer
All veto conditions, gates, and guards across all four engines.
b = TP/SL ratio
p = win probability
q = 1 - p
Learning Feedback Loops
How trade outcomes feed back into future decisions across all three engines.
| Condition | Action |
|---|---|
| ci_hi < 0.45 | skip pattern |
| ci_hi < 0.50 | reduce_size |
| ci_lo > 0.55 | boost 1.2× |
| ci_lo > 0.65 | boost 1.4× |
| ci_lo > 0.75 | boost 1.6× |
| Threshold | Status |
|---|---|
| 8+ samples | Generated |
| 10+ samples | ACTIVE |
| 10+ samples | Applied to scoring |
Database Schema
Complete Supabase/PostgreSQL schema — all 16 tables with key columns and relationships.
API Endpoint Map
All FastAPI routes — method, path, purpose, and response shape.
Scheduler Timeline
24-hour visual timeline of all APScheduler jobs — cron and interval triggers.
| Job ID | Trigger | Interval | Purpose |
|---|---|---|---|
| run_collect | interval | 60s | BTC data collection from Binance |
| run_signals | interval | 60s | VPIN, OFI, Edge computation |
| run_sim | interval | 60s | BTC paper trading simulator |
| run_ai | interval | 10min | 8-agent AI swarm prediction |
| run_ihsg | cron | 02:00 + 06:30 UTC | IHSG session analysis |
| run_ihsg_price_update | interval | 30min | Intraday IHSG price overlay |
| run_altcoins | interval | 4h | Altcoin engine full cycle |
| run_altcoin_price_check | interval | 15min | Open position P&L check |
| hermes_signal_calibration | interval | 6h | Audit 50 predictions + 30 decisions |
| hermes_ihsg_s1 | cron | 01:20 UTC | Pre-session 1 research |
| hermes_ihsg_s2 | cron | 05:50 UTC | Pre-session 2 research |
| hermes_altcoin_narrative | interval | 4h +10min offset | Altcoin narrative/catalyst research |
| hermes_weekly_review | cron | Sun 13:00 UTC | Full portfolio + predictions report |
Deployment Architecture
VPS, Nginx, Systemd, process supervision — complete deployment topology.
End-to-End Data Flow
From exchange API to learning loop — complete data lifecycle across BTC engine.
Stack: Python 3.12 · FastAPI · APScheduler · Supabase · OpenRouter · Hermes · Telegram · Nginx