Better approach to send orders

Hi everyone!
Based on a discussion on Discord I would like to open the conversation in this forum.
If you want to send orders to the market you have to use the methods:

  • buy/sell if you are using scripts
  • buy_with_specific_market/sell_with_specific_market if you are using strategies

I found this not very practical because I have to code a logic in the strategy every time that I want to buy or sell.
This are the current parameters that you have to send in the script strategy base:

  • connector_name: The name of the connector
  • trading_pair: The market trading pair
  • amount: An order amount in base token value
  • order_type: The type of the order
  • price: An order price
  • position_action: A position action (for perpetual market only)

and this are the ones for the strategy base:

  • market_trading_pair_tuple
  • amount
  • order_type
  • price
  • expiration_seconds
  • position_action

I think that we should create a method like place order, and one of the parameters has to be the side of the trade.
Also, we were discussing in the group the support of market orders via Hummingbot.
For this topic I would like to explain what a CoinAlpha engineer told me about this and then let you decide.
The problem of using market orders is that you don’t know how much you will move the price and if there is not liquidity in the market you will be loosing money.
One solution for this is send a limit order with a price that is crossing the mid price…

e.g.:
- Mid price: 100
- Best ask: 101
- Best bid: 99
I want to buy at market but I don't want to pay more than 102.

The solution is send a limit order with price 102. The bot will buy market but if the price is higher than 102 it will stop.

Hope that the explanation is clear enough and let me know if you need more details!

My opinion is that we should allow market orders because they will be useful if we want to trigger a stop loss for example, but regarding on the explanation, do you think that a “safe_market_order” method with a percentage of slippage will be useful too?

Let me know what you think about this, and if you have another ideas!

2 Likes

I agree that the current order placement logic is unwieldy. and I also agree that Hummingbot connectors should support market orders.

IMO, Hummingbot connectors should support the primary order types allowed by exchanges in a standardized way across all exchanges, and should not define what can or cannot be supported. Then, it’s up to the strategy/script builder what to use in their strategy. The XEMM strategy that CoinAlpha developed may only use limit orders to prevent bad trades, but that shouldn’t prevent others in the community who want to use market orders for other types of strategies

I think a better long-term approach for orders would be to define a place_order function that accepts side and type as arguments.

2 Likes

I also agree with supporting all the order types allowed by the exchanges / API. I think all the existing connectors shouldn’t have any restrictions and this way it will be a lot easier for users and developers to create their own scripts or strategies as they intended using their preferred order type.

1 Like