API Support Forum
OEC API > API Support > Blocking call to get Contract?
Author Topic: Blocking call to get Contract?
(4 messages, Page 1 of 1)
Moderators: VPfau
ABaraff
Posts: 2
Joined: Oct 25, 2011


Posted: Nov 15, 2011 @ 08:04 AM             Msg. 1 of 4
Is it possible to make a blocking call to get an instance of a Contract? If I know the symbols I want and just want to sequentially subscribe to them is there a simple method for doing this? Based on looking at the Advanced API Example combobox code, it seems as though I need to make a bunch of symbol lookup calls, then wait for call backs, then finally subscribe to each contract. This seems like a pretty obnoxiously roundabout way of doing what should be very simple. Please tell me that I am wrong.

Thanks,

Anthony

Anthony Baraff
VictorV
Posts: 746
Joined: May 08, 2007


Posted: Nov 15, 2011 @ 08:46 AM             Msg. 2 of 4
All symbol lookup responses are stored inside http://www.openecry.com/api/api/OEC.API.OECClient.Contracts.html. You can pre-populate it on start and use it in synchronous manner.

Victor Vins
Lead Software Developer
ABaraff
Posts: 2
Joined: Oct 25, 2011


Posted: Nov 15, 2011 @ 09:08 AM             Msg. 3 of 4
By prepopulate, you mean make a bunch of SymbolLookup queries when the application opens? If so, this doesn't really solve my problem, but I guess I can do something ugly like make all the requests on one thread and block until I've gotten back the results via another thread.

I've never seen another data API that required you to make a separate asynchronous call to get a reference to an object that then allows you to subscribe to data. Why not allow a developer to create a new Contract object by calling new with a symbol, if it exists in the ContractList you're good to go otherwise mark it as unverified until the API has time to look it up in the background?

Anthony Baraff
VictorV
Posts: 746
Joined: May 08, 2007


Posted: Nov 15, 2011 @ 09:19 AM             Msg. 4 of 4
I would recommend to avoid using OECAPI with multiple threads: OECAPI is not thread-safety.

OECAPI is designed to be asynchronous: we see and use a lot of advantages from it.

Victor Vins
Lead Software Developer