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

Live Order Not Retrieved #43

Open
rmalh opened this issue Jan 23, 2025 · 8 comments
Open

Live Order Not Retrieved #43

rmalh opened this issue Jan 23, 2025 · 8 comments

Comments

@rmalh
Copy link

rmalh commented Jan 23, 2025

I was able to place an order using iBind after RTH during extended hours. Pointing my browser to iserver/account/orders displays it with status:"Submitted". The buy price is too low, so I know it won't get filled.

When trying to retrieve it, the following returns an empty list []. I've tried it both with and without 'account_id':

filters = ['Submitted']
client.live_orders(filters, force=True, account_id='my paper account id')

Any idea what could be going on?

@Voyz
Copy link
Owner

Voyz commented Jan 23, 2025

I also noticed this - after RTH this just happens, I don't know why. I'd recommend you get in touch with IBKR support and ask them directly

@salsasepp
Copy link

When trying to retrieve it, the following returns an empty list []. I've tried it both with and without 'account_id':
filters = ['Submitted'] client.live_orders(filters, force=True, account_id='my paper account id')

IBKR docs state that with force=True the result will be an empty array. I guess a followup-request with force=False and filters = ['Submitted'] would work?
https://www.interactivebrokers.com/campus/ibkr-api-page/webapi-ref/#tag/Trading-Orders/paths/~1iserver~1account~1orders/get

@Voyz
Copy link
Owner

Voyz commented Jan 23, 2025

@salsasepp well spotted, although sadly in my experience using force=True followed by force=False after hours still doesn't provide expected results

@salsasepp
Copy link

sadly in my experience using force=True followed by force=False after hours still doesn't provide expected results

I'll soon be in a position to test this and make sad experiences myself... ;-) The fact that a parameter like force exists at all tells me a lot about the web API. Apparently I'm supposed to guess whether some cache is up-to-date or not, and whether I need to flush it or not, and this will maybe help or not. Super. But that's what we have... I guess working with IB to clear up ambiguities and maybe get the odd bug fixed is the best we can do.

@Voyz
Copy link
Owner

Voyz commented Jan 23, 2025

@salsasepp yupp. The good news is, that during market open hours this doesn't seem to be an issue, or if it is, it's very infrequent.

@rmalh
Copy link
Author

rmalh commented Jan 23, 2025

From what I can tell, orders are being sent to IB / exchange just fine. Retrieving them works sporadically, something to do with timing (RTH vs extended hours), caching etc.

@rmalh
Copy link
Author

rmalh commented Jan 24, 2025

After playing with it some, I think placing the following code immediately after a buy / sell / cancel / modify order API call, gets rid of the order retrieval issues.

client.live_orders(filters, force=True)

@rmalh
Copy link
Author

rmalh commented Jan 26, 2025

Another solution that seems to help is to proactively refresh the cache. I tried two options - the iBind function and restarting the script using os.system().

  • client.invalidate_backend_portfolio_cache()
  • os.system(f'./bin/python3 {os.path.basename(file)}')

But we do not know the root cause of the issue and these are all hacks.

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

3 participants