Building a Market Making Bot for Crypto: A Practical Guide

A market making bot is an automated program that continuously posts two-sided quotes, buy and sell orders around the current price, to capture the bid-ask spread while providing liquidity to an order book. It earns small, repeated profits on the difference between what buyers pay and sellers receive, and it manages the inventory risk that comes with holding one side of that trade longer than planned.
The fastest, lowest-risk way to start is not to write a strategy from scratch. Select an established open-source framework, configure a minimal set of quoting parameters, and run the whole thing on testnet or in paper-trading mode before a single dollar touches a live order. Skipping that step is the single most common reason first attempts lose money in the first week.
Three actions matter before you write any strategy logic:
- Choose a trading pair and exchange with enough order book depth to support two-sided quoting without excessive slippage.
- Configure post-only order types so every fill pays the maker fee rate, not the taker rate.
- Enable circuit breakers, meaning hard inventory limits and a daily loss threshold, before the bot places a single live order.
Key Takeaways
Reliable market making depends less on strategy sophistication and more on disciplined inventory limits, fee-aware post-only execution, and infrastructure that survives disconnects and restarts without losing state.
| Point | Details |
|---|---|
| Start with open-source, on testnet | Use Hummingbot, OctoBot, or a CCXT skeleton and paper-trade before risking capital. |
| Enforce post-only orders | Fee-aware pricing prevents taker fees from erasing spread capture on every fill. |
| Cap inventory hard | Set max_inventory_ratio independently of strategy logic to survive adverse selection. |
| Build kill switches first | Daily P&L breakers and restart recovery matter more than quoting sophistication. |
| Consider managed alternatives | Darkbot offers built-in risk controls and backtesting for traders who want less operational overhead than self-hosting. |
How Order Book Microstructure Drives Spread Capture
An order book has a best bid (the highest price someone will pay) and a best ask (the lowest price someone will sell at). The midpoint between them is the mid-price, and a market maker’s entire job is to place limit orders just inside or at that spread, hoping both sides fill before the market moves against the open position.

Maker versus taker fees decide whether that plan is profitable at all. A maker adds liquidity by placing a limit order that rests on the book; a taker removes liquidity by hitting an existing order immediately. Exchanges reward makers with lower fees, sometimes rebates, and charge takers more, because takers consume the liquidity the exchange needs to function. A bot that accidentally executes as a taker on both legs of a trade can burn through the entire spread it was trying to capture. This is why every serious implementation uses post-only order flags, which reject an order rather than let it execute as a taker.
Inventory risk and adverse selection are the two forces that make this harder than it sounds. If the price moves sharply after your bid fills, you now hold an asset that’s worth less than you paid, and the market moved because informed traders were selling into your bid. That is adverse selection: the counterparties who trade against your resting quotes are more likely to know something you don’t. A bot that ignores this will accumulate one-sided inventory during trending markets and take losses that dwarf any spread income.
A market maker needs three real-time signals to operate safely:
- The full level-2 order book (multiple price levels, not just top of book) so it can gauge depth and imbalance.
- A live trade feed to detect momentum and volume spikes.
- Its own fill stream, so the risk engine knows its current inventory position at all times.
An empirical backtest on crypto order-book data found that a static spread model carried portfolio variance substantially higher, and inventory standard deviation significantly greater, than an adaptive volatility-aware model tested on the same data. Static spreads are simple to reason about, but they quote the same width whether the market is calm or violently trending, which is exactly when adverse selection does the most damage.
Core Technical Components Every Market Making Bot Needs
A working bot is a small distributed system, even if it runs on one server. Treat it that way from the start, or you’ll rebuild it after the first outage.
The essential components:
- L2 WebSocket feed for real-time order book depth, since REST polling is too slow for competitive quoting.
- Wallet and balance tracker that reconciles what the exchange reports against what your bot believes it holds.
- Order manager that handles placing, canceling, and amending orders without race conditions between overlapping requests.
- Position tracker that maintains a running inventory count updated on every fill event.
- Risk engine that can halt trading and flatten positions independent of the main quoting loop.
- Backtester and paper-trading harness for testing changes before they touch live capital.
- Monitoring and alerting covering latency, fill rate, and P&L drift.
For exchange connectivity, unified API libraries handle the tedious work of normalizing REST and WebSocket calls across venues, so you write strategy logic once instead of per-exchange integration code. This matters more than it seems: exchange APIs differ in rate limits, order types, and even how they represent a canceled order, and a unified library absorbs most of that variance.
Pro Tip: Persist your position and open-order state to Redis or SQLite on every update, not just on shutdown. A crash mid-session that loses track of your live inventory is far more dangerous than the crash itself, because your bot will resume quoting with a wrong picture of what it holds.
Which Market Making Strategies Actually Work
Strategy selection depends almost entirely on liquidity, volatility, and how much capital you’re willing to put at risk. Industry practice generally groups these approaches into bid-ask spread quoting, dynamic spread adjustment, arbitrage, and order-book scalping, with inventory risk management as the thread running through all of them.
- Static spread quoting posts orders at a fixed distance from mid-price. It’s simple to implement and debug, but it doesn’t adapt when volatility spikes, which is precisely when a wider spread would protect you.
- Grid trading places a ladder of buy and sell orders at fixed intervals across a price range. It suits ranging, lower-liquidity tokens where price oscillates within a band, but it performs poorly during a sustained directional breakout, since the bot keeps buying into a falling market.
- Avellaneda–Stoikov style dynamic quoting adjusts both spread width and quote skew based on current inventory and estimated volatility. When the bot holds too much of an asset, it skews quotes to encourage selling and discourage further buying, pushing inventory back toward a target level. This model, drawn from the academic market-making literature, is the closest thing the field has to a standard framework for inventory-aware quoting.
- Delta-neutral market making hedges the spot inventory using futures or perpetual contracts, removing most directional exposure so the bot profits primarily from spread capture rather than price direction.
Modern crypto market-making setups increasingly combine grid logic, delta-neutral hedges, and active inventory management rather than relying on a single strategy in isolation. For a first deployment, a static or lightly adaptive spread strategy with strict inventory caps is the sensible starting point. Save Avellaneda–Stoikov style dynamic quoting for after you understand how your chosen pair behaves under normal conditions.
Open-Source Frameworks Worth Examining
Several open-source projects give you a working foundation instead of a blank file. Each makes different trade-offs in language, exchange coverage, and how much operational work you’ll take on.
Hummingbot is the most widely used open-source framework in this space, offering a Python-based architecture with prebuilt strategy templates, exchange connectors, and an active community. It’s the best starting point for rapid prototyping because you can get a basic market-making strategy running against a real exchange within a day, though customizing it deeply for a novel strategy means learning its internal strategy framework first.

