market_maker_rs/lib.rs
1//! Market Making Library
2//!
3//! A Rust library implementing quantitative market making strategies, starting with the
4//! Avellaneda-Stoikov model. This library provides the mathematical foundations and domain models
5//! necessary 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
14//!
15//! - **Inventory Risk**: Holding positions exposes the market maker to price movements
16//! - **Adverse Selection**: Informed traders may trade against you when they have better information
17//! - **Optimal Pricing**: Balance between execution probability and profitability
18//!
19//! # The Avellaneda-Stoikov Model
20//!
21//! The Avellaneda-Stoikov model (2008) solves the optimal market making problem using
22//! stochastic control theory. It determines optimal bid and ask prices given:
23//!
24//! - Current market price and volatility
25//! - Current inventory position
26//! - Risk aversion
27//! - Time remaining in trading session
28//! - Order arrival dynamics
29//!
30//! # Modules
31//!
32//! - [`strategy`]: Pure mathematical calculations for quote generation
33//! - [`position`]: Inventory tracking and PnL management
34//! - [`market_state`]: Market data representation
35//! - [`types`]: Common types and error definitions
36//! - [`prelude`]: Convenient re-exports of commonly used types
37//!
38//! # Quick Start
39//!
40//! Import commonly used types with the prelude:
41//!
42//! ```rust
43//! use market_maker_rs::prelude::*;
44//! ```
45//!
46//! # Examples
47//!
48//! Examples will be added once core functionality is implemented.
49
50#![warn(missing_docs)]
51#![warn(clippy::all)]
52#![deny(unsafe_code)]
53
54// Re-export Decimal for use throughout the library
55pub use rust_decimal::Decimal;
56pub use rust_decimal_macros::dec;
57
58/// Market state module containing market data representations.
59pub mod market_state;
60
61/// Position tracking module for inventory and PnL management.
62pub mod position;
63
64/// Strategy module containing pure mathematical calculations for market making.
65///
66/// This module implements the Avellaneda-Stoikov model calculations:
67/// - Reservation price computation
68/// - Optimal spread calculation
69/// - Bid/ask quote generation
70pub mod strategy;
71
72/// Common types and errors.
73pub mod types;
74
75/// Prelude module for convenient imports.
76pub mod prelude;