barter-data-rs icon indicating copy to clipboard operation
barter-data-rs copied to clipboard

feat: Coinbase Full Orderbook MVP

Open Skelectric opened this issue 2 years ago • 1 comments

  • Added full orderbook implementation with hooks to Coinbase
  • Added working example to examples folder

Skelectric avatar Oct 17 '22 21:10 Skelectric

Per request, pasting implementation summary of orderbook here, for convenience.

//! # Features
//! - No unsafe rust used
//! - Vector-based bid and ask books with a VecDeque for each price level
//! - Iteration over entire book, insert/remove/update, liquidity curve (see levels method),
//! order refs/muts by id, and more
//! - Crude sequence-checking: messages with a stale sequence are ignored. Skipped sequences
//! emit a warning.
//! - Optional simple factor-based outlier filter. choose a % deviation bound from best bid/ask and
//! orderbook will skip processing orders with prices outside the bound. This is especially useful for
//! exchanges which constantly broadcast extreme limit orders that are unlikely to ever fill - these
//! orders only serve to slow down vector-based books.
//!
//! # Time Complexity
//! - order deque insertion: O(logN+N) - find insert position via binary search and insert into vector
//! - order insertion: O(logN+M) - find deque via binary search and then push order to the back
//! - order removal: O(logN+M) - find deque via binary search and then remove order
//!     - if deque is left empty, removal is an additional O(N) operation
//! - order retrieval/update: O(logN+M) - find deque via binary search, then find order via linear search
//!
//! # Todos
//! - Consider ways to reduce time complexity of orderbook operations while retaining cache-friendliness.
//! - Simple stats tracking - generalize this and add more stats to track.
//! - Add option to swap in other data structures as desired.

Skelectric avatar Nov 15 '22 19:11 Skelectric

Closing this now we've migrated this repo to the new barter-rs monorepo: https://github.com/barter-rs/barter-rs

Feel free to open on the new mono-repo!

I'm going to be much more active now!

just-a-stream avatar Jul 12 '24 20:07 just-a-stream