A Rust Service that Subscribes to the L2 Order Book Updates for a user defined instrument and maintains an in-memory representation of the order book.
The repository follows a Cargo workspace structure. There are 3 crates defined
- oba-cli - A CLI tool to interact with
oba-server. - oba-client - An HTTP Client to interact with
oba-server - oba-server - A server, which interacts with
bitstampto subscribe to order books for specifiedinstrumentwithcertaindepth.
Both oba-cli and oba-server are binaries, whereas oba-client is a library.
In order, to spin up oba-server, a host and port need to be defined. Following two environment variables are needed
OBA_HOSTOBA_PORT
If not specified, by default the host would be 127.0.0.1 and port 3000
Please note these are also needed by oba-client to identify where to connect to the server, same defaults apply there as well.
The following are mandatory steps that need to be followed, if you want to interact with the tool.
-
Spin up OBA Server. This can be done in multiple ways
cd $HOME/order-book-adapater && cargo run --bin oba-servercd $HOME/order-book-adapter && cargo build && target/debug/oba-server
This would sping up the OBA Server. It would be listening on
OBA_HOSTandOBA_PORTif defined. If not defined, by default it will use127.0.0.1and3000.
All of the commands have two options on how they can be invoked.
cd $HOME/order-book-adapter && cargo run --bin oba-cli {command} {flags}cd $HOME/order-book-adapter && cargo build && target/debug/oba-cli {command} {flags}
Run the following command with these required flags to subscribe.
target/debug/oba-cli subscribe --instrument btcusd --depth 50
Run the following command with these required flag(s) to unsubscribe.
target/debug/oba-cli unsubscribe --instrument btcusd
Run the following command with these required flag(s) to get order book.
target/debug/oba-cli get-order-book --instrument btcusd
Run the following command with these required flag(s) to best bid.
target/debug/oba-cli best-bid --instrument btcusd
Run the following command with these required flag(s) to best bid.
target/debug/oba-cli best-ask --instrument btcusd
