简体   繁体   中英

Trying to use IbPy, but report “False” when connect to TWS

I have installed the TWS and checked the specific items for the API configuration.

I also installed IbPy by using pip install IbPy2

I think everything is right. However, I got error when I try to connect to the TWS.

Here is my code:

from ib.opt import ibConnection, message
from ib.ext.Contract import Contract
from ib.ext.Order import Order

conn = ibConnection()
conn.connect()

I used the newest version of TWS, and I have a free trail account with username and password. Will this affect the connection?

Output for the code is "False"

def watcher(msg):
    print(msg) 

conn = ibConnection(port=7497, clientId=123)
conn.registerAll(watcher)
conn.connect()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM