Agents API¶
The lumina_lob.agents package contains the built-in trading agents and the base class for custom agents.
lumina_lob.agents.base
¶
Abstract base class for market agents.
Classes¶
Agent
¶
Bases: ABC
Base class for all market agents.
An agent observes the current reference price and order book state, then emits zero or more orders to be processed by the matching engine.
Source code in lumina_lob/agents/base.py
lumina_lob.agents.noise_trader
¶
Noise trader: random Poisson arrivals with randomized size and side.
Classes¶
NoiseTrader
dataclass
¶
Bases: Agent
Liquidity-demanding agent that submits random limit orders.
Parameters¶
arrival_rate:
Expected number of orders emitted per act() call (Poisson).
size_dist:
Distribution for order quantity: uniform or lognormal.
size_min:
Minimum order quantity for uniform distribution. Default 1.
size_max:
Maximum order quantity for uniform distribution. Default 10.
size_mu:
Mean of log quantity for log-normal distribution. Default 1.0.
size_sigma:
Standard deviation of log quantity for log-normal distribution. Default 0.5.
side_bias:
Probability of generating a bid (0.5 = neutral). Default 0.5.
price_offset_max:
Maximum number of ticks away from the rounded reference price. Default 5.
tick_size:
Price tick size. Default 1.0.
seed:
Optional RNG seed for reproducibility.
Source code in lumina_lob/agents/noise_trader.py
Methods:¶
act(reference_price, book)
¶
Generate a batch of random limit orders.
Source code in lumina_lob/agents/noise_trader.py
lumina_lob.agents.informed_trader
¶
Informed trader: directional signal with temporary/permanent impact tracking.
Classes¶
InformedTrader
dataclass
¶
Bases: Agent
Trader that trades in the direction of a private signal.
The informed trader submits aggressive market orders or large crossing limit orders to move the fair value. It tracks its own traded volume so downstream impact models can estimate temporary and permanent price impact.
Parameters¶
signal:
Direction of private information: bullish or bearish.
trade_size:
Base quantity per order. Must be positive.
participation_rate:
Probability of submitting an order on any given act() call.
Must be in [0, 1].
order_type:
market for aggressive fills, limit for large crossing orders.
price_offset:
For limit orders, how many ticks past the best price to cross. Default 1.
tick_size:
Minimum price increment. Default 1.0.
seed:
Optional RNG seed.
Source code in lumina_lob/agents/informed_trader.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | |
Attributes¶
side
property
¶
Trading side implied by the signal.
total_traded
property
¶
Cumulative quantity traded by this agent.
Methods:¶
act(reference_price, book)
¶
Generate an order if the trader participates this step.
Source code in lumina_lob/agents/informed_trader.py
lumina_lob.agents.market_maker
¶
Market maker: symmetric quotes around reference price with inventory limits.
Classes¶
MarketMaker
dataclass
¶
Bases: Agent
Simple market maker that quotes symmetrically around the reference price.
The agent maintains a target half-spread and a maximum inventory (long/short). If inventory reaches the limit on one side, it stops quoting that side until the position comes back within bounds.
Parameters¶
spread_half_width: Half-spread in price ticks. Must be positive. quote_size: Quantity to quote on each side. Must be positive. max_inventory: Maximum absolute inventory allowed. Must be non-negative. tick_size: Minimum price increment. Default 1.0.
Source code in lumina_lob/agents/market_maker.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | |
Attributes¶
inventory
property
¶
Current signed inventory (positive = long, negative = short).
Methods:¶
act(reference_price, book)
¶
Submit bid/ask quotes around reference price, respecting inventory limits.
Source code in lumina_lob/agents/market_maker.py
on_fill(side, qty)
¶
Update inventory when one of the market maker's orders is filled.
Call this from the simulation loop after processing the agent's orders.
Source code in lumina_lob/agents/market_maker.py
lumina_lob.agents.skewed_market_maker
¶
Skewed market maker: inventory-sensitive quoting.
Classes¶
SkewedMarketMaker
dataclass
¶
Bases: Agent
Market maker that skews quotes based on signed inventory.
As inventory grows long, the market maker lowers bids and offers to attract sells. As inventory grows short, it raises bids and offers to attract buys. The skew is linear in the signed inventory ratio.
Parameters¶
base_half_spread: Base half-spread in ticks before skew. Must be positive. quote_size: Quantity to quote on each side. Must be positive. max_inventory: Maximum absolute inventory allowed. Must be non-negative. skew_factor: How aggressively to skew quotes per unit of inventory ratio. inventory_ratio = inventory / max_inventory. Default 2.0. tick_size: Minimum price increment. Default 1.0.
Source code in lumina_lob/agents/skewed_market_maker.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 | |
Attributes¶
inventory
property
¶
Current signed inventory (positive = long, negative = short).
Methods:¶
act(reference_price, book)
¶
Submit inventory-skewed bid/ask quotes.
Source code in lumina_lob/agents/skewed_market_maker.py
on_fill(side, qty)
¶
Update inventory when one of the market maker's orders is filled.