Automated Market Making on Kalshi
How Cognitive Financial Agents optimize Stochastic Control Problems
I recently noted this interesting project about automated market-making on the alternative investment platform Kalshi after seeing this discussion on YC’s Hackernews. In the rare case that you don’t know, Kalshi is a regulated event futures exchange where users can trade on the outcome of real-world events. Market making in general is a fundamental function in modern financial markets, providing liquidity by continuously quoting both buy and sell prices. And Kalshi is not that different in that regard. This helps to reduce price volatility and ensure smoother trading by allowing investors to buy or sell assets without significant delays. Modern market making, especially in high-frequency trading, was significantly influenced by the 2008 Avellaneda-Stoikov model, developed by Marco Avellaneda and Sasha Stoikov. Their model provides a mathematical framework for optimizing market-making strategies and balancing profit potential with inventory risk. Market makers generate profit through price arbitrage of the bid-ask spread (the price difference between buy and sell orders)
In this post, I will discuss Stochastic Control Problems and ideas to improve market-making with Cognitive Financial Agents.
Market Makers (MM) on Kalshi
It is in Kalshi’s best interest that there is enough liquidity on the platform and that trades are executed quickly. Therefore, Kalshi introduced the MM program which is aimed at credible partners to support Kalshi at enhancing market liquidity and ensuring fair trading practices. While everybody can apply, to qualify, applicants have to pass an evaluation process assessing their financial stability, relevant experience, and business reputation. Benefits of becoming a Kalshi market maker include financial incentives, reduced fees, adjusted position limits, and enhanced platform access.
source
The market maker has to answer three fundamental questions.
What does the market think the asset is worth?
What do I think the asset is worth?
What is my existing inventory of this asset?
This leads to these two fundamental risks a market maker faces:
Inventory risk: The potential for significant losses due to adverse price movements while holding inventory. This risk becomes particularly acute during periods of high volatility or when market makers accumulate large positions due to one-sided order flow. The cost of hedging these positions must be carefully weighed against potential profits. Therefore in any model, we should penalize large inventory positions, encouraging the agent to rebalance to neutral holdings over time.
and
Execution risk: The uncertainty surrounding whether quoted prices will result in executed trades. This includes both the risk of missed trading opportunities when spreads are too wide and the risk of adverse selection when spreads are too tight.
Market makers, as shown in High-Frequency Trading in a Limit Order Book, must constantly balance these competing risks while maintaining competitive quotes.
For a slightly simplified model, the market maker's risk management actions are based on optimizing these variables:
Reservation price: A dynamically adjusted mid-price based on the state of inventory.
Optimal spread: The bid-ask spread (depends on risk appetite and market conditions).
How can this be done?
Stochastic Control Problems (SCP)
Stochastic control problems are optimization problems where decisions are made sequentially under uncertainty. The system evolves over time based on both the decision-maker’s actions and stochastic (random) influences, often modeled as a Markov process. Since the goal is typically to minimize a cost function or maximize a reward function over a given time horizon it lends itself to supporting the challenges of the market maker. You might already see where I am going with this.
SCP’s have the following core components:
State Space: Represents current market conditions—order flow, spread, mid-price movements, and liquidity imbalances.
Control: The set of actions available to the decision-maker. Usually bid-ask quotes and inventory adjustments
Dynamics: The transition law, is often governed by a stochastic differential equation or a Markov decision process (MDP). The next state depends on the current state, action, and a random noise term.
Cost/Reward Function: Defines the objective, usually an expectation over future discounted rewards or costs. Typically minimizes inventory risk while maximizing expected revenues from the bid-ask spread, often formulated as an expected reward over a finite or infinite horizon
Policy: A strategy mapping states to actions.
Automated Market Making as a Stochastic Control Problem
What makes AMM an interesting proposition for Cognitive Financial Agents, is that automation needs to operate in a volatile, adversarial environment where optimal pricing and inventory management require continuous decision-making under uncertainty. We already know that market makers must balance profitability and inventory risk, as holding too much of one asset exposes them to adverse price movements. The underlying dynamics follow a stochastic process, where execution probabilities depend on the posted prices relative to order flow distributions.
Solving the fundamental challenges for automated market-making involves tools from stochastic control, notably the Hamilton-Jacobi-Bellman (HJB) equation and reinforcement learning-based approximations. HJB expresses the maximized reward function through a partial differential equation that captures the trade-offs between immediate costs and future rewards. Solving the HJB equation allows for the dynamic adjustment of bid-ask spreads and inventory positions to maximize long-term profitability while controlling risk. However, the HJB equation is notoriously difficult for market makers due to its high-dimensional, nonlinear nature and the stochastic dynamics of order flow and execution uncertainty.
Avellaneda-Stoikov’s model
Classical approaches like Avellaneda-Stoikov’s model use dynamic programming to determine optimal quoting strategies, balancing spread width and order execution likelihood. Dynamic programming is an optimization technique that breaks complex problems into simpler subproblems and solves each subproblem once while retaining intermediary results to avoid redundant computations.
How would a mathematical model for automated market making following the Avellaneda-Stoikov model, since this is the one used by the project, look like?
A Mathematical Framework for Automated Market Making
Task 1: The market maker quotes bid and ask prices. These quotes define the core mechanism through which the market maker interacts with the market. The spreads, due to their immediate profit impact act as the key control variables that the market maker needs to adjust to maximize profit. Here, the average of the bid and ask prices is called the mid-price and represents the theoretical "fair" value of the asset at any given moment,
Task 2: The market maker needs to control their inventory position.
The mid-price of the asset follows a random walk. i.e., future price changes are independent of past price changes (no memory) and are randomly distributed around the current price. This assumption simplifies the price evolution process while capturing the essential unpredictability of short-term price movements. The random walk model allows for analytical tractability while still providing useful insights for practical implementation.
The Optimal Strategy
Optimization problems are hard. Here, the Avellaneda-Stoikov model aims to derive an optimal pricing strategy that maximizes expected profit while controlling inventory risk.
The market maker operates on the following assumptions
The key result is that optimal spreads should be set according to:
δa*(q,t) = γσ²(T-t)/2 + q*γσ²
δb*(q,t) = γσ²(T-t)/2 - q*γσ²
where:
- γ represents the market maker's risk preference, i.e.: the delta between profit maximization and safe harbor. Higher values of γ lead to wider spreads and more aggressive inventory management.
- T is the terminal time: This represents the investment horizon over which the market maker optimizes their strategy. The dependence of γ on (T-t) captures the increasing risk aversion as the terminal time approaches.
- q is the current inventory: The inventory-dependent term q*γσ² adjusts spreads asymmetrically to encourage mean reversion of the inventory position. Larger absolute inventory positions result in wider spreads on the side that would increase inventory and tighter spreads on the side that would reduce it.
- σ is the volatility: Higher volatility leads to wider spreads to compensate for increased inventory risk. The volatility estimate should be updated frequently using recent market data.
Application to Cognitive Financial Agents
I noticed that cognitive financial agents can augment the Avellaneda-Stoikov model with several minor enhancements.
Here are some of my ideas in no particular order.
Dynamic Parameter Estimation: Using time series models (LTSM) to predict volatility in real-time, using high-frequency data and accounting for short-term patterns. Here the agent observes market conditions as expressed through volatility, order flow, and liquidity and then dynamically adjusts risk preference (γ) and volatility (σ)
Multi-Asset Extension: The agent can extend the AS model to handle correlated assets by incorporating a covariance matrix into the inventory risk calculations which then can be passed into the agent context. Cross-asset pricing opportunities can be identified and exploited through the modeling of price relationships and order flow dynamics. Portfolio-level risk constraints can be implemented using techniques from modern portfolio theory and risk management.
Market Microstructure Integration: Since the agent can handle larger contexts autonomously, it should be possible to incorporate detailed order book information into context to better estimate execution probabilities. The discrete nature orders as expressed through blobs of prices and minimum tick sizes can be explicitly modeled.
Maybe like this:
Order book imbalance: Adjust bid/ask prices based on liquidity.
Hidden liquidity: Detect iceberg orders and adjust positioning.
Momentum signals: If large aggressive orders appear, anticipate price moves.
orders are not getting filled, it can tighten the spread to improve execution.
If fills are too fast, it can widen the spread to avoid adverse selection.
Let’s say the agent detects passive buyers accumulating, the agent would raise the bid price to counter the move.
Calibration Challenges: We already know that asset markets can be highly dynamic. and an event futures exchange for obvious reasons even more so. As model parameters must be regularly recalibrated to adapt to changing market conditions the agent can monitor model performance and flag it to the governance agent. Market regime detection algorithms like vector autoregression can help identify structural breaks that require parameter updates.
In conclusion
I believe that implementing Cogitive Financial Agents jointly with the Avellaneda-Stoikov model as a tool can improve the performance of the market maker on platforms like Kalshi. Deep reinforcement learning methods might directly train optimal market-making policies without relying on simplified model assumptions. Multi-agent learning frameworks can help understand and optimize the collective behavior of multiple market-making agents. Adaptive risk management can be implemented through dynamic reward shaping.
When considering the market impact price impact modeling can help optimize the placement of large orders while minimizing market footprint. Flow toxicity analysis can identify and adapt to informed order flow that may result in adverse selection.
Regulatory Compliance is, as always, key. Market-making Cognitive Financial Agents must and can maintain high-quality detailed audit trails of their decision-making process to satisfy regulatory requirements. Real-time risk controls have to be in place before the model runs wild to prevent disruptive trading behavior. Fair and orderly market requirements must be balanced against profit optimization objectives.
Therefore, Avellaneda-Stoikov provides a robust theoretical opportunity for automated market making — especially on Kalshi. I believe the future of automated market-making will likely see continued evolution of the model, with CFAs playing an increasingly important role in providing market liquidity while managing risks effectively.