OctoBot, through its market-making module, takes a plugin-based approach that’s useful if you want a self-hosted setup with a visual interface layered on top of Python strategy logic. It fits traders who want more configurability than a pure GUI tool but don’t want to write an exchange connector from scratch.
Krypto-trading-bot, known by its repository name ctubio/krypto-trading-bot, is a low-latency C++ engine built for quoting frequency and queue-position sensitivity that Python-based tools generally can’t match. That performance comes at a cost: it demands more systems administration experience to compile, configure, and keep running safely, and its community is smaller than Hummingbot’s.
CCXT isn’t a market-making framework by itself. It’s a unified API library covering a large number of exchanges through one consistent interface, and most custom bots, including the components inside larger frameworks, use it or something like it under the hood to avoid writing separate REST and WebSocket handlers per exchange.
When comparing these projects, weigh four things: the language you and your team can actually maintain, whether your target exchange has a mature connector, how current the documentation is, and whether the codebase includes real risk controls or leaves that entirely to you. A framework with thousands of GitHub stars but a stale commit history is a worse bet than a smaller, actively maintained one.
A Minimal Quoting Loop You Can Build On
A production-minded skeleton follows a repeating cycle, and getting the order of operations right matters more than the specific language you write it in.
The loop: subscribe to the order book via WebSocket (watchOrderBook), compute the mid-price and a reservation price adjusted for current inventory, calculate spread width and quote skew based on volatility, cancel or amend existing orders, place new post-only limit orders at the calculated prices, and update the inventory tracker as fills arrive. CCXT’s own market-making guidance follows this exact shape: stream the book, quote post-only, cancel everything on shutdown, then layer in inventory tracking and volatility-aware spreads incrementally rather than building all of it at once.
Each parameter exists because getting it wrong has a specific, predictable failure mode. A refresh rate that’s too aggressive burns through exchange rate limits and gets your API key throttled; too slow, and your quotes go stale relative to the market, inviting adverse fills. max_inventory_ratio is the parameter that most directly prevents a bad day from becoming a catastrophic one.
Pro Tip: Set order_refresh_ms and min_order_lifetime together, not independently. If your refresh interval is shorter than your minimum order lifetime, you’ll cancel and replace orders before they’ve had a real chance to fill, which pushes you toward the back of the queue on every price level and quietly kills your fill rate.
Risk Controls You Cannot Skip
Fee awareness sits underneath every other risk decision. Maker and taker fee tiers vary by exchange and by your trading volume, and if your spread math doesn’t subtract expected fees from expected profit, you can be executing a strategy that loses money on every completed round trip without realizing it until the statement arrives.
Beyond fees, a handful of operational controls separate a bot that survives volatile markets from one that doesn’t:
- A daily P&L circuit breaker that halts trading once losses cross a predefined threshold.
- A hard maximum inventory limit enforced independently of the strategy logic, not just as a parameter the strategy can override.
- Graceful shutdown behavior that cancels all open orders and, where appropriate, flattens the position rather than leaving it exposed.
- Explicit rules for how the bot unwinds inventory when a limit is breached, rather than freezing and doing nothing.
The same backtest comparing static and adaptive models found that adaptive, volatility-aware spread adjustment reduced inventory variance substantially compared to a static Roll model, even when the adaptive strategy traded less frequently. Fewer trades with tighter risk control beat more trades with wider variance almost every time this has been tested. Adverse selection, not fee drag, is usually what erodes theoretical spread income the fastest, and inventory discipline is the main lever you have against it.
Pro Tip: Before running any live capital, simulate a flash-crash scenario in your backtester, a 5-10% price move within seconds, and confirm your kill switch fires and your inventory cap holds. If your monitoring can surface queue-position estimates (how many orders sit ahead of yours at a price level), use that signal too, since it tells you whether your fills are coming from genuine liquidity demand or from being at the back of a long queue during a spike.
For a deeper walkthrough of how inventory limits and adaptive controls interact in live systems, Darkbot’s guide to risk management in crypto trading covers the operational side of these decisions in more detail.
Deployment, Latency, and Monitoring
Where you run the bot affects how competitive its quotes can be. WebSocket connections deliver book updates in near real time, but the physical distance between your server and the exchange’s matching engine still adds measurable latency. A cloud instance in a region close to the exchange’s infrastructure, or a purpose-built low-latency provider for high-frequency setups, narrows that gap. For most retail-scale market making, a well-connected cloud VPS is sufficient; true colocation only pays off once quoting frequency and order size justify the added cost.

State persistence and failover matter just as much as speed. Store live position and order state in something durable like Redis so a restart doesn’t force the bot to rebuild its picture of the world from scratch, and keep audit logs separate from operational state so you can reconstruct what happened after an incident. API keys deserve the same seriousness as the rest of your infrastructure: restrict them to trading permissions only, disable withdrawal rights entirely, and store secrets outside your codebase.
Monitoring should track fill rate, inventory drift against your target, latency spikes on your data feed, and running P&L, with alerts wired directly into your kill switch rather than requiring a human to notice a dashboard first. Darkbot’s notes on bot hardening and secure operations walk through the monitoring and API-key practices that matter most once a bot is running unattended.
Pro Tip: Wire a health check into your kill switch that verifies WebSocket connectivity every few seconds, not just P&L. A silent disconnection that leaves stale orders resting on the book is a more common failure mode than an actual bad trade.
From Zero to Paper Trading: A Step-by-Step Checklist
- Choose your exchange and trading pair. Pick one with sufficient order book depth and a mature API connector in whatever framework you select.
- Fork or install an open-source framework. Hummingbot, OctoBot, or a CCXT-based custom skeleton are all reasonable starting points depending on your language preference and how much you want to build yourself.
- Configure a minimal, conservative parameter set. Start with a wide base spread, small order size, and a low max inventory ratio; you can tighten these once you see real behavior.
- Run in simulation or on a testnet. Verify the bot places, cancels, and amends orders correctly, and that fills update your inventory tracker accurately.
- Validate inventory behavior under stress. Feed it historical data from a volatile period, or simulate one, and confirm the risk engine skews quotes and halts trading as designed.
- Run a small live test with strict limits. Use real capital, but an amount you’d be comfortable losing entirely, with your daily P&L breaker set tight.
Check logs, fill rates, and latency metrics at every step, not just at the end. A framework covering backtesting and simulation methods, like the resources on Darkbot’s backtesting content hub or the technique-focused posts on QUANTA’s blog, can help you validate a strategy’s behavior before committing real capital to it.
Pro Tip: Before enabling live funds, deliberately kill the bot’s process and restart it while it holds open orders. Confirm it reconciles state correctly and doesn’t double-place orders or lose track of existing inventory. This single test catches more production bugs than any amount of code review.
What Actually Separates a Working Bot From a Toy One
Most people who build their first market-making bot spend the bulk of their time on strategy logic and almost none on the failure paths. That’s backward. A simple static-spread strategy with a hard inventory cap, a daily loss breaker, and reliable state persistence will outperform a mathematically elegant Avellaneda–Stoikov implementation that has no kill switch and doesn’t survive a WebSocket disconnect.
If I were implementing a live strategy from scratch, the first three things I’d build, before any quoting logic, are post-only order enforcement, a hard inventory cap enforced outside the strategy code, and a daily P&L circuit breaker that halts trading independent of everything else. Those three controls don’t make you money. They stop a bad assumption from becoming a large, irreversible loss, which in this business is most of the job.
The gap between a backtest that looks good and a live deployment that survives its first volatile week almost always comes down to operational discipline rather than strategy sophistication. Adaptive volatility-aware quoting helps, but it’s not a substitute for the boring infrastructure work: reconciling state after a crash, verifying your kill switch actually fires, and treating every exchange API quirk as a potential failure point rather than an edge case you’ll handle later.
How Darkbot Compares to Self-Hosted Open-Source Setups
Everything covered above, WebSocket book streaming, post-only order management, inventory caps, circuit breakers, is work you either build yourself with an open-source framework or delegate to a managed platform that has already implemented it. Darkbot approaches this from the second angle: an AI-enabled automation platform built around systematic execution rather than manual strategy assembly.

