IB API: reqMktData() - how to submit a new snapshot request after app.run() call?

Discussion in 'Automated Trading' started by kmiklas, Apr 28, 2020.

  1. "I ended up spawning a separate thread to submit reqMktData() requests to the cycling message loop."
    The correct way to do it is to spawn a separate thread to run app.run(). This thread will KEEP LISTENING( send and receive TWS messages through the port). So asking main thread to do it will prevent you from doing anything else.

    Main thread can do reqMketData() and will return immediately. The spawned thread (running app.run) will give you the results from TWS.
     
    #11     May 13, 2020
  2. math

    math

    I am curious how you finally implemented it (hacking def run(self) of client.py I would not recommend), I think you need to send some message to the other thread that is calling reqMktData after tickSnapshotEnd is received (or call reqMktData within that callback). But you may run into problems due to the 11 sec interval (=lag)? In that case cancelMktData may work?
     
    Last edited: Apr 9, 2021
    #12     Apr 9, 2021