API Support Forum
OEC API > API Support > Request Full Option Chains
Author Topic: Request Full Option Chains
(2 messages, Page 1 of 1)
Moderators: VPfau
MVenè
Posts: 4
Joined: Apr 08, 2019


Posted: Dec 17, 2019 @ 09:12 AM             Msg. 1 of 2
Hello, I need to request the list of available options (maturity, strikes) for a given underlying symbol, let's say ES.

After creating the client, connecting to OEC server, etc, this is what I've done:

First I look up for all available contracts with "ES" in the symbol name


OECLookUp = new SymbolLookupCriteria()
{
OptionsRequired = true,
SearchText = "ES",
Mode = OEC.Data.SymbolLookupMode.AnyInclusion
};
OECClient.SymbolLookup(OECLookUp);


then when receiving the lookup I check whether the received contracts have options, for those who do, I send a new lookup looking for options. For those who don't I assume they are options coming from the second lookup, and print strike and style.
For simplicity, here, I only consider the first received underlying contracts, this results in at most two lookup requests


private void OECClient_OnSymbolLookupReceived(SymbolLookupCriteria symbolLookup, ContractList contracts)
{
if (contracts.First().HasOptions)
{
//Is Futures, ask for options
OECClient.SymbolLookup(new SymbolLookupCriteria
{
SearchText = "*",
ParentContract = contracts.First(),
DesiredResultCount = 999999
});
}
else
{
//Is Options, print underlying, strike, style
foreach (var C in contracts)
Console.WriteLine("{0} {1} {2}", C.ParentContract.Symbol, C.Strike, C.Put ? "Put" : "Call");
}

}


This looks like should working properly, based on other threads here in the forum. But it doesn't. My output is:
ESZ9 3220 Call
ESZ9 3345 Call
ESZ9 2955 Call

Of course there should be many more options available, not only three. But I keep getting only three.
If I request a look up on the second available underlying, instead of the first as in the example, I get 23 options returned. This looks very random.
VPfau
Moderator
Posts: 154
Joined:


Posted: Dec 20, 2019 @ 10:32 AM             Msg. 2 of 2
Hello MVenè,

We have two snippets for option fetching in our repository (3.5 API version)
https://bitbucket.org/snippets/GainFuturesDev/7oLd4/options-lookup
and https://bitbucket.org/snippets/GainFuturesDev/6eg47K/paginated-options-lookup

does it work for you?
Vitaliy Pfau