Market order to rebalance inventory in PMM

Author: Lawnel 0x27A

Original Post Date: 8 Jun 2022


I would like to propose a change in the PMM strategy I implemented and that I would like to integrate to the base library.

As discussed with cgambit a long time ago, there is a need for an automatic re-balance of inventory as soon as the base or the quote asset are not enough to submit a limit order on one of the two sides. basically whenever the strategy has accumulated inventory in one of the sides and thus there is no enough asset in the other side to submit an order, the strategy will submit a market order to re-balance inventory so we can have always two limit orders active and thus profit for the earnings without having to do it manually in the exchange as it is the case for some traders in the community.

the logic is as follow:

two parameters will be added to the PMM strategy :

  • use market order boolean that would activate this feature if desired
  • a threshold to trigger the market order if the order_amount is less than asset balance * threshold

As an example, suppose that the strategy targeting the pair AVAX/USDT with a price of 50 dollars with :

  • balance of 2 AVAX and 100 dollars
  • the order amount is 2: so we would have 2 AVAX in one side and 100 dollars in the other side
  • the threshold is set to 10%

If the ask order is filled (so we sold 2 AVAX), the base balance would be: 0 AVAX and 200 dollars.

On the next refresh, we would have two options:

  • the feature is not activated : the strategy will only post a buy limit order of 2 AVAX and no sell order (same as usual)
  • the feature is activated: there is no AVAX in the balance which is below the 10% threshold= 0.2 AVAX. If the exchange allow a market order, the strategy will, trigger a market buy order of 2 AVAX. as soon as it is treated by the exchange, the strategy will post a buy and a sell order and could profit for earning on the two sides

one think though, some exchanges do not implement the market order (yeah i am talking to you…) so I decided to use a limit order with negative spread which will be transformed by the exchange to a limit order on best bid or ask…

let me know your though and if this interests the community to propose it as PRP next.



Author: Lawnel 0x27A

one detail I forgot, the market order will take only the amount available on the best bid/ask level so it would not eat different levels and costs many…

Author: cgambit 0xdEa

You really made it through! This feature is really useful as it can auto-manage the bots in normal market conditions.Users will not need to keep on checking the bots and manually intervene to balance the inventories. Setting the bot to take only the available current best orders, instead of market ordering the whole order_amount at once, is wise decision you made. Keep up the good and thanks a lot for sharing this back to the community.

Author: AG Hunter 0x3d5

I agree that this would be a good feature. It would mean users would be less reliant on scripting to achieve this outcome. I would be supportive of this feature being added.