Darkbot provides direct API integration with major exchanges, configurable risk controls including inventory and drawdown limits, backtesting tools to validate a strategy before it runs live, and real-time analytics for monitoring fill behavior and portfolio exposure. Where a self-hosted framework like Hummingbot or a CCXT-based custom bot gives you full control over every parameter at the cost of ongoing maintenance, patching connectors, monitoring uptime, managing infrastructure, Darkbot handles that operational layer so you can focus on strategy configuration and risk parameters instead of server administration.
A managed platform makes the most sense when your priority is reliable execution and structured risk management without dedicating engineering time to infrastructure upkeep. If you want to evaluate how automated strategy execution behaves before committing capital, you can start with paper-trading on the Darkbot platform and review its risk controls and reporting firsthand.
Frequently Asked Questions
Is a market-making bot the same as a crypto liquidity provider? They overlap. A market-making bot is one method of acting as a crypto liquidity provider: it posts continuous two-sided quotes that add depth to an order book, which is the core function liquidity provision describes.
Do I need to code to run a market making bot strategy? Not necessarily. Frameworks like Hummingbot offer configuration-driven strategy templates that don’t require writing new code, though customizing beyond the built-in templates does require Python familiarity.
What’s the difference between a market making strategy and a breakout strategy crypto traders use? A market making strategy profits from the spread between resting bid and ask orders and generally tries to stay inventory-neutral. A breakout bot crypto traders deploy instead tries to capture directional moves once price clears a defined range, which is a fundamentally different risk profile involving intentional directional exposure rather than spread capture.
How much capital do I need to start a crypto market maker strategy? There’s no fixed minimum, but order sizes need to be large enough to be competitive on the book without breaching your inventory caps after a handful of fills. Starting small on testnet or with minimal live capital while you validate the bot’s behavior is the more important constraint than any specific dollar figure.
Can I run more than one market making strategy at once? Yes, running separate bots on different pairs or exchanges is common practice, provided each has its own independent risk controls and inventory limits so a failure in one doesn’t cascade into the others.
This article provides general technical and educational information about market-making bot design and does not constitute financial or investment advice. Trading cryptocurrency carries risk of loss, and you should confirm exchange-specific rules and consult a qualified professional before deploying live capital.
Sources
- Market making with CCXT (CCXT docs/blog)
- 4 common strategies that crypto market makers use (DWF Labs)
- Crypto Market Making Strategies 2026: Grid, Delta-Neutral and Inventory Management (Token Market Maker)
Recommended
Start trading on Darkbot with ease
Come and explore our crypto trading platform by connecting your free account!
Free plan available • No credit card required
