Combo bot TP logic improvement

I noticed that combo bot behavior related to putting TP order not really efficient

Basically when TP price is reached, bot

  1. Cancel all existing orders
  2. Put TP order with calculated price
  3. Waiting for it to fill and if not successful - fill market order instead

Every of those actions have a little delay between each other

This lead to next issues:

Higher fees for market order

Sometimes TP price ended up lower than calculated. Sometimes higher, depends on your luck

This is very important especially for trading with high leverage

I think this moment can be easily improved, because TP is calculated internally after every change and every filled grid order

I understand that putting and moving TP order after each filled grid order will take up too many resources and API request

My proposed solution, in case of LONG bot:

Check if TP price is lower than next SELL grid order. And if yes, put TP limit order with exact calculated price instead of all next nigher SELL grid orders. Cancel all leftover grid orders after

This will improve speed and will make sure that TP is always on proper price, because higher grid orders will not be filled anyway

Most exchanges allowing to have many “reduce only” orders for 100% of position, so its not supposed to a problem