Working with options
TT's Options trading tools provide traders with all the tools they need to view and analyze option markets, identify opportunities, and assess position risk. TT’s Advanced Options Package is an add-on that enables options analytics and other powerful tools for viewing and trading options. If you are permissioned for this feature, you can also access the options chain through TT .NET SDK.
Process for creating options chain subscriptions
To create an options chain subscription and start receiving updates, you:
- Create an OptionsChainSubscription object for a specific instrument.
- Create an event handler method to be called when options chain updates are available.
- Register the event handler with the OptionsChainSubscription instance.
- Call the Start() method of the OptionsChainSubscription instance.
Subscribing for options chains
The following snippet demonstrates how to instantiate an OptionsChainSubscription instance with specifying a low and high strike in the constructor.
private OptionsChainSubscription m_optSub = null;
{
// …
// Subscribe for market Data
m_optSub = new OptionsChainSubscription(MarketId.CME, "LO", "Jun20",
16M, 28M, tt_net_sdk.Dispatcher.Current);
m_optSub.FieldsUpdated += chain_FieldsUpdated;
m_optSub.Start();
// …
}
Creating the subscription event handler
After the subscription starts, TT .NET SDK retrieves the options chain and invokes the event handler method you registered with the subscription. Subsequent events are then fired as the options chain changes.
The following code snippet shows the structure of a sample options chain subscription event handler method:
void chain_FieldsUpdated(object sender, OptionsChainEventArgs e)
{
if (e.Error == null)
{
Console.WriteLine("{0} Received {1} update for {2} instruments",
DateTime.Now,
e.Fields.UpdateDataType.ToString(),
e.Fields.GetChangedInstrumentIds().Length);
if (e.Fields.UpdateDataType == UpdateDataType.GreekData)
{
foreach (var id in e.Fields.GetChangedInstrumentIds())
{
Instrument i = e.Fields.Instrument(id);
string changes = " instrument: " + i.Name + " ";
foreach (FieldId fid in e.Fields.GetChangedFieldIds(id))
{
changes = changes + fid.ToString() + " " + e.Fields[fid, id].FormattedValue;
}
Console.WriteLine(changes);
}
}
}
else
{
if (e.Error != null)
{
Console.WriteLine("Unrecoverable price subscription error: {0}", e.Error.Message);
Dispose();
}
}
}