Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Size Limit and Other Order Questions #42

Open
rmalh opened this issue Jan 18, 2025 · 7 comments
Open

Size Limit and Other Order Questions #42

rmalh opened this issue Jan 18, 2025 · 7 comments

Comments

@rmalh
Copy link

rmalh commented Jan 18, 2025

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!

@Voyz
Copy link
Owner

Voyz commented Jan 21, 2025

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.

@rmalh
Copy link
Author

rmalh commented Jan 21, 2025

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?

@Voyz
Copy link
Owner

Voyz commented Jan 21, 2025

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?

@rmalh
Copy link
Author

rmalh commented Jan 21, 2025

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.

@Voyz
Copy link
Owner

Voyz commented Jan 21, 2025

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

@rmalh
Copy link
Author

rmalh commented Jan 23, 2025

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
Copy link
Author

rmalh commented Jan 23, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants