Alpha Engine
BuiltSignature capability
Risk metrics (Sharpe, Sortino, max-drawdown, VaR, Kelly) are implemented twice, once in pure Elixir and once as matching Rust NIFs via Rustler, so the hot path can drop to native code without changing the calling contract.
What it is
It is a three-app Elixir umbrella. alpha_core holds the trading domain: a GenStateMachine bot lifecycle with running, paused, error and emergency states, a strategy executor for momentum, mean-reversion and AI-signal strategies, portfolio, position and order managers, and a risk manager. alpha_kraken is the exchange adapter, with a Kraken WebSocket feed over websockex, a REST client, a rate limiter and an order book. alpha_web is a Phoenix 1.7 dashboard with LiveDashboard, nine controllers and Phoenix Channels. Components communicate over Phoenix PubSub, so the strategy executor subscribes to market:signals and bot:status rather than being wired in directly. Performance-sensitive math lives in three Rust crates exposed as NIFs through Rustler, each with a pure-Elixir fallback. Persistence is Ecto and Postgres. It is a substantial, well-structured prototype, not the live money system.
Highlights
- Phoenix umbrella with 3 OTP apps, 39 Elixir modules (~5,400 LOC) plus 3 Rust NIF crates, packaged as one alpha_engine release running alpha_core, alpha_web and alpha_kraken as permanent applications
- Risk engine written twice for a native fast-path: a Rust risk_calc Rustler NIF and a pure-Elixir mirror both implement Sharpe, Sortino, max-drawdown, historical VaR and Kelly with matching logic
- Bot control is a real GenStateMachine with seven states (stopped, starting, running, paused, stopping, error, emergency) tracking trades_today and daily_pnl, not an ad-hoc flag
- Decoupled by Phoenix PubSub: the strategy executor reacts to market:signals and bot:status topics instead of direct calls, so feeds, strategy and UI stay independent
- Kraken adapter is a full exchange layer: WebSocket market data (wss://ws.kraken.com) via websockex, REST client, dedicated rate limiter and live order book, with kraken_executor and market_data as separate Rust crates
- Honest status: no test suite and last commit Dec 2025, so it reads as a serious architecture prototype rather than a battle-tested live system
Tech · Elixir, Erlang/OTP, Phoenix 1.7, Phoenix LiveView/LiveDashboard, Phoenix PubSub, GenStateMachine, Ecto, PostgreSQL, Rust, Rustler NIFs, websockex, Kraken API