When using Hummingbot to make markets on OKX, most people get stuck on two things: managing inventory and handling orders left behind after a shutdown. The core constraint for placing orders is that OKX has position limits for individual contracts. If your market-making strategy does not set an inventory skew, it is easy to push your inventory to the limit during a one-sided market move. Once that happens, all new orders will be rejected. There are two types of shutdowns: intentional shutdowns and unexpected disconnections. In the first case, Hummingbot will cancel orders when it exits. In the second case, orders are left on the market. That is the most dangerous situation.

A leading global cryptocurrency platform,suitable for both beginners and experienced traders.
New user benefit: 20% off trading fees upon registration!!
Connecting to OKX: Check Your Account Mode First
The OKX connector supports spot and perpetual markets. The connection command is connect okx, and the perpetual connector ID is okx_perpetual. You can create API keys in the API menu under the user icon on the OKX website. You need to provide three items: API Key, Secret, and Passphrase.
Before connecting to perpetual markets, you must switch your OKX account to Single-currency margin mode. This is a clear prerequisite in the official Hummingbot documentation. If you are using Multi-currency margin mode, the connection or order placement may fail.
Another detail that is easy to miss: Hummingbot sets the position mode (one-way or hedge mode) every time it starts. If you still have open perpetual positions when you restart Hummingbot, you need to close them manually before restarting. Otherwise, a conflict in position mode may cause order errors.
Placing Orders: LIMIT_MAKER and Inventory Skew
The order types supported by the OKX connector are LIMIT and LIMIT_MAKER (which corresponds to OKX's post_only). A market-making strategy should use LIMIT_MAKER to ensure that orders only earn rebates and do not pay taker fees.
The real difficulty in market making is inventory management. Hummingbot's pure_market_making strategy has inventory_skew and inventory_range_multiplier parameters. These adjust the offset of buy and sell quotes when inventory deviates from the target. If you do not set these parameters, the strategy will keep placing symmetric orders regardless of inventory changes. The result is that in a one-sided market, one side keeps getting filled and inventory quickly tilts to one side.
OKX's position limit rules will directly interrupt this process. For any contract, if the one-way position and order value of the main account and sub-accounts in that contract reaches max(platform total position value × position ratio threshold, user maximum position value), new opening orders in the same direction will be rejected by the system. The error code is 54030. Orders that close or reduce positions are not restricted.
This means that if your market-making strategy keeps buying and inventory keeps increasing, once it hits the limit, new buy orders sent by the strategy will be rejected by OKX. Hummingbot will record these errors, but the strategy itself will not automatically reduce inventory exposure. You need to monitor inventory value and adjust the strategy or intervene manually before approaching the limit.
Downtime: Intentional Exit and Unexpected Disconnection
When you intentionally shut down Hummingbot, it will try to cancel all unfilled orders. This is the normal process, but you should still confirm: after exiting, check the exchange website to make sure no orders remain.
Unexpected disconnection is the real risk. Hummingbot's architecture documentation clearly states that a core requirement for a trading bot is to keep running during internet outages or exchange service disruptions and to automatically repair its state after recovery. But if the machine you are running loses network, loses power, or the process crashes, Hummingbot has no chance to cancel orders. The orders placed earlier will remain on OKX's order book.
Hummingbot's official explanation of market-making risks also confirms this: if a market-making bot is disconnected from the exchange for a long time, the buy and sell quotes placed earlier will remain on the market. As the price moves, these orders may be filled at unfavorable prices, causing losses.
The size of this risk depends on your order size and how far the orders are from the best bid and ask. If orders are near the top of the book and are large, the chance of being filled by a price spike during a disconnection is not low. If orders are far from the top of the book, the risk is smaller. But market-making orders usually are not far from the top, otherwise there is no chance of being filled.
Pre-Shutdown Checklist
Before shutting down Hummingbot or restarting the server, follow these steps in order:
Run the
stopcommand inside Hummingbot to stop the strategy and wait for the strategy to confirm that order cancellation is complete. Do not close the terminal or kill the process directly.Check the "Current Orders" page on the OKX website and confirm that all orders are gone. Do not only trust Hummingbot's log display.
Confirm that there are no open perpetual positions. If you are using the perpetual connector, you must check before restarting. Hummingbot will reset the position mode when it starts, and leftover positions may cause conflicts.
If the server needs to be restarted, complete the steps above first, then restart the system. After restarting, Hummingbot will not automatically restore the previous strategy state. You need to start the strategy again.
You cannot fully prevent unexpected disconnections, but you can reduce the impact. Use a cloud server instead of a personal computer to run Hummingbot to reduce disconnections caused by closing the laptop lid, system updates, or network switching. Enable OKX's "Cancel on Disconnect" feature if your account type supports it. This can automatically cancel orders when the connection is lost, but you need to check whether your account has this option. Regularly check OKX's API status page and Hummingbot's logs to detect connection issues early.

A leading global cryptocurrency platform,suitable for both beginners and experienced traders.
New user benefit: 20% off trading fees upon registration!!
References
- Hummingbot·OKX, page published or updated: 2026-09-21; checked: 2026-10-08.
- OKX·Contract OI Position Limit Rules, page published or updated: 2025-03-22; checked: 2026-10-08.
- Hummingbot·Hummingbot Architecture - Part 1, page published or updated: 2025-12-02; checked: 2026-10-08.
- Hummingbot Miner·What other risk does a market maker face?, page has no update date; checked: 2026-10-08.
- Tencent Cloud·Hummingbot Cloud Deployment Tutorial, page published or updated: 2026-08-10; checked: 2026-10-08.
- GitHub·hummingbot okx_perpetual_constants.py, page published or updated: 2026-01-18; checked: 2026-10-08.
- GitHub·hummingbot okx index.md, page has no update date; checked: 2026-10-08.


