Skip to main content

rustkernel_orderbook/
lib.rs

1//! # RustKernel Order Matching
2//!
3//! GPU-accelerated order book matching for HFT.
4//!
5//! ## Kernels
6//! - `OrderMatchingEngine` - Price-time priority matching (<10μs P99)
7//!
8//! ## Features
9//! - Price-time priority matching
10//! - Support for limit and market orders
11//! - Self-trade prevention
12//! - Order book management with L2 snapshots
13//! - Batch order processing
14
15#![warn(missing_docs)]
16
17pub mod matching;
18pub mod messages;
19pub mod ring_messages;
20pub mod types;
21
22/// Prelude for convenient imports.
23pub mod prelude {
24    pub use crate::matching::*;
25    pub use crate::messages::*;
26    pub use crate::types::*;
27}
28
29// Re-export main kernel
30pub use matching::OrderMatchingEngine;
31
32// Re-export key types
33pub use types::{
34    EngineConfig, L2Snapshot, MatchResult, Order, OrderBook, OrderStatus, OrderType, Price,
35    PriceLevel, Quantity, Side, TimeInForce, Trade,
36};
37
38/// Register all order matching kernels with a registry.
39pub fn register_all(
40    registry: &rustkernel_core::registry::KernelRegistry,
41) -> rustkernel_core::error::Result<()> {
42    tracing::info!("Registering order matching kernels");
43
44    // Order matching kernel (1) - Ring (also implements BatchKernel for multiple types)
45    registry.register_ring_metadata_from(matching::OrderMatchingEngine::new)?;
46
47    tracing::info!("Registered 1 order matching kernel");
48    Ok(())
49}
50
51#[cfg(test)]
52mod tests {
53    use super::*;
54    use rustkernel_core::registry::KernelRegistry;
55
56    #[test]
57    fn test_register_all() {
58        let registry = KernelRegistry::new();
59        register_all(&registry).expect("Failed to register orderbook kernels");
60        assert_eq!(registry.total_count(), 1);
61    }
62}