В ванильном API IB вы можете указать тикид, но, похоже, Insync каким-то образом позаботится об этом. Проблема в том, что мне нужно отменить потоки рыночных данных, а также запустить их.
Вот мой код:
Код: Выделить всё
from ib_insync import *
# Connect to IB Gateway or TWS
ib = IB()
ib.connect('127.0.0.1', 7496, clientId=5)
# Define the contract for the index
instr = Stock(symbol='SPY', exchange='SMART', currency='USD')
# Request market data
ticker = ib.reqMktData(instr, snapshot=False, regulatorySnapshot=False)
# Wait for data to populate
ib.sleep(1)
# Access the tickId from the ticker object
tick_id = ticker.contract.conId
print(f"Contract ID (conId): {tick_id}")
# Print current market data
print(f"Last price: {ticker.last}")
print(f"Bid: {ticker.bid}")
print(f"Ask: {ticker.ask}")
# Cancel the market data stream
ib.cancelMktData(tick_id)
# Disconnect
ib.disconnect()
Я попробовал добавить галочку:
Код: Выделить всё
ticker = ib.reqMktData(stock, '', False, False, TICKID)
Подробнее здесь: https://stackoverflow.com/questions/788 ... t-a-tickid