erdewit / ib_insync

Python sync/async framework for Interactive Brokers API
BSD 2-Clause "Simplified" License
2.83k stars 765 forks source link

Fetching broatape news does not work #248

Closed ghost closed 4 years ago

ghost commented 4 years ago

In a Jupyter notebook I have tried this:

from ib_insync import *

util.startLoop()
ib = IB()
ib.connect('host.docker.internal', 4001, clientId=5)

# Fetch broadtape news
con = Contract()
con.symbol = "DJNL:DJNL_ALL"
con.secType = "NEWS"
con.exchange = "DJNL"

bt = ib.reqMktData(con, "mdoff,292", False, False, [])
ib.sleep(10)
print(bt)

With IB's terminal I receive the broadtape news. However, with ib_insync the gateway says it cannot communicate with the socket

2020-05-02 09:20:25.655 [VQ] INFO  [JTS-CCPDispatcherS15-405] - [2:152:152:1:0:0:0:ERR] Can't write, socket client{2} is closing.
2020-05-02 09:20:25.655 [VQ] INFO  [JTS-CCPDispatcherS15-405] - [2:152:152:1:0:0:0:ERR] Can't write, socket client{2} is closing.
2020-05-02 09:20:25.655 [VQ] INFO  [JTS-CCPDispatcherS15-405] - [2:152:152:1:0:0:0:ERR] Can't write, socket client{2} is closing.
2020-05-02 09:20:25.655 [VQ] INFO  [JTS-CCPDispatcherS15-405] - [2:152:152:1:0:0:0:ERR] Can't write, socket client{2} is closing.

I feel I need to implement an event class. But I do not see any documentation on this. @erdewit can you please advise.

erdewit commented 4 years ago
news = Contract('NEWS', symbol="DJNL:DJNL_ALL", exchange="DJNL")
ib.reqMktData(news, 'mdoff,292')

ib.sleep(5)
print(ib.newsTicks())