Order Refresh Tolerance¶
Updated as of
This feature allows you to specify a range of spreads that is "tolerable" - not canceled and left on the order books - every refresh cycle. It allows you to specify the allowed minimum percentage change in spread to adjust an order. Suppose there is movement in the mid-market price. In that case, you can create flexibility with your trading strategy to control when orders are canceled/replaced (refreshed) with a tolerance percent change to capture an additional profit (see How Is This Parameter Helpful below).
The spread (from mid-price) to defer the order refresh process to the next cycle.
** Prompt: **
How it works¶
config order_refresh_tolerance_pct to set this parameter. By default, this parameter is set to
This means that Hummingbot will cancel active orders (excluding hanging orders) every
order_refresh_time seconds. However, if the price has not changed since the last cycle, Hummingbot will leave the orders there. Setting it to
-1 will disable the feature, which means Hummingbot will always cancel and create orders every
For example, setting
0.1 and an active order's spread changes from 1.0% to 0.9%-1.1% when it's time to refresh depending on
order_refresh_time, this order is kept on the order books (not canceled). However, if the spread exceeds 1.1% or goes below 0.9%, then the order is canceled.
Note that one can set
order_refresh_tolerance_pct to be greater than the bid and ask spreads. If so, the spread can be negative and put you in a position of loss.
Imagine you are trading the
ETH-USDT asset pair on an exchange with a starting mid-market price of 200 USDT (\(t_0\)).
Sample status output/log¶
The ask and bid spread is 2%, so your bot will place orders at the ask price of 204 and your bid price to 196 (\(t_1\)). This configuration creates your orders as follows.
Every 30 seconds, the bot will only cancel and replace the orders if the spreads exceed the range of 1% - 3%.
After 30 seconds (\(t_2\)), the mid-market price increases to 201; the sell spread is 1.49%, and the buy spread is 2.49%. The status of the orders as follows:
The spread of buy/sell orders did not change by more than 1% of what it initially was. A message will show in the logs pane.
Let's say a market taker, someone taking a position in the market likes the smaller sell spread of right before $3 before the ask spread reaches 0.99% (let's say around 1%) and decides to fill your sell order because they think the market price will go up. At $t_3$, the bot cancels the buy order and creates two new orders with an ask and buy spread of 2%.
Consider now that at $4 the price drops to 199. The bid spread is 1.01%, and the ask spread is 3.02%. This is outside of the order refresh tolerance because the spread has changed by more than 1%.
The bot cancels both orders and replaces them with a spread of 2%, let's say at \(t_5\).
Now, at \(t_6\), the spread is now 1.5% and 2.5% for bid and ask spreads, respectively.
The bot will leave these orders because they are within the order refresh tolerance and display the following message again:
Not enough balance for buy (sell) order .... order_amount is adjusted to >
Not canceling active orders since the difference between new order prices and current order prices is within is no longer shown in logs.
Let's say that a market taker thinks the market price will decrease substantially and likes your bid spread. They then can fill your buy order at 195.02.
How is this parameter helpful¶
The default for this parameter is a tolerance of 0%. Thus, at each refresh cycle, if the spread changes at all, the bot will cancel the orders and place new orders at the configuration spread. Because the spread resets at every refresh cycle, this increases the likelihood that the bid and ask spread are closer to the original bid and ask spread. This reduces the risk that the spread substantially strays away from the original spread, perhaps preventing a loss. However, as we have seen above, the strategy can capitalize on the flexibility (tolerance) of the bid and ask spreads because price takers could be looking for some range of spreads that are unknown to you.