utilmon / EasyIB

Python wrapper for Interactive Brokers Client Portal Web API
BSD 3-Clause "New" or "Revised" License
89 stars 24 forks source link

Key error on placing order #10

Closed freekeys closed 1 year ago

freekeys commented 1 year ago

Hi, when I try to create an order I'm getting this message (not always). It's something to do with how it's handling the response during the "reply all" flow (if the response has no position 0). Any thoughts please? Thanks!

placing order for AAPL
Traceback (most recent call last):
  File "/home/xxx/minute_screener_update_dev.py", line 660, in create_order
    response = api.submit_orders(orders, True)
  File "/home/xxx/.local/lib/python3.9/site-packages/easyib/easyib.py", line 191, in submit_orders
    return self._reply_all_yes(response, reply_yes)
  File "/home/xxx/.local/lib/python3.9/site-packages/easyib/easyib.py", line 167, in _reply_all_yes
    dic = response.json()[0]
KeyError: 0
utilmon commented 1 year ago

Hi,

It seems you are getting an empty response from the order submit request. Are other functions working fine, for example get_account()?

freekeys commented 1 year ago

Thanks for your quick response. Since I posted this I've tried a couple of things. When I use the same code to trade AAPL (rather than BABL and others which I'm experiencing the error on) it works fine.

When I try to trade BABL via the IBKR app I get the following message: "No Trading Permission, Customer Ineligible; Ineligibility reasons: Only closing orders are permitted in this instrument.". Any idea what this means? I guess this is what's causing the problem. Shouldn't this message come through via the Api to easyib rather than it being blank?

utilmon commented 1 year ago

I see. According to the error message, the response from the server is empty. I will look into if there are ways to get the warning message printed out.

freekeys commented 1 year ago

Thanks so much! I've also raised a ticket with IBKR to find out why I'm getting the error

eolszewski commented 1 year ago

I have had this same issue when submitting multiple orders. I get no error when the list contains only one order, however. No clue why this is, the error I get back is a blank string...

binxuan commented 1 year ago

I am having the same issue. My account is IBKR lite. Does the account type matter?

utilmon commented 1 year ago

Interactive Broker must have updated their policy. See Jan 2023 update at https://interactivebrokers.github.io/cpwebapi/changelog. I am also having a similar problem when submitting an order. I get a "not authenticated" error. For now, I added an assertion error line that will spit out the correct error statement. However, I feel the ultimate cause of the issue is interconnected with the authentication server somehow (in my case ibeam).