Skip to content

Commit af50672

Browse files
committed
docs: note inventory control is stripped, point to Avellaneda-Stoikov
calculate_quotes_fast has no inventory adjustment � it skews quotes purely from the gap-resistance alpha signal. Added prominent notes in both the docstring and README explaining: - Inventory control is intentionally absent - Users must compute a reservation mid before calling calculate_quotes_fast - Formula: reservation_mid = fair_mid + alpha - gamma * sigma^2 * inventory - Reference: Avellaneda & Stoikov (2008) Also added 'No inventory control' to the known limitations bullet list. Made-with: Cursor
1 parent 5ce5807 commit af50672

2 files changed

Lines changed: 48 additions & 0 deletions

File tree

README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,38 @@ Bybit public WS
4141

4242
---
4343

44+
## Inventory control — bring your own
45+
46+
`calculate_quotes_fast` has **no inventory control**. It skews quotes purely based on the
47+
gap-resistance alpha signal and does not penalise a growing position. Running it as-is will
48+
expose you to adverse selection and unbounded inventory risk.
49+
50+
To use this as a proper market-making strategy, compute a **reservation mid** that combines
51+
the alpha signal with an inventory penalty before calling `calculate_quotes_fast`:
52+
53+
```
54+
reservation_mid = fair_mid + alpha_adjustment - gamma * sigma² * inventory
55+
```
56+
57+
where:
58+
- `fair_mid` — raw exchange mid price
59+
- `alpha_adjustment` — your short-term price prediction (e.g. derived from the gap signal)
60+
- `gamma` — risk-aversion / inventory-penalty coefficient (tune to your position limit)
61+
- `sigma` — short-term realised volatility
62+
- `inventory` — current net position (positive = long, negative = short)
63+
64+
Pass `reservation_mid` as the `mid_price` argument and the spread will automatically
65+
centre around an inventory-aware fair value instead of the raw mid.
66+
67+
The canonical reference for this approach is **Avellaneda & Stoikov (2008)**,
68+
"High-frequency trading in a limit order book."
69+
70+
---
71+
4472
## Known limitations / quirks
4573

4674
- **No backtested edge.** The gap-probability signal is a microstructure heuristic. It has not been statistically validated. Treat this as a reference implementation, not a proven profitable strategy.
75+
- **No inventory control.** See the section above. You must implement your own reservation-price adjustment to run this safely in production.
4776
- **Bybit only.** The WS and REST code is Bybit-specific (v5 API).
4877
- **Tick size must match your symbol.** Pass `tick_size` both in `.env` and to `TradingNode.start_stream(tick_size=...)`. Default is `0.10` (BTCUSDT spot). Other symbols need their correct tick size.
4978
- **PostOnly orders only.** The bot never crosses the spread. If the market is too fast, orders are amended rather than re-submitted.

src/gap_mm/engine.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,25 @@ def calculate_quotes_fast(
9191
Returns
9292
-------
9393
(bid_price, ask_price, bid_edge_ticks, ask_edge_ticks, spread_ticks)
94+
95+
NOTE — inventory control has been intentionally stripped out.
96+
This function only skews quotes based on the gap-resistance alpha signal.
97+
To avoid adverse selection and control position risk you should implement
98+
your own inventory adjustment before calling this function, e.g.
99+
Avellaneda-Stoikov reservation price:
100+
101+
reservation_mid = fair_mid + alpha_adjustment - gamma * sigma^2 * inventory
102+
103+
where:
104+
fair_mid = raw mid price
105+
alpha_adjustment = signal-derived short-term price prediction
106+
gamma = risk-aversion coefficient
107+
sigma = realized volatility
108+
inventory = current net position (positive = long, negative = short)
109+
110+
Pass the adjusted reservation_mid as ``mid_price`` to have the spread
111+
automatically centred around a position-aware fair value, rather than the
112+
raw exchange mid.
94113
"""
95114
if confidence == CONF_HIGH or confidence == CONF_MED:
96115
if signal == SIGNAL_UP:

0 commit comments

Comments
 (0)