Can the limit order be placed with timeout?

Hello I would like to place the LIMIT type of order (for spot) and I would like to automaticallly cancel after timeout if not filled. Is that possible? I do it in Python by measuring time from placing the order and then I cancel it, but I would like to know if it can be specified directly in API call. Thanks

Hi,

You can’t set an exact timeout when creating an order. However you can use the timeInForce parameter which has 3 options:

  • GTC (Good-Till-Cancel): the order will last until it is completed or you cancel it.
  • IOC (Immediate-Or-Cancel): the order will attempt to execute all or part of it immediately at the price and quantity available, then cancel any remaining, unfilled part of the order. If no quantity is available at the chosen price when you place the order, it will be canceled immediately.
  • FOK (Fill-Or-Kill): the order is instructed to execute in full immediately (filled), otherwise it will be canceled (killed).

Otherwise you can continue doing what you described by measuring the time directly in your code and sending a DELETE /api/v3/order call if it still hasn’t been filled in the desired timeframe. That will give you the most control.