-
-
Notifications
You must be signed in to change notification settings - Fork 786
ib_insync connection issue on a Mac #661
Comments
What TWS version are you using? (Help -> About Trader Workstation, something like "Build 10.26.1i, Dec 5, 2023 4:14:06 PM") |
This is it: |
Could it be a conflict between Spyder IDE and async run loops? What happens if you create a python file with this example code: https://github.com/erdewit/ib_insync#example , and run it from the command line (ie: |
Thanks, tashmore. I had no problem downloading the data by running the example you provided. In this case, do you know how can I fix the issue I had? |
Try https://pypi.org/project/nest-asyncio/
Then, before any async code, put:
|
Thank you. My code includes the nest_asyncio call exactly as you mentioned, and the program freezes. I think it is probably related to something else. |
To rule out any network issues, you can try the following code:
If this doesn't work then I suspect Spyder on Mac just doesn't work with ib_insync. Spyder on Linux does work. |
Tried this. It seems to be a problem with asyncio in Spyder on Mac M1. No solution found. |
I have problem connecting to IB using ib_insync on a Mac, but without any problem on a PC. Below are some details:
The ib_insync code I ran is simple, and the same across systems. The setup for TWS seems to have no issue.
import ib_insync as ibis
ib = ibis.IB()
ib.connect('127.0.0.1', 7497, clientId=1)
Once I ran these three lines on a Mac, the Spyder console keeps running without any error message. I have two Macs, both having the same issue. I have no problem connecting to IB on a PC using this code.
I have no issue to connect to IB using IB's own code. That is,
from ibapi.client import EClient
from ibapi.wrapper import EWrapper
class MyWrapper(EWrapper):
def init(self):
super().init()
wrapper = MyWrapper()
client = EClient(wrapper)
client.connect("127.0.0.1", 7497, clientId=1)
client.run()
However, when I ran the ib_insync code above after this, it freezes again. When I restart the kernel, the IB code no longer works, unless I restart the TWS and re login.
The text was updated successfully, but these errors were encountered: