from datetime import datetime from ib_insync import Option from ibkr.client import Client from ibkr.exchange import SMART client = Client(host = '127.0.0.1', port = 7497) expiration = datetime.now().strftime('%Y%m%d') contract = Option('SPX', expiration, 4550.0, 'P', exchange = SMART, currency = 'USD') contract.tradingClass = 'SPXW' market_data = client.get_market_data(contract, streaming = True) market_data.updateEvent += lambda _: print(market_data.last) client.run_event_loop()