Expand description
A synchronous, high-performance Central Limit Order Book implementation in Rust featuring an in-memory architecture with zero-cost abstractions and type-safe financial primitives for ultra-low latency trading applications.
§Usage
use clob_sync::prelude::*;
use std::str::FromStr;
fn main() -> Result<()> {
let symbol = Symbol::from("BTC-USD");
let mut book = InMemoryOrderBookFactory::create_order_book(symbol);
let sell_order = Order::new(
OrderType::Limit(Price::try_from("50000.50").unwrap()),
Quantity::try_from("100.5").unwrap(),
OrderSide::Sell,
Symbol::from("BTC-USD"),
);
let sell_exec = book.execute(&sell_order)?;
assert!(matches!(sell_exec, Executions::AllocatedNoExecutions));
let buy_order = Order::new(
OrderType::Limit(Price::try_from("50000.75").unwrap()),
Quantity::try_from("75.25").unwrap(),
OrderSide::Buy,
Symbol::from("BTC-USD"),
);
let buy_exec = book.execute(&buy_order)?;
assert!(matches!(buy_exec, Executions::Executed(_)));
Ok(())
}Re-exports§
pub use order::*;pub use order_book::*;
Modules§
Macros§
- f
- Creates a
Stringusing interpolation of runtime expressions. - fatal
- Logs an error message and panics with the same message.
Enums§
- Error
- Errors that can occur during order book operations.