Overview
TheMarketMakerStrategy implements an automated market-making strategy with:
- Multi-level quote generation
- Inventory-based price skewing
- Position limit management
- Quote lifecycle tracking
- Configurable spread and refresh intervals
MarketMakerConfig
Configuration Parameters
base_spread_ticks
The base spread between bid and ask quotes, measured in ticks. Default:2
Example:
inventory_skew_factor
Controls how much to skew quotes based on current inventory position. Range: 0.0 to 1.0. Default:0.5
Behavior:
- Positive inventory (long) → Lower bids, higher asks (encourage selling)
- Negative inventory (short) → Higher bids, lower asks (encourage buying)
- Factor of 0.0 → No skew
- Factor of 1.0 → Maximum skew
max_inventory
Maximum absolute position size allowed. Strategy stops quoting on a side when this limit is reached. Default:50
Example:
order_size
Quantity of contracts for each quote order. Default:5
num_levels
Number of price levels to quote on each side of the market. Default:3
Example:
min_edge_ticks
Minimum edge required before placing quotes (currently not actively used in implementation). Default:1
cancel_distance_ticks
Distance from the best bid/offer at which to cancel stale orders. Default:10
file:///home/daytona/workspace/source/crates/nano-strategy/src/market_maker.rs:229-252
tick_size
Raw price units per tick. Default:25
refresh_interval_ns
How often to refresh quotes, in nanoseconds. Default:100_000_000 (100ms)
Default Configuration
QuoteManager
Manages the lifecycle of active quote orders.Methods
new
next_order_id
on_order_submit
on_order_ack
on_order_reject
on_fill
on_cancel
Quantity Tracking
Order Lists
MarketMakerStrategy
Constructor
new
name: Strategy identifierinstrument_id: ID of the instrument to tradeconfig: Market maker configurationtick_value: Value of one tick for P&L calculation
Core Methods
calculate_quotes
- Calculate inventory ratio:
position / max_inventory - Calculate skew in ticks:
inv_ratio * skew_factor * base_spread - Apply skew to bid/ask prices around mid
should_refresh_quotes
generate_quotes
- Check if mid price is available
- Check position limits (stop quoting if at max)
- Calculate skewed bid/ask prices
- Generate orders for each level
- Record orders in quote manager
- Update last quote time
generate_cancels
Accessor Methods
quotes
config
fair_value
Strategy Implementation
TheMarketMakerStrategy implements the Strategy trait:
on_market_data
file:///home/daytona/workspace/source/crates/nano-strategy/src/market_maker.rs:348-366 Called when market data updates:- Updates base strategy (P&L, position)
- Checks if strategy is ready
- Checks if quotes need refreshing
- Generates new quotes if refresh interval elapsed
on_fill
file:///home/daytona/workspace/source/crates/nano-strategy/src/market_maker.rs:368-371 Handles fill events:- Updates position and P&L via base strategy
- Updates remaining quantity in quote manager
on_order_ack, on_order_reject, on_order_cancel
file:///home/daytona/workspace/source/crates/nano-strategy/src/market_maker.rs:373-384 Forward order lifecycle events to the quote manager.Complete Example
Inventory Management
The strategy implements inventory risk management through:- Position Limits: Stops quoting when
max_inventoryis reached - Price Skewing: Adjusts quotes to encourage inventory reduction
- Symmetric Limits: Applies limits to both long and short positions
Performance Considerations
- Quote refresh is throttled by
refresh_interval_ns - Old quotes beyond
cancel_distance_ticksare cancelled - All order tracking uses efficient HashMap lookups
- Position checks prevent over-trading
See Also
- BaseStrategy - Base strategy implementation
- SignalStrategy - Signal-based trading
- QuoteManager - Quote lifecycle management