Skip to content

akolishchak/exnet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

180 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

exnet

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.

How it works

  1. DataSource emits raw lines (file replay or live stream).
  2. EventSource parses those lines into typed messages (orders, trades, candles).
  3. Environment aggregates messages into a rolling State and emits normalized snapshots.
  4. Agent evaluates a model and emits Actions.
  5. Trader/Broker executes paper or live orders and tracks metrics.

Layout

  • src/ Rust core (agents, environments, exchange clients, traders)
  • configs/ Example TOML configs for runs, training, and dataset generation
  • data/, research/, test/ Data and experiments

Build and run

cargo build
cargo run -- configs/ds_series_gen_gemini_bchusd_file.toml run

The run subcommand is the default if you omit it.

Configs

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).

Dependencies

  • HDF5 library (used by dataset generation and replay tools).
  • libtorch 1.11 (used by the tch crate for model inference/training).
  • Rust tch comes from a forked (updated) repo (akolishchak/tch-rs), pinned to libtorch 1.11 C++11 ABI.

Environment variables

  • GEMINI_API_KEY / GEMINI_API_SECRET
  • BINANCE_API_KEY / BINANCE_API_SECRET
  • TELEGRAM_BOT_TOKEN / TELEGRAM_CHAT_ID

ML

  • Supervised learning models live in src/sl_train*.py and 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 FixupBasicBlock in src/sl_train10.py and related scripts).
  • Training uses cross-entropy on action classes, writes checkpoints to models/, and can export TorchScript .pt models for Rust inference via tch::CModule.

CUDA support

  • The Rust side uses tch pinned 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 (or LIBTORCH=/path/to/libtorch and update LD_LIBRARY_PATH) before running cargo build.
  • Ensure your CUDA driver/runtime is compatible with CUDA 11.2; otherwise the build will fall back to CPU or fail to link.

About

Rust crypto order‑book trading pipeline

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published