bat-markets
bat-markets is a futures-first, headless Rust exchange engine for Binance USD-M
and Bybit USDT linear futures.
The crate focuses on a narrow production surface:
- typed market, account, position, trade, stream, and order-entry APIs;
- decimal domain types instead of
f64in public/state contracts; - fixture-backed native adapters for Binance and Bybit payloads;
- shared public/private websocket lanes with typed watchers;
- explicit command acknowledgements, lifecycle events, and
UnknownExecutionrecovery semantics; - in-memory state, health, and diagnostics snapshots for live runners.
Install
[]
= "0.1"
Default features enable Binance, Bybit, and private trading surfaces:
[]
= { = "0.1", = false, = ["binance"] }
Feature flags:
binance: enable the Binance USD-M linear futures adapter.bybit: enable the Bybit USDT linear futures adapter.private-trading: expose authenticated order-entry and private account flows.metrics: reserved for metrics integrations.serde: reserved for serde-facing API expansion.
Quick Start
use ;
Live REST/WS clients are async and read credentials from environment variables by default:
use ;
async
Safety Model
bat-markets is intentionally conservative:
- live credentials are supplied through environment variables or explicit config;
- secrets are never required for public market reads;
- live write tests are opt-in and environment-gated;
- exchange-specific semantics remain visible through
native()instead of being hidden behind fake cross-venue guarantees; - uncertain command outcomes stay explicit until local state or reconciliation evidence resolves them.
Workspace Crates
bat-markets: public facade and ergonomic API.bat-markets-core: domain contracts, error taxonomy, state engine, and adapter traits.bat-markets-binance: Binance USD-M linear futures adapter.bat-markets-bybit: Bybit USDT linear futures adapter.bat-markets-testing: unpublished workspace-only fixtures, smoke helpers, and benches.
Publishing is automated from the protected GitHub Actions environment
crates-io. Runtime crates are published in dependency order:
Store crates.io tokens only as GitHub Actions secrets or local environment variables. Never commit tokens to the repository.
Development
Run the full local quality gate:
Useful focused checks: