Order Book Price Optimization and Dust-Order Filtering
Summary
This documentation explains an order-pricing feature that adjusts bid and ask prices relative to the next best orders in the order book. It is intended to maintain a position near the top of the book when an order is already best-priced; it does not move an order from the back of the queue to the front automatically. Price changes by other participants are acted on at the next configured order refresh, when existing orders are canceled and replaced.
Separate depth settings specify how much base-asset quantity to ignore when identifying the top bid or ask, allowing small orders to be treated as dust. The guide says the feature works best in single-order mode and recommends disabling transaction-cost adjustments because those adjustments can alter placement prices. It also describes use with multiple order levels. The examples illustrate configurations and price changes, but provide no measurements of fills, queue priority, costs, or profitability; the refresh delay and order-book changes can affect execution outcomes.
Key ideas
- The feature adjusts prices relative to the next best bid and ask when the user's orders are already at the top of the book.
- It does not promote orders from the back of the queue to the front.
- Depth settings ignore a chosen quantity of orders on each side when finding the relevant book price.
- Changes in other orders are reflected after the configured refresh cancels and replaces existing orders.
- The documentation recommends single-order mode and disabling transaction-cost adjustments for this feature.
Tags
Full text
# Order Optimization
# Order Optimization
**Updated as of `v0.35.0`**
Users now have the option to automatically adjust the prices to the right, just above the top bid and just below the top ask.
!!! note
`order_optimization_enabled` was previously called `jump_orders_enabled`
## `order_optimization_enabled`
Allows your bid and ask order prices to be adjusted based on the current top bid and ask prices in the market.
** Prompt: **
```json
Do you want to enable best bid ask jumping? (Yes/No)
>>> Yes
```
## `ask_order_optimization_depth`
The depth in base asset amount to be used for finding top ask.
** Prompt: **
```json
How deep do you want to go into the order book for calculating the top ask, ignoring dust orders on the top (expressed in base asset amount)?
>>>
```
## `bid_order_optimization_depth`
The depth in base asset amount to be used for finding the top bid.
** Prompt: **
```json
How deep do you want to go into the order book for calculating the top bid, ignoring dust orders on the top (expressed in base asset amount)?
>>>
```
## How it works
This feature works best in single order mode. Take note that this does not automatically jump your orders from the bottom to the top. Instead, if your orders are already the best in the order book (at the top) this will adjust your prices right next to the next best orders.
It is recommended to disable `add_transaction_costs` (set to `False`) for this feature to work effectively. This is because adding transaction costs would affect the prices at which the orders are placed and might not be the best bid/ask.
## Sample configuration
```json
- bid_spread: 0.1%
- ask_spread: 0.1%
- order_optimization_enabled: false
- ask_order_optimization_depth: 0
- bid_order_optimization_depth: 0
```
Setting our bid and ask threshold to a very small value (0.1%) puts our orders at the top of the order book. For example, the image below shows the buy order is placed at `0.003159` and the sell order at `0.003165` with the order optimization disabled.

Now let's enable `order_optimization_enabled`. You'll see in the next image that the buy order is placed at `0.003150` and the sell order at `0.003174`, right just above the next best order.
```json
- bid_spread: 0.1%
- ask_spread: 0.1%
- order_optimization_enabled: True
- ask_order_optimization_depth: 0
- bid_order_optimization_depth: 0
```

If the next best order's price changes (not your own), your existing orders will not adjust immediately. It will wait for `order_refresh_time` to cancel your existing orders and the new orders will try to jump to just above best bid or just below best ask.
## Order optimization depth
This allows users to ignore dust orders specified in the base currency amount. As shown in the example above, this is the expected behavior when enabling order optimization.
```json
- bid_spread: 0.1%
- ask_spread: 0.1%
- order_optimization_enabled: True
- ask_order_optimization_depth: 0
- bid_order_optimization_depth: 0
```

Here we configure and set `ask_order_optimization_depth` and `bid_order_optimization_depth` both to 5,000.
```json
- bid_spread: 0.1%
- ask_spread: 0.1%
- order_optimization_enabled: True
- ask_order_optimization_depth: 5000
- bid_order_optimization_depth: 5000
```
Doing this ignores the first 5,000 units of orders on each side in the order book and places our orders right next to them.

## Order optimization with multiple order levels
Users can now use order optimization with multiple `order_levels` see the example below. Order optimization is triggered, and it placed the 2nd order, which has a spread of 0.2% because of `order_level_spread`.
```json
- bid_spread: 0.1%
- ask_spread: 0.2%
- order_levels: 2
- order_level_spread: 0.1%
- order_optimization_enabled: True
- ask_order_optimization_depth: 0
- bid_order_optimization_depth: 0
```
Shown in full with attribution under the source's licence. Licence: Apache-2.0
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.