ExNet is a Rust trading and data pipeline for crypto exchange order books. It ingests live or replayed data, builds normalized state for ML, can generate datasets, and runs agents that drive paper or live execution.
- DataSource emits raw lines (file replay or live stream).
- EventSource parses those lines into typed messages (orders, trades, candles).
- Environment aggregates messages into a rolling State and emits normalized snapshots.
- Agent evaluates a model and emits Actions.
- Trader/Broker executes paper or live orders and tracks metrics.
src/Rust core (agents, environments, exchange clients, traders)configs/Example TOML configs for runs, training, and dataset generationdata/,research/,test/Data and experiments
cargo build
cargo run -- configs/ds_series_gen_gemini_bchusd_file.toml runThe run subcommand is the default if you omit it.
Configs are TOML files that define the data source, environment, agent, and trader. See configs/ for
examples. For any config that requires API credentials, copy an example into a local file and keep it
out of git:
# configs/trader_gemini_btcusd.local.toml
client = { Gemini = { server = "api.gemini.com", api_key = "<GEMINI_API_KEY>", api_secret = "<GEMINI_API_SECRET>" } }Local overrides are ignored by .gitignore (for example, configs/*.local.toml).
- HDF5 library (used by dataset generation and replay tools).
- libtorch 1.11 (used by the
tchcrate for model inference/training). - Rust
tchcomes from a forked (updated) repo (akolishchak/tch-rs), pinned to libtorch 1.11 C++11 ABI.
GEMINI_API_KEY/GEMINI_API_SECRETBINANCE_API_KEY/BINANCE_API_SECRETTELEGRAM_BOT_TOKEN/TELEGRAM_CHAT_ID
- Supervised learning models live in
src/sl_train*.pyand are trained with PyTorch on HDF5 datasets. - Inputs are order book + trade tensors (
books,trades) with discrete action labels (actions), produced by the dataset generators (EnvDatasetSL). - The model family is a stack of 1D/2D convs with Fixup-style residual blocks (see
FixupBasicBlockinsrc/sl_train10.pyand related scripts). - Training uses cross-entropy on action classes, writes checkpoints to
models/, and can export TorchScript.ptmodels for Rust inference viatch::CModule.
- The Rust side uses
tchpinned to libtorch 1.11.0 (C++11 ABI); CPU builds are the default. - To build against CUDA, install the matching libtorch 1.11.0 + cu112 archive, then set
TORCH_CUDA_VERSION=112(orLIBTORCH=/path/to/libtorchand updateLD_LIBRARY_PATH) before runningcargo build. - Ensure your CUDA driver/runtime is compatible with CUDA 11.2; otherwise the build will fall back to CPU or fail to link.