一个高性能、超低延迟的交易终端和基于 AI 的守护程序,完全由 Rust 构建。
RustFinance Terminal, also called RustForge, is an open-source Rust trading terminal for market-data ingestion, execution research, quantitative risk controls, compliance checks, and terminal dashboards.
cargo run -p tui --releaseUSE_MOCK=1 cargo run -p daemon --releaseUSE_MOCK=0 SYMBOLS_CRYPTO=BTCUSDT,ETHUSDT cargo run -p daemon --release — Binance's public
WebSocket needs no credentials, so this is the shortest path to real market data flowing through the full pipelineSafety: this project is research and open-source infrastructure. It is not financial advice, not a broker, and not a guarantee of live-trading readiness. Use paper trading and independent review before connecting real capital.
https://github.com/user-attachments/assets/c769b2c2-cfa0-44bd-a261-99786ea653e1
RustForge is an institutional-grade AI trading terminal built in pure Rust. It combines real-time multi-exchange market data, Claude-powered AI analysis, quantitative risk management, prediction market trading, and a full TUI dashboard — all in a single binary with nanosecond-precision timestamps and sub-millisecond latency.
v0.4 — 2026 Quant Alpha Library: Multi-level Microprice (MLOFI), Adverse Selection Detection, Regime-Conditioned Quoting, Kelly+Bayesian Sizing, Alpha Health Monitor, IC-Weighted Composite Signals, Enhanced Avellaneda-Stoikov Quoting Engine, Almgren-Chriss Optimal Execution, Live Binance WebSocket Candlestick Feed, and WebSocket Gap Detection Engine. 82+ unit tests passing on Rust 1.95.0.
| Feature | Detail |
|---|---|
| Language | Pure Rust |
| Interface | Full TUI Dashboard (Ratatui, 6 screens) |
| AI Integration | Claude-powered Dexter Analyst |
| Execution Algorithms | TWAP, VWAP, Iceberg, POV, Almgren-Chriss Optimal Execution |
| Market Making | Enhanced Avellaneda-Stoikov with regime gating, VPIN toxicity, OFI skew |
| Microstructure | Multi-level MLOFI, OFI, Microprice, Kyle's Lambda, VPIN, Amihud, Lee-Ready |
| Smart Order Router | Multi-venue scoring (fill rate, latency, fees, impact) |
| Alpha Signals | Toxicity detection, regime classifier, IC-weighted composite, alpha health |
| Position Sizing | Quarter-Kelly with Bayesian shrinkage, conviction scaling |
| Live Data | Binance WebSocket candlestick feed with gap detection engine |
| Prediction Markets | Polymarket CLOB + cross-platform arbitrage engine |
| Agent Simulation | 100K-agent Rayon-parallel swarm |
| Knowledge Graph | petgraph-backed RAG engine |
| Risk Models | GARCH(1,1) + VaR + Kill Switch + SMP + Regime Detection + Toxicity Gating |
| Timestamp Precision | Nanosecond (UnixNanos) |
| Deterministic Replay | DeterministicClock + SequenceId ordering |
| Regulatory Compliance | SEBI 2026 Algo-ID + OPS threshold + pre-trade checks |
| Fill Simulation | Almgren-Chriss √-impact model + fixed slippage |
| Alpha Monitoring | Rolling IC, Sharpe, hit rate with auto-decay detection |
| FIX Protocol | Production FIX 4.4 parser + NYSE Pillar FIX 4.2 profile |
| Direct Feeds | Nasdaq TotalView-ITCH 5.0 (MoldUDP64/SoupBinTCP), NYSE XDP Integrated (A/B multicast) |
| Native Order Entry | Nasdaq OUCH 4.2, NYSE Pillar Binary Gateway, NYSE Pillar FIX 4.2 |
| Order Book | Level 3 order-by-order, exact integer prices (1e-9 USD), venue-neutral |
| Feed Recovery | MoldUDP64 re-request, Pillar retransmit + refresh, A/B line arbitration, GLIMPSE |
| Market Sources | Nasdaq ITCH, NYSE XDP, Alpaca, Binance, Finnhub, Polymarket, Mock |
| Execution | Nasdaq OUCH, NYSE Pillar (binary + FIX), Alpaca REST, Polymarket CLOB, Paper Trading |
| License | MIT |
38 modular crates, 260+ source files, strict dependency boundaries.
……Based on 18 research papers (2025–2026). 55 unit tests.
…Almgren-Chriss Optimal trajectory: xⱼ = X × sinh(κ(N-j)) / sinh(κN)
Urgency parameter κ = √(λσ²/η), square-root impact model
Presets: liquid_default, aggressive, passive
7 unit tests (TWAP convergence, front-loading, quantity conservation)Native co-location-grade connectivity to both US primary listing venues — the exchanges' own binary protocols, implemented from the published specifications. No vendor SDK, no REST polling. 294 unit tests across four crates.
Full documentation: docs/DIRECT_EXCHANGE_CONNECTIVITY.md
| Nasdaq (Carteret, NJ) | NYSE / ICE Pillar (Mahwah, NJ) | |
|---|---|---|
| Market data | TotalView-ITCH 5.0 — all 22 message types | XDP Integrated Feed — types 100–114 + 223 |
| Transport | MoldUDP64 multicast · SoupBinTCP 3.00 | UDP multicast, A/B line arbitration |
| Recovery | Re-request server · GLIMPSE snapshot | Pillar Request Server — retransmit + refresh |
| Order entry | OUCH 4.2 over SoupBinTCP | Pillar Binary Gateway · Pillar FIX 4.2 |
| Byte order | Big endian, space-padded | Little endian, NUL-padded |
exchange-core Wire primitives · exact fixed-point Price · L3 order book · gap tracker · tick-to-trade latency
├─ nasdaq ITCH 5.0 · OUCH 4.2 · SoupBinTCP · MoldUDP64
├─ nyse XDP packet/common/Integrated · Request Server · Pillar Binary · Pillar FIX 4.2
└─ exchange MarketDataSource + ExecutionGateway adapters · config · colo preflight · replayExact prices, never floats — every venue scales prices differently (ITCH 4 decimals, Pillar
gateway 8, XDP a per-symbol PriceScaleCode). All normalise to one i64 at 1e-9 USD, so every
conversion is an exact integer multiply and tick arithmetic stays associative.
Level 3 order book — order-by-order, shared by both venues. An event referencing an unknown
order id reports UnknownOrder and does not mutate the book: on a live feed that means a
dropped packet, and the only correct response is state recovery, never a guess.
Gap detection that refuses to skip — shared sequence tracker classifies every packet (in-order / duplicate / partial overlap / gap), splits wide gaps to respect the venue's request limit, and treats heartbeats as gap evidence since they carry the next-expected sequence. A gap with no configured recovery path ends the session rather than publishing a book with a hole in it.
A/B line arbitration — NYSE's redundant multicast lines share one tracker, so the first copy
wins and the second is a duplicate by construction. ChannelStats reports the first-arrival split
between lines, which is how you find a consistently slower path.
Co-location preflight — measures TCP RTT, multicast join on the intended NIC, monotonic clock
resolution, and CPU budget against a LatencyBudget. A check that cannot run here reports
Skipped, never Pass.
Capture replay — recorded datagrams through the same decoders, book builders and normalisers as the live path, so a book builder can be validated and an incident reproduced without an entitlement.
Fail-closed by design. Nothing here fabricates market data, simulates a session, or defaults a value only an exchange can issue. An unconfigured connector refuses to start and names what it lacks. Encoders exist for round-trip tests and capture tooling only, and are never wired into a feed path.
# 1. Install Rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# 2. Clone
git clone https://github.com/Ashutosh0x/rust-finance.git
cd rust-finance
# 3. Configure
cp .env.example .env
# Edit .env — add your API keys (see Configuration below)
# 4. Build
cargo build --release
# 5. Run (mock mode — no API keys required)
USE_MOCK=1 cargo run -p daemon --release
# 6. Run TUI (separate terminal)
cargo run -p tui --releaseUnixNanos) with monotonic SequenceId orderingRealtimeClock for live trading, DeterministicClock for backtestingEnvelope wrapping every system eventPriceScaleCode applied before any price is interpreted — messages that arrive ahead of their mapping are counted and dropped, never decoded at a guessed scaleLastSeqNumgamma-api.polymarket.com)暂无开放 Issues,或尚未同步最近议题。