Add Avellaneda-Stoikov market making strategy example#76
Conversation
Implements the optimal market making model from "High-frequency trading in a limit order book" (Avellaneda & Stoikov, 2008) adapted for prediction markets. The strategy computes a reservation price adjusted for inventory risk and quotes bid/ask at optimal distances. Key features: - Reservation price shifts proportionally to inventory, encouraging mean-reversion toward zero position - Optimal spread derived from risk aversion (gamma) and order arrival sensitivity (k) parameters - Volatility estimated from rolling window of absolute price changes - Time-decaying inventory penalty (shrinks as session ends) - Prices clamped to valid [0, 1] prediction market range Reference: https://github.com/fedecaccia/avellaneda-stoikov https://claude.ai/code/session_01Wvgt2qrSTA2VvaQyHTrtJT
✅ Deploy Preview for dr-manhattan-oss canceled.
|
👷 Deploy Preview for dr-manhattan-oss processing.
|
|
Pull Request Review: Avellaneda-Stoikov Market Making Strategy SUMMARY STRENGTHS
CRITICAL ISSUES
HIGH PRIORITY ISSUES
MEDIUM PRIORITY ISSUES
PERFORMANCE CONSIDERATIONS Positive:
Improvements:
SECURITY CONCERNS Good practices: Concerns:
TEST COVERAGE Missing: 396 lines of new code with 0 test coverage Recommendations:
RECOMMENDATIONS High Priority:
Medium Priority: VERDICT Approve with changes This is a high-quality implementation of a sophisticated market making strategy. The code is well-structured, mathematically sound, and follows codebase conventions. However, it requires:
With the suggested fixes, this will be an excellent addition to the examples. ADDITIONAL NOTES
|
Summary
Adds a complete implementation of the Avellaneda-Stoikov optimal market making strategy as an example strategy. This strategy uses inventory-adjusted pricing and optimal spread calculation to balance profit capture against inventory risk in prediction markets.
Key Changes
New strategy class:
AvellanedaStoikovStrategythat extends the baseStrategyclassCore algorithm implementation:
r = s - q * gamma * sigma^2 * (T - t)spread = (2 / gamma) * ln(1 + gamma / k)Configuration parameters:
gamma: Risk aversion (0.1-1.0 range for prediction markets)k: Order arrival sensitivity (10-100 range)time_horizon_hours: Trading session lengthvolatility_window: Ticks used for volatility estimationMarket discovery utilities:
find_market_id(): Search markets by slug with optional index selectionprompt_market_selection(): Interactive market selection when multiple matches foundCommand-line interface: Full argument parsing for all strategy parameters with environment variable fallbacks
Implementation Details
https://claude.ai/code/session_01Wvgt2qrSTA2VvaQyHTrtJT