Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Coinbase Full Orderbook MVP #10

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from

Conversation

Skelectric
Copy link

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

- Added working example "coinbase_orderbook_l3_stream.rs"
- Added full orderbook implementation with hooks to Coinbase
@c10k-cc c10k-cc added the pr::feat Pull request whose primary topic is `feat` (see `Git Conventional Commits` in `CONTRIBUTING.md`) label Oct 18, 2022
@c10k-cc c10k-cc self-assigned this Oct 18, 2022
- Added tracing subscriber to dev-dependencies and example
- Example now displays matches from full channel
- Added coinbase-specific find_instrument_flexible function that allows for trades to be included within an orderbook l3 event subscription
- Moved OrderType enum to coinbase\model.rs since its main use is for order type deserialization
- Added orderbook time complexity notes
- Started adding orderbook traces
- Renamed Order to LimitOrder
- Introduced new MarketOrder enum
- Introduced new Order enum to distinguish between Limit and Market orders
- Added stream dumper to example
- Finished graceful shutdown
- Added sequence to PublicTrade
- Refactored orderbook processing to process market events instead of orderbook events, allowing processing of public trades, and market validation
- Refactored orderbook's sequence validation
- Separated update_sequence_and_stats into update_sequence and update_stats
- Added market validation
- Implemented serializer for AtomicOrder's floats
- Refactored snapshot fetch into separate function
- Added streaming from local stream dumps
- Refactored stream dumping
@Skelectric Skelectric closed this Oct 25, 2022
- Refactored how orderbook handles incoming orders that don't affect orderbook's state, using OrderState enum
- Cleaned up and refactored example
- Orderbook now tracks received order ids
@Skelectric Skelectric reopened this Oct 25, 2022
@Skelectric
Copy link
Author

Skelectric commented Nov 15, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr::feat Pull request whose primary topic is `feat` (see `Git Conventional Commits` in `CONTRIBUTING.md`)
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

2 participants