Share articles to

Academy Beginners Tutorial Article

How to use the OKX crypto trading bot for automated crypto buys and sells

2022.04.28 Rick Delaney

As one of the world’s leading cryptocurrency ecosystems, OKX offers a comprehensive suite of products and services. In addition to our regularly updated trading pairs, decentralized finance offerings and opportunities to generate passive income, we’ve now introduced a customizable trading bot to help you leverage various automated and manual trading strategies.

Trading bot modes

The OKX trading bot has six distinct modes — spot grid, futures grid, recurring buy, arbitrage order, iceberg and TWAP (i.e., time-weighted average price) — suitable for varying purposes and needs.

The first mode, called spot grid, is ideal for traders of any volume hoping to lock in additional profits from asset volatility. You can determine the spot grid’s parameters yourself or choose the AI strategy, which is based on previous price movements. The futures grid trading bot is similar but executes long or short futures trades rather than buying and selling spot.

Recurring buy is OKX’s dollar-cost averaging tool. You can use it to buy into one or more cryptocurrencies at regular intervals to average out a crypto investment’s cost basis. 

Arbitrage order simplifies locking in profits from price discrepancies between OKX trading instruments. For example, using the bot in funding rate arbitrage mode enables users to make money from the payments traders must make to keep perpetual swap positions open. Spread arbitrage mode presents opportunities to profit from the price difference between futures contracts with different settlement dates, or between futures and spot prices. 

The fifth and sixth modes are intended for traders making larger orders. Both TWAP and iceberg orders use the bot to enter or exit a market where price slippage is a risk. These modes are ideal for those wanting to place big trades relative to the size of the chosen market. Large trade sizes can shift the price unfavorably in less liquid markets — like those of smaller market-cap assets listed on OKX. These modes can be helpful when placing such relatively large orders.

The tutorial below covers all six modes and provides instructions for accessing and using the OKX trading bot.

Accessing OKX’s trading bot

On the OKX app homepage, tap Trade


Then, tap MNL and select Trading bot mode.


Open the trading bot menu highlighted and tap the bot you want to use. 

Grid Trading Bot: Spot grid mode for automated buys and sells

Spot grid mode enables you to set a manual price range or use a back-tested AI strategy according to which the trading bot will execute automated buys and sells. This mode is handy for high-volatility assets in bullish markets.

Spot grid mode splits your starting capital between the two assets of your chosen trading pair. It then creates a grid of price points between the upper and lower bounds, and divides your starting position equally between the number of grids used. 

Each time the asset price reaches the upper grid line, the bot automatically sells a portion of the asset. When the asset price reaches the lower grid line, the bot automatically buys the asset. The trader profits from the difference between the buys and sells executed as the price swings.

The following example demonstrates how this works in practice:

Maxwell has $10,000 and wants to profit from BTC price volatility as it trades at $60,000. In manual spot grid mode, he sets a lower price of $50,000, an upper price of $70,000 and 20 grids. This places grid lines with buy or sell orders positioned after every $1,000 interval.

The bot divides his starting position — $10,000 — equally between the number of grid lines. In this case, each grid line is allocated $500 (10,000/20). Since the price when he opens his trade is exactly in the middle of his stated range ($60,000), half of his 10,000 USDT is immediately exchanged for BTC.

Under this setup, the bot establishes $500 BTC sell orders at $61,000, $62,000, etc., up to $70,000, and $500 BTC buy orders at $59,000, $58,000, etc., down to $50,000. Each time a buy or sell order is hit, the bot rebalances the grid with the starting point at the new price. 

If the BTC price moves up to $61,000 over the next day, the bot sells $500 worth of BTC for USDT. The grid rebalances with BTC sell orders above $61,000 and buy orders below. If then, the price moves down to $60,000 again, it fills a buy trade and nets Maxwell just under $8.20 in profit — while also returning the BTC position to roughly its starting size.

If Maxwell had simply held his position, the price action described above would result in a $0 profit.

To access the spot grid trading bot, you must first select a spot trading pair by tapping the trading pair at the top of the screen.

Then, tap Spot and the trading pair you wish to trade with the spot grid bot.


Next, tap Spot grid from the trading bot menu. 

Using the AI strategy for the spot grid

The easiest way to use the spot grid trading bot is with OKX’s back-tested AI strategy. This strategy determines the number of grids and price range on your behalf based on historical price data. 

In the spot grid section, select AI strategy.

Then, enter the total amount you want the bot to trade and tap Create.

On the next screen, check your order details and tap Confirm.

Manually setting the spot grid parameters

OKX’s trading bot allows you to determine the spot grid parameters manually. This is riskier than using the AI strategy — particularly for novice traders. However, it does allow for greater user control and potentially higher profitability. 

Tap Set myself in the spot grid section. 

Enter the upper and lower price bounds for your desired trading range. Then, enter the number of grids you would like to fill the range. This will determine the size of the buy and sell orders the bot creates. Next, enter the total amount you want to invest and select the investment cryptocurrency.

There is also an option to set how the grid is spaced. “Arithmetic” will position each grid line at fixed price intervals (e.g., every 20 USDT). Meanwhile, “Geometric” sets the grids using a fixed percentage from the current price, resulting in widening grids further out from the starting price. 

When you have determined your spot grid parameters, tap Create.

On the next screen, you have the option to add a price at which to take profit from your trade or stop loss. These are useful if the asset price increases or decreases beyond the range you set, and they essentially exit your position either in profit or to limit further losses. 

Enter your SL/TP levels, check the trade details and tap Confirm to deploy the spot grid trading bot.

Futures grid

The futures grid trading bot is similar but buys and sells long or short futures contracts rather than buying and selling assets in the spot market. Again, the futures trading bot uses a grid system to place orders above and below the current price, and buys and sells different futures contracts to profit from price volatility. Futures grid supports three distinct trading strategies: long, short and neutral. 

A crucial difference between the futures grid and spot grid modes is the ability to trade with leverage on futures contracts. Users can amplify their position size with leverage, potentially making it a more capital-efficient strategy. Of course, leverage trading carries its own set of risks, and it’s crucial to understand them before using the futures grid trading bot. 

Learn how to use the futures grid crypto trading bot in this dedicated guide.

Recurring buy using the trading bot

OKX’s trading bot also supports automatic dollar-cost averaging with recurring buy mode, which automatically buys into one or more cryptocurrencies at regular intervals to average an investment’s cost basis out. 

This trading bot is ideal for crypto investors who want to build a position over time and are not confident at optimally timing an entry. With the OKX recurring buy mode, you can set the trading bot and forget about it. 

You can learn how to use OKX recurring buy in this dedicated guide.

Arbitrage orders using the trading bot

OKX’s trading bot features a mode to simplify placing orders to take advantage of arbitrage opportunities between different instruments. Discrepancies between spot and futures contract prices can present profitable situations for traders. This is known as spread arbitrage. 

Similarly, longing an asset in the spot market and shorting with a perpetual swap provides an opportunity to profit via funding rate payments. This is known as funding rate arbitrage. 

If you’ve never traded futures or perpetual swaps before, we recommend you read OKX’s tutorials about each product before attempting to use this arbitrage bot. This will help you understand the risks when trading futures or perpetual swaps.

Select Arbitrage order from the list of trading bot strategies to get started. 


To arbitrage perpetual swap funding rates, tap Fees. To arbitrage the spread between two instruments, tap Spreads

Then, select either Crypto margined to settle trades in your chosen cryptocurrency or USDT margined to settle in USDT, and then tap the portfolio you want to trade.

Funding rate arbitrage

Each funding rate — or fees — arbitrage portfolio has a spot pair and an equivalent perpetual swap contract. When selecting a portfolio, you’ll see important information about each arbitrage opportunity, including its expected APY. 

Enter the details of each leg of the order, including whether it is a buy or sell order, the desired USDT price and the amount in the crypto asset traded. Check the details and click Both Legs to submit both orders simultaneously. 


If the funding rate is positive, you want to be shorting the perpetual contract because long positions will pay you to keep it open. Conversely, if the funding rate is negative, you want to long the perpetual swap to earn funding rate payments from short positions. 

The strategy is low risk, as the two positions cancel each other out. However, if the funding rate goes against you for a prolonged period, you will pay the opposite side of the perpetual position and may lose money overall. 

Spread arbitrage

Spread arbitrage can be performed between two futures contracts or a futures contract and spot position. In spread arbitrage, we take opposite positions in two markets, profiting from price differences.  

Let’s presume the BTC spot price is currently $50,000, and a futures contract is priced at $50,100. If we buy 1 BTC in the spot market and short-sell the futures contract, we will profit with minimal risk no matter the price when the futures contract settles. 

For example, the spot price at settlement is now $55,000. We can sell our spot position for a $5,000 profit (minus trading fees). Meanwhile, our futures position will lose money because we agreed to sell BTC for $50,100 at settlement. OKX sells the BTC on our behalf to honor the futures contract, losing us $4,900. So, we have $5,000 in profit from our spot position and a loss of $4,900 from the futures contract, resulting in a net position of just under $100 — minus the trading fees.  

