Skip to main content

nautilus_trading/examples/strategies/composite_market_maker/
mod.rs

1// -------------------------------------------------------------------------------------------------
2//  Copyright (C) 2015-2026 Nautech Systems Pty Ltd. All rights reserved.
3//  https://nautechsystems.io
4//
5//  Licensed under the GNU Lesser General Public License Version 3.0 (the "License");
6//  You may not use this file except in compliance with the License.
7//  You may obtain a copy of the License at https://www.gnu.org/licenses/lgpl-3.0.en.html
8//
9//  Unless required by applicable law or agreed to in writing, software
10//  distributed under the License is distributed on an "AS IS" BASIS,
11//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12//  See the License for the specific language governing permissions and
13//  limitations under the License.
14// -------------------------------------------------------------------------------------------------
15
16//! Composite market making strategy with book-mid quoting and external-signal skew.
17//!
18//! Subscribes to quotes for two instruments: a target instrument (the market the
19//! strategy quotes on) and a signal instrument (typically a `SyntheticInstrument`
20//! published by the data engine, but any instrument with a quote stream works).
21//! Quotes a single bid and a single ask around the target's book mid, with two
22//! independent skew terms applied on top:
23//!
24//! - **Inventory skew** discourages position buildup. With `inventory_skew_factor`
25//!   positive, both sides shift down by `factor * net_position`: the bid moves
26//!   further from the market when long, the ask moves closer.
27//! - **Signal skew** lifts both quotes when the signal trades above its baseline.
28//!   The residual is `(signal_mid - baseline) / baseline`. With
29//!   `signal_skew_factor` positive, both sides shift up by `factor * residual`,
30//!   which captures expected drift inferred from the signal.
31//!
32//! Max-position enforcement uses worst-case same-side exposure: open positions
33//! plus all pending buy/sell orders are projected forward so the cap holds even
34//! while async cancels are in flight (same pattern as `GridMarketMaker`).
35
36pub mod config;
37pub mod strategy;
38
39#[cfg(test)]
40mod tests;
41
42pub use config::CompositeMarketMakerConfig;
43pub use strategy::CompositeMarketMaker;