ibind icon indicating copy to clipboard operation
ibind copied to clipboard

Size Limit and Other Order Questions

Open rmalh opened this issue 11 months ago • 7 comments

Hello,

I used the following answers in my place_order request but received "ValueError: No answer found for question" because I didn't include an answer for the size limit question.

answers = { QuestionType.PRICE_PERCENTAGE_CONSTRAINT: True, QuestionType.ORDER_VALUE_LIMIT: True, "Unforeseen new question": True, }

Is there a list of all the questions somewhere? Better yet, can they be answered via configuration (similar to in TWS)?

Thank you so much!

rmalh avatar Jan 18 '25 01:01 rmalh

Hey @rmalh thanks for submitting your issue and for your questions 👍

No, I haven't found the list of the questions anywhere sadly. I've set them up as a minimal example to ensure each user goes through the setup and decides how to answer to these questions on their own through trial and error. As for answering via configuration - you'd need to ask IBKR support, as I don't know of any way of doing this atm. If you do, let us know what they say.

Voyz avatar Jan 21 '25 11:01 Voyz

Thanks @Voyz , maybe I should capture the id for the warning and respond to it as mentioned here and/or here?

If this is indeed the correct way to handle order warnings, do we have an example of how to retrieve and respond to the id?

rmalh avatar Jan 21 '25 13:01 rmalh

The expected way to interact with it would be to specify question-answer dict of pairs and provide these as answers parameter when calling place_order. IBind will then use these to reply to IBKR when they do the back and forth asking questions, handling the replyIds automatically. So the way you'd do it would be:

  1. Try submitting an order
  2. Receive an error due to an unanswered question. IBind will print the entire unanswered question in the log for you to note.
  3. Note the text in the question
  4. Create a new question-answer pair in the answers dict, as demonstrated in the example. Use the text from the question that you've noted in the previous step. Note that this is a partial match, hence the key in the q-a dict may be something like 'orders with limit of' when the entire question text would be 'Would you like to submit orders with limit of 100$' (made up example).
  5. Set the answer (the value of that key) to either True or False if you'd like to proceed or stop when encountering that particular question
  6. Repeat all steps until no further errors are raised and the order is submitted successfully.

Eg.

answers = {
    ...
    'orders with limit of': True
}

Does that make sense? Any way I could clarify it?

Voyz avatar Jan 21 '25 13:01 Voyz

Thanks again @Voyz.

Does iBind have the Order Reply Suppression capability? I'll contact IB today to try and get a comprehensive list of messageIds (i.e. category of messages).

With these two pieces (iBind capability and messageIds), we'll be able to suppress the relevant messages with code.

rmalh avatar Jan 21 '25 21:01 rmalh

Ohh thanks for pointing me in that direction. I'll test out the order surpression and let you know

Voyz avatar Jan 21 '25 21:01 Voyz

Added this to 'ibind/client/ibkr_utils.py' in my local environment: ORDER_SIZE_LIMIT = 'size exceeds the Size Limit of'

Also added this to the list of my answers before placing orders: "QuestionType.ORDER_SIZE_LIMIT: True,"

This worked for a test order placed during extended trading i.e. after RTH. Not sure if IB and the exchanges apply all the checks and balances after RTH. Will keep an eye and post here if there's still an issue.

rmalh avatar Jan 23 '25 01:01 rmalh

@Voyz IB support provided the following links for question suppression:

https://www.interactivebrokers.com/campus/ibkr-api-page/cpapi-v1/#questions-suppress

https://www.interactivebrokers.com/campus/ibkr-api-page/cpapi-v1/#suppressible-id

https://www.interactivebrokers.com/campus/ibkr-api-page/cpapi-v1/#reset-questions-suppress

rmalh avatar Jan 23 '25 13:01 rmalh

Released with 0.1.15 👍

Voyz avatar Jun 17 '25 09:06 Voyz