Ouch.? So my reply was more damaging then helpful.?
To follow up.
As some pointed out there is the IBK 2-Thread and 3-Thread model that is explaned in the iBK doc really well.? I conflated the internal socket reading thread with the separate call back thread for ease of discussion but probably muddied things up.
The link to the Ruby Library is pretty illustrative.? It shows that that library supports a snapshot request for market data that one may use sequentially.? It shows an async version and then a threaded version, as the library offers the capabiility for a syncronous request/response? on a per thread basis.? Note however this is a "higher level" library where the author did a lot of work to support that.
The standard IBK libarry is (deliberately) pretty bare bones.? If you use it, over time, as you do more sophiisticated things,? you will end up building an additionals layer of code? on top of the library with various abstractions, such as a synchronous request / reponse per thread capability,etc. (Notice that is quite different from just sending the requests each on their own thread.)
More specificallyl to your original dilemna.?
?I am using the base IBK client library and need to do a handful of basic Market Data requests should I use threading??? Probably not.?? The sketch of code you were laying out was the start of a slippery slop of writing your own layer of code to support an abstraction of a synchronous request/response on a single thread.? True once you wrote that, yes then you could loop N times, create N req/resp threads, and join (sync) on thread completion. BUT that is a lot of work for your simple problem.
I am using a higher level, third party? (Python, Ruby etc) library that offers threaded Market Data request capability out of the box, should I leverage this capability.? Probably, as someone has already done a lot of heavy lifting for you and made it "simple". There is a highler level. open source, Python library that gets taked about here on the list.? I'd suggest looking into that.
Hey guys, what I am trying to perform is a reqMktData pull (I'm pulling the bid,ask,last prices) for multiple tickers. Normally I would just change the ID number for each ticker.. but for this specific program I am building. The ticker amounts are going to change each day. One day it could be 3 stocks, next day it could be 7.?
So I am trying to come up with a fancy way to "spin off" the reqMktData into its own threads so that can change by the input.?
What is happening is, that the threads spin off fine, but the reqMktData just keeps getting "replaced" by the next ticker in line in the function.?
Really what I need it to do is this
1) For ticker in tickers (the loop through). After we loop the first one. Stop the function and loop. And seal that up as the first thread. 2) Run the function again, for ticker in tickers (the loop) but we pick back up where we left off. Creates another ReqMktData in the 2nd thread. Stop the function and loop from continuing. 3) Function runs again, for ticker in tickers (the loop), and we once again pick back up where we left off. Creates another reqMktData in the 3rd thread. Stop the function and loop.
Since there is only 3 "tickercount" its all finished. Now I had 3 threads all running a reqMktData but each thread has a unique "tickerId" corresponding with each stock in the tickers list.?
Does that make sense? Am I just over complicating this? Here is the code for you to study. Its obviously not the whole program. Everything else in the program works fine.?