If the price went the other way, we’d still profit. Let’s say the price dropped to $45,000. Our spot position would lose $5,000. However, our futures position would sell BTC at $50,100 above the spot price, locking in a $100 profit (minus trading fees). The only real risk with this strategy is that the price moves so much that your futures position is liquidated

From the arbitrage portfolio screen, select Spreads

Then, select the margin mode from Crypto margined and USDT margined. Select the instruments you want to arbitrage and the portfolio you wish to trade. You’ll also see various details about the expected profitability of each arbitrage portfolio to help inform your decision.  


Next, fill in your order details for both legs of the order. The portfolio chosen will determine the order type for each leg — either Buy or Sell.

You can choose between “Cross” and “Isolated” margin mode for your derivatives positions. Cross margin mode uses all account funds of the currency traded as a position’s margin. Meanwhile, the Isolated margin mode uses only funds designated as the margin position.

You can also add leverage to your order using the multiplier option. Although leverage can increase your potential profits versus your starting capital, it also increases your liquidation risk. 


For each trade leg, enter your limit order price and the amount in the crypto asset.

You can further customize your trades using the order types Queuing, Surpassed, BBO and Market. Click the Set price button to tweak the “Queuing” and “Surpassed” parameters. These two order types will create a range in which your order will be filled — useful to ensure both legs of the arbitrage are filled at favorable prices. 


When you are happy with your orders, click Both legs to place them simultaneously. You can also use the checkbox to immediately place a market order for the second leg as soon as the initial order fills, guaranteeing that both legs are placed. However, this may reduce the overall spread size, impacting the strategy’s profitability.    

Iceberg orders using the trading bot

Iceberg orders are large buys or sells broken down into many smaller orders. They are handy when making a significant trade relative to the size of the market. Even a smaller order can move the asset price in illiquid markets, resulting in a less favorable entry or exit. Iceberg orders attempt to mask large orders and limit the impact of price slippage. 

To enter iceberg mode, tap Iceberg from the trading bot options. Then, select the instrument and trading pair you want to trade using the menu at the top.

You can use the trading bot in the Spot, Perpetual, Futures, Margin and Options markets. Select the desired instrument and then the trading pair from the list. 

Select either Buy or Sell. Then, enter the amount of slippage you will tolerate — i.e., the amount by which the price can move when executing your trade — in the price range field. You can do this in increments of the trading pair’s base asset using the “Var.” option or a percentage of your order price by using the “Ratio” option. 

Under “Price limit,” enter your ideal exit or entry price. This is the minimum price at which your sell orders will execute or the maximum price of buy orders.


Then, enter the average amount of each of your smaller orders and the total position size. Tap Buy [asset] or Sell [asset] to place your iceberg trade. 


Check your trade details on the next screen and tap Confirm

TWAP orders using the trading bot 

TWAP mode — short for time-weighted average price — seeks to execute a large trade over a specified period. It is similar to an iceberg order in that it attempts to enter or exit a market with a large position without significantly moving the asset’s price. 

To enter the trading bot’s TWAP mode, click TWAP from the bot selection page. 

Once again, select your desired trading pair and instrument using the menu at the topof the screen. 

Choose whether you want to buy or sell the first asset listed in the trading pair and input your tolerated price slippage. Selecting “Var.” enables you to enter an amount denoted in the second asset from the trading pair. Meanwhile, “Ratio” allows you to choose your slippage based on a percentage move from the limit price. 

Next, enter your desired limit price.

Enter the time interval at which you want the bot to make trades, the size of each buy or sell, and the total order amount. Finally, enter the total trade amount and tap Buy [asset].

Check your trade details and tap Confirm on the next screen to initiate the bot. 


Stopping the trading bot and closing trades

You can check on any trades you have created using the trading bot in the “Bot” tab of the trading dashboard. Here you can view details of your trades, including their profitability to date, and here is also where you can stop the bot manually. 

Just tap Close next to the relevant trade to stop an active bot.

You can then keep the asset traded or exit your position to USDT. Choose the appropriate option and tap Confirm.   

Your trade will then disappear from the “Bots” section and appear in your “History.” 

If you experience any difficulties using the trading bot, please contact our support team via the OKX Telegram group or our dedicated Support Center

Not already an OKX trader? Create an account and join our world-leading crypto ecosystem today!

Download the OKX app and trade crypto wherever you are.

Disclaimer: This material should not be taken as the basis for making investment decisions, nor be construed as a recommendation to engage in investment transactions. Trading digital assets involve significant risk and can result in the loss of your invested capital. You should ensure that you fully understand the risk involved and take into consideration your level of experience, investment objectives and seek independent financial advice if necessary.