Skip to content

A Rust program that connects to multiple exchanges (Binance and Bitstamp websocket servers specifically) and publishes a live merged order book (top 10 asks and bids along with the spread) using gRPC.

Notifications You must be signed in to change notification settings

gprs1809/orderbook_challenge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

orderbook_challenge

A Rust program that connects to multiple exchanges (Binance and Bitstamp websocket servers specifically) and publishes a live merged order book (top 10 asks and bids along with the spread) using gRPC.

The challenge statement was to create a mini Rust project that:

  1. connects to two exchanges' websocket feeds at the same time,
  2. pulls order books, using these streaming connections, for a given traded pair of currencies (configurable), from each exchange,
  3. merges and sorts the order books to create a combined order book,
  4. from the combined book, publishes the spread, top ten bids, and top ten asks, as a stream, through a gRPC server.

The code compiles into 2 binaries called grpc_orderbook_server and grpc_orderbook_client, both specified in the cargo.toml file. To execute the program after compiling with default options, run the following from the command line:

cargo run --bin grpc_orderbook_server

While the server runs, open a new command line window and run the following:

cargo run --bin grpc_orderbook_client

This executes the program with the default currency pair (etcbtc) and by default merges both streams from binance and bitstamp. To use a different currency pair, run:

cargo run --bin grpc_orderbook_server -- --currency-pair ethusd

To skip order details from either Binance or Bitstamp, use the skip-binance or skip-bitstamp flags:

cargo run --bin grpc_orderbook_server -- --currency-pair ethusd --skip-binance

The results that a grpc clients would see on their command line would look something like below:

image

I have to mention that there are several resources online like the Rust Documentation, Rust lang book, some blogs and some code respositories online that have been incredibly useful for me to complete this challenge. My understanding of the Rust language has also improved several folds with this challenge.

About

A Rust program that connects to multiple exchanges (Binance and Bitstamp websocket servers specifically) and publishes a live merged order book (top 10 asks and bids along with the spread) using gRPC.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages