Skip to main content

market_maker_rs/
lib.rs

1//! # Market Making Library
2//!
3//! A comprehensive Rust library implementing quantitative market making strategies based on
4//! the Avellaneda-Stoikov model and extensions. This library provides production-ready
5//! components for building automated market making systems for financial markets.
6//!
7//! ## Overview
8//!
9//! Market making is the practice of simultaneously providing buy (bid) and sell (ask) quotes
10//! in a financial market. The market maker profits from the bid-ask spread while providing
11//! liquidity to the market.
12//!
13//! ### Key Challenges Addressed
14//!
15//! - **Inventory Risk**: Dynamic quote skewing based on position
16//! - **Adverse Selection**: Order flow toxicity detection with VPIN
17//! - **Optimal Pricing**: Stochastic control theory for spread optimization
18//! - **Risk Management**: Circuit breakers, drawdown limits, and position controls
19//! - **Multi-Asset**: Correlation-aware portfolio risk management
20//! - **Options Market Making**: Greeks-aware quoting with delta hedging
21//!
22//! ## Features
23//!
24//! ### Strategy Models
25//!
26//! - **Avellaneda-Stoikov**: Classic optimal market making with reservation price
27//! - **GLFT Extension**: Guéant-Lehalle-Fernandez-Tapia with terminal penalties
28//! - **Grid Trading**: Multi-level order placement with geometric/arithmetic spacing
29//! - **Adaptive Spread**: Dynamic spread adjustment based on order book imbalance
30//! - **Depth-Based Offering**: Size adjustment based on market depth
31//!
32//! ### Risk Management
33//!
34//! - **Position Limits**: Maximum inventory size controls
35//! - **Notional Limits**: Maximum value at risk
36//! - **Circuit Breakers**: Automatic trading halts on adverse conditions
37//! - **Drawdown Tracking**: Peak-to-trough monitoring with configurable limits
38//! - **Alert System**: Configurable alerts for critical events
39//! - **Portfolio Risk**: Correlation matrix and multi-asset VaR
40//!
41//! ### Analytics
42//!
43//! - **Order Flow Analysis**: Trade flow imbalance and toxicity metrics
44//! - **VPIN Calculator**: Volume-synchronized probability of informed trading
45//! - **Order Intensity Estimation**: Fill rate modeling for parameter calibration
46//! - **Live Metrics**: Real-time operational metrics with atomic counters
47//! - **Prometheus Export**: Optional metrics export with Grafana dashboard
48//!
49//! ### Backtesting
50//!
51//! - **Event-Driven Engine**: Tick-by-tick simulation
52//! - **Fill Models**: Immediate, queue position, probabilistic, market impact
53//! - **Performance Metrics**: Sharpe, Sortino, Calmar, max drawdown, profit factor
54//! - **Slippage Models**: Fixed, percentage, volatility-based
55//!
56//! ### Execution
57//!
58//! - **Exchange Connector Trait**: Abstract interface for any exchange
59//! - **Order Manager**: Order lifecycle management with state tracking
60//! - **Latency Tracking**: Histogram-based latency measurement
61//! - **Mock Connector**: Testing without real exchange connectivity
62//! - **OrderBook-rs Connector**: Integration with lock-free order book
63//!
64//! ### Options Market Making (Feature: `options`)
65//!
66//! - **Greeks Calculation**: Delta, gamma, theta, vega, rho via OptionStratLib
67//! - **Portfolio Greeks**: Aggregation across multiple positions
68//! - **Greeks-Aware Quoting**: Spread adjustment based on gamma exposure
69//! - **Delta Hedging**: Automatic hedge order generation
70//! - **Risk Management**: Greeks-based limits and circuit breakers
71//! - **Auto-Hedging**: Configurable triggers for delta neutralization
72//!
73//! ### Option Chain Integration (Feature: `chain`)
74//!
75//! - **Multi-Strike Quoting**: Quote all strikes in an expiration
76//! - **Chain-Level Risk**: Aggregate Greeks across the chain
77//! - **ATM Detection**: Automatic spread adjustment for ATM options
78//! - **Chain Risk Manager**: Chain-wide limits and hedging
79//!
80//! ### Parameter Calibration
81//!
82//! - **Risk Aversion (γ)**: Calibration from inventory half-life
83//! - **Order Intensity (k)**: Estimation from historical fill rates
84//! - **Volatility Regimes**: Automatic detection and parameter adjustment
85//!
86//! ## The Avellaneda-Stoikov Model
87//!
88//! The Avellaneda-Stoikov model (2008) solves the optimal market making problem using
89//! stochastic control theory. Key formulas:
90//!
91//! ### Reservation Price
92//! ```text
93//! r = s - q × γ × σ² × (T - t)
94//! ```
95//!
96//! ### Optimal Spread
97//! ```text
98//! spread = γ × σ² × (T - t) + (2/γ) × ln(1 + γ/k)
99//! ```
100//!
101//! Where:
102//! - `s`: Mid price
103//! - `q`: Current inventory
104//! - `γ`: Risk aversion parameter
105//! - `σ`: Volatility
106//! - `T - t`: Time remaining
107//! - `k`: Order arrival intensity
108//!
109//! ## Modules
110//!
111//! - [`strategy`]: Quote generation algorithms (A-S, GLFT, Grid, Adaptive)
112//! - [`position`]: Inventory tracking and PnL management
113//! - [`market_state`]: Market data and volatility estimation
114//! - [`risk`]: Limits, circuit breakers, alerts, and portfolio risk
115//! - [`analytics`]: Order flow, VPIN, intensity estimation, live metrics
116//! - [`execution`]: Exchange connectivity, order management, latency tracking
117//! - [`backtest`]: Historical simulation with fill models and metrics
118//! - [`types`]: Common types, decimals, and error definitions
119//! - [`prelude`]: Convenient re-exports of commonly used types
120//! - `options`: Options pricing, Greeks, and market making (feature: `options`)
121//! - `chain`: Option chain integration and multi-strike quoting (feature: `chain`)
122//! - `api`: REST/WebSocket API layer (feature: `api`)
123//! - `persistence`: Data persistence layer (feature: `persistence`)
124//! - `multi_underlying`: Multi-asset management (feature: `multi-underlying`)
125//! - `events`: Event broadcasting system (feature: `events`)
126//! - `data_feeds`: Real-time market data feeds (feature: `data-feeds`)
127//!
128//! ## Quick Start
129//!
130//! ```rust
131//! use market_maker_rs::prelude::*;
132//!
133//! // Calculate optimal quotes using Avellaneda-Stoikov
134//! let mid_price = dec!(100.0);
135//! let inventory = dec!(5.0);
136//! let risk_aversion = dec!(0.5);    // γ
137//! let volatility = dec!(0.02);
138//! let time_to_terminal_ms = 3600_000; // 1 hour
139//! let order_intensity = dec!(1.5);  // k
140//!
141//! let (bid, ask) = market_maker_rs::strategy::avellaneda_stoikov::calculate_optimal_quotes(
142//!     mid_price,
143//!     inventory,
144//!     risk_aversion,
145//!     volatility,
146//!     time_to_terminal_ms,
147//!     order_intensity,
148//! ).unwrap();
149//!
150//! println!("Bid: {}, Ask: {}", bid, ask);
151//! ```
152//!
153//! ## Feature Flags
154//!
155//! - `prometheus`: Enable Prometheus metrics export (adds `prometheus`, `hyper`, `tokio` dependencies)
156//! - `serde`: Enable serialization/deserialization for all types
157//! - `options`: Enable OptionStratLib integration for options pricing and Greeks calculation
158//! - `chain`: Enable Option-Chain-OrderBook integration (includes `options`)
159//! - `api`: Enable REST/WebSocket API layer with OpenAPI documentation
160//! - `persistence`: Enable persistence layer for market maker data
161//! - `multi-underlying`: Enable multi-asset management with correlation tracking
162//! - `events`: Enable event broadcasting system for real-time updates
163//! - `data-feeds`: Enable real-time market data feed abstractions
164//!
165//! ## Examples
166//!
167//! ### Risk Management
168//!
169//! ```rust
170//! use market_maker_rs::prelude::*;
171//!
172//! // Set up position limits
173//! let limits = RiskLimits::new(
174//!     dec!(100.0),   // max 100 units position
175//!     dec!(10000.0), // max $10,000 notional
176//!     dec!(0.5),     // 50% scaling factor
177//! ).unwrap();
178//!
179//! // Check if order is allowed
180//! let allowed = limits.check_order(dec!(50.0), dec!(10.0), dec!(100.0)).unwrap();
181//!
182//! // Circuit breaker for automatic trading halts
183//! let config = CircuitBreakerConfig::new(
184//!     dec!(1000.0), // max daily loss
185//!     dec!(0.05),   // max loss per trade (5%)
186//!     5,            // max consecutive losses
187//!     dec!(0.10),   // max drawdown (10%)
188//!     300_000,      // cooldown period (5 min)
189//!     60_000,       // loss window (1 min)
190//! ).unwrap();
191//! let breaker = CircuitBreaker::new(config);
192//! ```
193//!
194//! ### Backtesting
195//!
196//! ```rust,ignore
197//! use market_maker_rs::prelude::*;
198//!
199//! // Configure backtest
200//! let config = BacktestConfig::default()
201//!     .with_initial_capital(dec!(100000.0))
202//!     .with_fee_rate(dec!(0.001))
203//!     .with_slippage(SlippageModel::Fixed(dec!(0.01)));
204//!
205//! // Run backtest with your strategy
206//! let mut engine = BacktestEngine::new(config, strategy, data_source);
207//! let result = engine.run();
208//!
209//! println!("Net PnL: {}", result.net_pnl);
210//! println!("Sharpe Ratio: {:?}", result.sharpe_ratio);
211//! println!("Max Drawdown: {}", result.max_drawdown);
212//! ```
213//!
214//! ### Portfolio Risk
215//!
216//! ```rust
217//! use market_maker_rs::risk::portfolio::*;
218//! use market_maker_rs::dec;
219//!
220//! // Create correlation matrix
221//! let btc = AssetId::new("BTC");
222//! let eth = AssetId::new("ETH");
223//! let mut matrix = CorrelationMatrix::new(vec![btc.clone(), eth.clone()]);
224//! matrix.set_correlation(&btc, &eth, dec!(0.8)).unwrap();
225//!
226//! // Calculate portfolio risk
227//! let mut portfolio = PortfolioPosition::new();
228//! portfolio.set_position(btc, dec!(1.0), dec!(0.05));
229//! portfolio.set_position(eth, dec!(10.0), dec!(0.08));
230//!
231//! let calculator = PortfolioRiskCalculator::new(matrix);
232//! let vol = calculator.portfolio_volatility(&portfolio).unwrap();
233//! ```
234//!
235//! ### Options Greeks (Feature: `options`)
236//!
237//! ```rust,ignore
238//! use market_maker_rs::options::{OptionsAdapter, PortfolioGreeks, PositionGreeks};
239//! use optionstratlib::model::option::Options;
240//!
241//! // Calculate Greeks for an option
242//! let greeks = OptionsAdapter::calculate_greeks(&option).unwrap();
243//! println!("Delta: {}, Gamma: {}", greeks.delta, greeks.gamma);
244//!
245//! // Aggregate portfolio Greeks
246//! let mut portfolio = PortfolioGreeks::new();
247//! portfolio.add(&greeks, dec!(10.0)); // 10 contracts
248//!
249//! // Check delta neutrality
250//! let shares_to_hedge = portfolio.shares_to_hedge(dec!(100.0));
251//! ```
252//!
253//! ### Options Market Making (Feature: `options`)
254//!
255//! ```rust,ignore
256//! use market_maker_rs::options::{
257//!     OptionsMarketMaker, OptionsMarketMakerImpl, OptionsMarketMakerConfig,
258//!     GreeksLimits, PortfolioGreeks,
259//! };
260//!
261//! // Create market maker with Greeks-aware quoting
262//! let config = OptionsMarketMakerConfig::default();
263//! let market_maker = OptionsMarketMakerImpl::new(config);
264//!
265//! // Calculate Greeks-adjusted quotes
266//! let (bid, ask) = market_maker.calculate_greeks_adjusted_quotes(
267//!     &option,
268//!     &portfolio_greeks,
269//!     &risk_limits,
270//! ).unwrap();
271//!
272//! // Get delta hedge suggestions
273//! let hedges = market_maker.calculate_delta_hedge(
274//!     &portfolio_greeks,
275//!     underlying_price,
276//!     "BTC",
277//! ).unwrap();
278//! ```
279//!
280//! ### Greeks Risk Management (Feature: `options`)
281//!
282//! ```rust,ignore
283//! use market_maker_rs::options::{
284//!     GreeksRiskManager, AutoHedgerConfig, GreeksLimits, OrderDecision,
285//! };
286//!
287//! // Create risk manager with auto-hedging
288//! let limits = GreeksLimits::default();
289//! let hedger_config = AutoHedgerConfig::default();
290//! let mut risk_manager = GreeksRiskManager::new("BTC", limits, hedger_config);
291//!
292//! // Check if order is allowed
293//! let decision = risk_manager.check_order(&option_greeks, dec!(10.0));
294//! match decision {
295//!     OrderDecision::Allowed => { /* proceed */ },
296//!     OrderDecision::Scaled { new_size, .. } => { /* use scaled size */ },
297//!     OrderDecision::Rejected { reason } => { /* reject */ },
298//! }
299//!
300//! // Check if hedging is needed
301//! if risk_manager.needs_hedge() {
302//!     let hedge = risk_manager.calculate_hedge_order(underlying_price);
303//! }
304//! ```
305//!
306//! ### Option Chain Market Making (Feature: `chain`)
307//!
308//! ```rust,ignore
309//! use market_maker_rs::chain::{ChainMarketMaker, ChainMarketMakerConfig};
310//! use option_chain_orderbook::orderbook::ExpirationOrderBook;
311//! use std::sync::Arc;
312//!
313//! // Create chain market maker
314//! let chain = Arc::new(ExpirationOrderBook::new("BTC", expiration));
315//! let config = ChainMarketMakerConfig::default();
316//! let mm = ChainMarketMaker::new(chain, config);
317//!
318//! // Refresh all quotes across the chain
319//! let quotes = mm.refresh_all_quotes(underlying_price).unwrap();
320//!
321//! // Check chain risk status
322//! let status = mm.check_chain_risk();
323//! if !status.can_quote() {
324//!     // Stop quoting or hedge
325//! }
326//! ```
327//!
328//! ### Multi-Underlying Management (Feature: `multi-underlying`)
329//!
330//! ```rust,ignore
331//! use market_maker_rs::multi_underlying::{
332//!     MultiUnderlyingManager, UnderlyingConfig, CapitalAllocationStrategy,
333//! };
334//! use market_maker_rs::dec;
335//!
336//! // Create manager with $1M capital
337//! let mut manager = MultiUnderlyingManager::new(dec!(1_000_000))
338//!     .with_allocation_strategy(CapitalAllocationStrategy::RiskParity)
339//!     .with_max_total_delta(dec!(50000));
340//!
341//! // Add underlyings with target weights
342//! manager.add_underlying(UnderlyingConfig::new("BTC", dec!(0.40))).unwrap();
343//! manager.add_underlying(UnderlyingConfig::new("ETH", dec!(0.30))).unwrap();
344//!
345//! // Set correlations
346//! manager.set_correlation("BTC", "ETH", dec!(0.85));
347//!
348//! // Update market data
349//! manager.update_price("BTC", dec!(45000));
350//! manager.update_greeks("BTC", dec!(5.5), dec!(0.02), dec!(1500));
351//!
352//! // Get unified risk view
353//! let risk = manager.get_unified_risk();
354//! println!("Total delta: {}", risk.greeks.total_dollar_delta);
355//!
356//! // Get cross-asset hedge suggestions
357//! let hedges = manager.get_cross_asset_hedges();
358//! ```
359//!
360//! ### Event Broadcasting (Feature: `events`)
361//!
362//! ```rust,ignore
363//! use market_maker_rs::events::{
364//!     EventBroadcaster, EventBroadcasterConfig, EventFilter, EventType,
365//!     MarketMakerEvent, Side,
366//! };
367//! use std::sync::Arc;
368//!
369//! // Create broadcaster
370//! let config = EventBroadcasterConfig::default();
371//! let broadcaster = Arc::new(EventBroadcaster::new(config));
372//!
373//! // Subscribe to all events
374//! let mut all_rx = broadcaster.subscribe();
375//!
376//! // Subscribe with filter (fills only)
377//! let filter = EventFilter::new()
378//!     .with_event_types([EventType::OrderFilled])
379//!     .with_symbols(["BTC".to_string()]);
380//! let mut filtered_rx = broadcaster.subscribe_filtered(filter);
381//!
382//! // Broadcast an event
383//! broadcaster.broadcast(MarketMakerEvent::OrderFilled {
384//!     order_id: "ORD-001".to_string(),
385//!     symbol: "BTC".to_string(),
386//!     instrument: "BTC-PERP".to_string(),
387//!     side: Side::Buy,
388//!     quantity: 10,
389//!     price: 50000,
390//!     fee: 5,
391//!     edge: 100,
392//!     timestamp: 1234567890,
393//! }).await;
394//!
395//! // Get history for reconnection
396//! let missed = broadcaster.get_reconnection_history(last_sequence).await;
397//! ```
398
399#![warn(missing_docs)]
400#![warn(clippy::all)]
401#![deny(unsafe_code)]
402
403// Re-export Decimal for use throughout the library
404pub use rust_decimal::Decimal;
405pub use rust_decimal_macros::dec;
406
407/// Market state module containing market data representations.
408///
409/// Provides:
410/// - Market snapshots with bid/ask prices
411/// - Volatility estimation (simple, EWMA, Parkinson)
412pub mod market_state;
413
414/// Position tracking module for inventory and PnL management.
415///
416/// Provides:
417/// - Inventory position tracking with average cost
418/// - Realized and unrealized PnL calculation
419pub mod position;
420
421/// Strategy module containing quote generation algorithms.
422///
423/// Implements multiple market making strategies:
424/// - **Avellaneda-Stoikov**: Optimal quotes using stochastic control
425/// - **GLFT**: Extension with terminal inventory penalties
426/// - **Grid Trading**: Multi-level orders with configurable spacing
427/// - **Adaptive Spread**: Dynamic adjustment based on order book imbalance
428/// - **Depth-Based**: Size adjustment based on market depth
429/// - **Parameter Calibration**: Tools for γ and k estimation
430pub mod strategy;
431
432/// Risk management module for comprehensive risk control.
433///
434/// Provides:
435/// - **Position Limits**: Maximum inventory size controls
436/// - **Notional Limits**: Maximum value at risk
437/// - **Circuit Breakers**: Automatic trading halts on adverse conditions
438/// - **Drawdown Tracking**: Peak-to-trough monitoring
439/// - **Alert System**: Configurable alerts with multiple handlers
440/// - **Portfolio Risk**: Correlation matrix and multi-asset VaR
441/// - **Hedge Calculator**: Cross-asset hedging ratios
442pub mod risk;
443
444/// Common types and error definitions.
445///
446/// Provides:
447/// - Decimal helper functions (ln, sqrt, powi)
448/// - Error types with thiserror
449/// - Primitive type aliases
450pub mod types;
451
452/// Analytics module for market microstructure analysis.
453///
454/// Provides:
455/// - **Order Flow Analysis**: Trade flow imbalance and toxicity
456/// - **VPIN Calculator**: Volume-synchronized probability of informed trading
457/// - **Order Intensity**: Fill rate estimation for parameter calibration
458/// - **Live Metrics**: Real-time operational metrics with atomic counters
459/// - **Prometheus Export**: Optional metrics server with Grafana dashboard
460pub mod analytics;
461
462/// Execution module for exchange connectivity and order management.
463///
464/// Provides:
465/// - **Exchange Connector**: Abstract trait for any exchange
466/// - **Order Manager**: Order lifecycle with state tracking
467/// - **Latency Tracking**: Histogram-based measurement
468/// - **Mock Connector**: Testing without real connectivity
469pub mod execution;
470
471/// Backtesting module for strategy validation on historical data.
472///
473/// Provides:
474/// - **Event-Driven Engine**: Tick-by-tick simulation
475/// - **Data Sources**: Ticks and OHLCV bars
476/// - **Fill Models**: Immediate, queue position, probabilistic, market impact
477/// - **Performance Metrics**: Sharpe, Sortino, Calmar, profit factor
478/// - **Slippage Models**: Fixed, percentage, volatility-based
479pub mod backtest;
480
481/// Real-time market data feeds module.
482///
483/// This module is only available when the `data-feeds` feature is enabled.
484/// It provides:
485/// - **MarketDataFeed Trait**: Abstract interface for data providers
486/// - **Price Updates**: Real-time underlying price streaming
487/// - **Trade Feed**: Trade events for order flow analysis
488/// - **IV Surface**: Implied volatility surface updates
489/// - **Mock Feed**: Testing without real connectivity
490///
491/// # Feature Flag
492///
493/// Enable with:
494/// ```toml
495/// [dependencies]
496/// market-maker-rs = { version = "0.3", features = ["data-feeds"] }
497/// ```
498#[cfg(feature = "data-feeds")]
499pub mod data_feeds;
500
501/// Prelude module for convenient imports.
502///
503/// Import all commonly used types with:
504/// ```rust
505/// use market_maker_rs::prelude::*;
506/// ```
507pub mod prelude;
508
509/// OptionStratLib integration module for options market making.
510///
511/// This module is only available when the `options` feature is enabled.
512/// It provides:
513/// - Greeks calculation and portfolio aggregation
514/// - Options pricing adapter
515/// - Time conversion utilities
516/// - Moneyness calculations
517///
518/// # Feature Flag
519///
520/// Enable with:
521/// ```toml
522/// [dependencies]
523/// market-maker-rs = { version = "0.2", features = ["options"] }
524/// ```
525#[cfg(feature = "options")]
526pub mod options;
527
528/// Option-Chain-OrderBook integration module.
529///
530/// This module is only available when the `chain` feature is enabled.
531/// It provides:
532/// - Multi-strike quoting across option chains
533/// - Chain-level Greeks aggregation
534/// - Chain risk management
535/// - ATM strike detection
536///
537/// # Feature Flag
538///
539/// Enable with:
540/// ```toml
541/// [dependencies]
542/// market-maker-rs = { version = "0.3", features = ["chain"] }
543/// ```
544#[cfg(feature = "chain")]
545pub mod chain;
546
547/// REST/WebSocket API module for market maker control and monitoring.
548///
549/// This module is only available when the `api` feature is enabled.
550/// It provides:
551/// - **REST Endpoints**: Status, configuration, quotes, positions, Greeks, P&L
552/// - **OpenAPI Documentation**: Auto-generated API docs with utoipa
553/// - **CORS Support**: Configurable cross-origin resource sharing
554/// - **State Management**: Thread-safe shared state for the market maker
555///
556/// # Feature Flag
557///
558/// Enable with:
559/// ```toml
560/// [dependencies]
561/// market-maker-rs = { version = "0.3", features = ["api"] }
562/// ```
563#[cfg(feature = "api")]
564pub mod api;
565
566/// Persistence layer for market maker data.
567///
568/// This module is only available when the `persistence` feature is enabled.
569/// It provides abstractions for persisting market maker data including:
570/// - **Fill Records**: Trade executions with price, quantity, fees
571/// - **Position Snapshots**: Point-in-time position state
572/// - **Daily P&L**: Aggregated daily profit/loss records
573/// - **Configuration**: Persistent settings storage
574/// - **Event Logs**: System events and alerts
575///
576/// The module includes an in-memory implementation for testing.
577///
578/// # Feature Flag
579///
580/// Enable with:
581/// ```toml
582/// [dependencies]
583/// market-maker-rs = { version = "0.3", features = ["persistence"] }
584/// ```
585#[cfg(feature = "persistence")]
586pub mod persistence;
587
588/// Multi-underlying support module for managing multiple assets simultaneously.
589///
590/// This module is only available when the `multi-underlying` feature is enabled.
591/// It provides:
592/// - **Cross-Asset Correlation**: Track correlations between underlyings
593/// - **Capital Allocation**: Multiple strategies (equal, risk parity, volatility-weighted)
594/// - **Unified Risk View**: Aggregate Greeks and P&L across all positions
595/// - **Per-Underlying Limits**: Individual risk limits per asset
596/// - **Cross-Asset Hedging**: Suggestions for hedging across correlated assets
597///
598/// # Feature Flag
599///
600/// Enable with:
601/// ```toml
602/// [dependencies]
603/// market-maker-rs = { version = "0.3", features = ["multi-underlying"] }
604/// ```
605#[cfg(feature = "multi-underlying")]
606pub mod multi_underlying;
607
608/// Event system for broadcasting market maker events.
609///
610/// This module is only available when the `events` feature is enabled.
611/// It provides a structured event handling system for broadcasting
612/// market maker events to the frontend and other consumers, with support for
613/// event history and reconnection.
614///
615/// # Features
616///
617/// - **Event Broadcasting**: Distribute real-time events to multiple consumers
618/// - **Event Filtering**: Subscribe to specific event types or symbols
619/// - **Event History**: Buffer for reconnection scenarios
620/// - **Event Batching**: Aggregate high-frequency updates
621/// - **Heartbeat**: Connection keep-alive mechanism
622///
623/// # Feature Flag
624///
625/// Enable with:
626/// ```toml
627/// [dependencies]
628/// market-maker-rs = { version = "0.3", features = ["events"] }
629/// ```
630#[cfg(feature = "events")]
631pub mod events;