python - Disconnecting from Interactive Brokers with ibpy -
here pretty standard piece of code use request data interactive brokers api through python:
from ib.ext.contract import contract ib.opt import ibconnection, message import time def watcher(msg): print msg con = ibconnection() con.registerall(watcher) con.connect() contract = contract() contract.m_symbol = "eur" contract.m_exchange = "idealpro" contract.m_currency = "usd" contract.m_sectype = "cash" con.reqmktdata(1, contract, '', false) time.sleep(5) con.disconnect() print "disconnected" time.sleep(60)
i expect connection closed after con.disconnect()
, keeps getting new data (messages print updated bid, ask etc).
why doesn't disconnect()
seem , how can close connection?
use cancelmktdata()
. after calling method, market data specified id stop flowing.
Comments
Post a Comment