Fetching a single instrument
Steps for fetching a single instrument
To fetch a single Instrument, you:
Instantiating the InstrumentLookup class
The InstrumentLookup class provides several overloaded constructors that let you identify instruments using different sets of criteria. These are listed below along with code snippets showing their use.
Synchronous fetch
Once an InstrumentLookup object has been created, you can simply call the Get() method to perform a synchronous lookup of the instrument as shown below. Note that although this is normally fairly quick, your execution thread will be blocked until this action is complete.
Asynchronous fetch
If you prefer not to be blocked, you can register a callback function to be called once the fetching has been completed as shown below.
After the GetAsync() method of the InstrumentLookup instance is called, TT .NET SDK performs a lookup for the instrument based on the inputs that it are given. Whether the instrument is found or not, the specified event handler method is called. The following code snippet illustrates the structure of this event handler.
Cleaning up
When you shut down your application, you should detach all event handlers and call the Dispose() method for each instance of the InstrumentLookup class as follows: