Kokoro

Kokoro Alpha Lab

Author

wang

Date Published

Bold abstract shapes representing digital innovation and ambition
RustTypeScriptNext.jsRedis StreamsSolanaJito MEVMCPDocker

Overview

Kokoro Alpha Lab is a quantitative factor-based trading system for Solana. It monitors smart-money wallet activity in real time, runs capital flow through 20+ pluggable alpha factors, predicts price trajectories using physically meaningful state-space models (IMM, RBPF, conformal prediction), and executes MEV-protected trades through AMM pools via Jito block engine bundles.

The core thesis: cryptocurrency price movements follow a causal chain — social triggers create herd behavior, which generates capital flow, which moves prices. The system does not predict when trends start. It detects that a trend has started and rides the capital flow using models where every parameter maps to a real-world quantity.

Architecture

The system uses a Clean Integration Layer (CIL) architecture across a 5-repository ecosystem. All business logic lives in 84 pure Rust crates with zero I/O dependencies — independently testable and composable. Three application tiers sit on top: Lab (research and paper trading with hot-reload), Engine (production execution with frozen strategy), and Platform (gateway service with auth, billing, and tier gates).

Four companion services complete the ecosystem: a Next.js frontend dashboard with real-time charting, a Wallet Monitor service that tracks on-chain swaps via WebSocket subscriptions across Jupiter, Raydium, Orca, and PumpFun DEXes, a Pricing Service that aggregates multi-DEX prices and computes order flow imbalance, and an MCP server exposing 98 tools for AI-native interaction through Claude Code.

All inter-service communication flows through Redis Streams — 10 active streams carry swaps, price updates, order flow, cluster events, token discovery, and approved signals between services.

Key Features

Signal Intelligence — Smart-money wallet monitoring with graph-based Louvain clustering, 20+ pluggable alpha factors covering swap momentum, order flow, regime detection, Hawkes processes, and AMM state, composed through role-based signal composition (Primary/Confirmation/Filter/Observer).

Prediction Engine — Interacting Multiple Model (IMM) with parallel Kalman filters per regime, Rao-Blackwellized Particle Filter for regime uncertainty, conformal prediction with 95% coverage guarantee, and online expert aggregation via weighted hedge algorithm.

Risk Management — Adaptive stop-loss/take-profit with confirmation windows, regime-aware position sizing, per-factor circuit breakers, portfolio drawdown breakers, and Kelly criterion optimal sizing.

Execution — Modular pipeline (OrderSizer → SlippageEstimator → ProfitabilityFilter → ExecutionBackend → PostTradeValidator) with MEV-protected Jito bundles, cross-DEX arbitrage scanning, and paper trading with configurable slippage models.

Self-Improvement — Prediction accuracy tracking with directional accuracy, MAE, and calibration per factor. Accuracy-weighted composition where better-performing factors gain influence. Nelder-Mead auto-tuning for filter parameters. Per-factor P&L attribution to track which factors actually make money.

Technical Decisions

Every design choice prioritizes physical meaning over statistical fit. State variables map to real-world quantities — velocity is capital flow rate, acceleration is herd intensification, decay is follower exhaustion. The IMM presents separate regime branches with probabilities rather than blending them into meaningless averages. Black-box ML is rejected in favor of methods with clear physical interpretations: IMM, RBPF, Hawkes processes, conformal prediction.

The CIL architecture ensures all business logic is pure — no I/O, no async, no network calls in the 84 core crates. This makes every crate independently testable and benchmarkable. I/O lives at the edges in apps and services. Rust was chosen for its type system, ownership model, and Send + Sync guarantees that eliminate entire bug categories at compile time.

Scale

84 Rust crates, 3 applications, 4 services, 1032 tests, zero clippy warnings. The 5-repo ecosystem includes the monorepo, a Next.js frontend dashboard, a Wallet Monitor service, a Pricing Service, and an MCP server with 98 Claude Code tools. Deployed via Docker Compose with Redis, PostgreSQL, Prometheus, and Grafana for monitoring.