Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

crypto-latency-probe

A small Rust CLI for comparing Binance USD-M network latency from different machines or cloud locations.

The probe is intentionally narrow:

  • Exchange: Binance USD-M Futures
  • Symbol: BTCUSDT
  • WebSocket: btcusdt@bookTicker
  • Signed REST probe: POST /fapi/v1/order/test
  • Output percentiles: p50_us, p95_us, and p99_us

It never places a real order and does not contain strategy logic.

What is measured

  • time_sync_rtt: GET /fapi/v1/time round-trip, including response decoding. The samples calibrate the local clock against Binance.
  • book_ticker: Binance event time to local receipt time, adjusted by the calibrated clock offset.
  • order_test: local request preparation, parameter serialization, HMAC signing, HTTP round-trip, and response handling for POST /fapi/v1/order/test.

All summaries use microseconds. Binance WebSocket event timestamps and signed-request timestamps remain millisecond-based, so microsecond output provides consistent arithmetic and aggregation, not microsecond source timestamp accuracy.

Run with Cargo

Public market-data mode does not require credentials:

cargo run --release -- --duration-secs 95 --disable-order-test

To include the signed order-test probe:

export BINANCE_API_KEY=...
export BINANCE_API_SECRET=...

cargo run --release -- --duration-secs 95

The default duration is 95 seconds and includes 30 initial server-time samples. Keep only final summaries with:

RUST_LOG='summary=info,crypto_latency_probe=warn' \
  cargo run --release -- --duration-secs 95 --disable-order-test

Run with Docker

Build the image:

docker build -t crypto-latency-probe .

Run without Binance credentials:

docker run --rm crypto-latency-probe \
  --duration-secs 95 \
  --disable-order-test

Run all probes with a local .env file:

docker run --rm --env-file .env crypto-latency-probe \
  --duration-secs 95

For a Linux amd64 image on an arm64 development machine:

docker buildx build --platform linux/amd64 --load \
  -t crypto-latency-probe:linux-amd64 .

Example results

An anonymized two-location comparison is included to show the output and comparison method without publishing server identifiers.

Development

cargo fmt --check
cargo test --locked
cargo clippy --locked --all-targets -- -D warnings
cargo build --release --locked

Requires Rust 1.85 or newer.

License

LGPL-3.0-or-later.

About

Measure Binance USD-M WebSocket and signed REST latency in microseconds.

Resources

Stars

46 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages