API Support Forum
OEC API > API Support > Option-Chain?
Author Topic: Option-Chain?
(6 messages, Page 1 of 1)
Moderators: VPfau
MMuhammad80
Posts: 7
Joined: Feb 25, 2010


Posted: Mar 30, 2010 @ 01:55 AM             Msg. 1 of 6
I want to retrieve (subscribe to) prices for S&P-EMini Options.
E.g. for OESJ0 C1170.
For the underlying future ESM0 one simply calls either SubScribeBars() and gets the message OnBarsReceived() back. Or SubScribeTicks() with OnTicksReceived().

When calling SubScribe() with the contract "OESJ0 C1170" when gets the corresponding message back too, but bars[] or ticks is empty. There are Option-Ticks available. Live-Trade and also eSignal reports current ticks.

I have not found something like an OptionsChain() method.

What is the correct method to retrieve Index-Futures Option-Prices?

Note: The API-documentation has some potential for improvement. Its some sort of reverse engineering to implement the API.

Muhammad Ali
VictorV
Posts: 746
Joined: May 08, 2007


Posted: Mar 30, 2010 @ 07:46 AM             Msg. 2 of 6
Hello,

We are not providing historical data for options.

To get options chain, you need to call RequestContracts for OES base contract. As soon as you rececieve the response, the underlying contract ("ESM0") will contain option chain in the property Contract.Options.

To get any prices you need to use Subscribe(contract) method.
MErshov1302
Posts: 4
Joined: Aug 05, 2021


Posted: Dec 31, 2021 @ 03:38 PM             Msg. 3 of 6
Hello, I tried something similar (subscribe for greeks of the option) on the demo API account

so I set
Client.Options.VolatilitySource = Api.Options.OptionVolatilitySource.Client;

then subscribed on greeks (slightly modifying GF Advanced Example)

protected override void PrepareControlEventHandlers()
{
base.PrepareControlEventHandlers();
Client.Subscriptions.Histogram.HistogramReceived += OnHistogramReceived;
Client.Subscriptions.Greeks.GreeksChanged += OnGreeksChanges;
Client.Contracts.Volatility.ContractVolatilityChanged += OnContractVolatilityChanged;
Client.Contracts.Volatility.VolatilitySubscriptionChanged += OnVolatilitySubscriptionChanged;

Client.Options.VolatilitySource = Api.Options.OptionVolatilitySource.Client;

}


...

public void ChartSelectedContractChangedEventHandler(IContract contract)
{
//clears last subscription
histogramChart.ClearHistogram();
dgHistogram.DataSource = null;

_currentSubscription?.Unsubscribe();
_currentSubscription = null;

if (contract == null)
return;

_currentContract = contract;

Client.Subscriptions.Histogram.Subscribe(contract.ID);
if (contract.IsOption) {
Client.Subscriptions.Greeks.Subscribe(contract.ID);
}

}


Please help me to figure out, is its limitation of the demo account
or should do something additional to receive greeks?

Also, may I ask whether if "GF.Api.Contracts.Volatility"
related to options?
Or it's not a something-related option Implied Volatility (IV)?
MErshov1302
Posts: 4
Joined: Aug 05, 2021


Posted: Dec 31, 2021 @ 03:41 PM             Msg. 4 of 6
The problem is that

private void OnGreeksChanges(IGFClient client, GreeksChangedEventArgs e)
{
Console.WriteLine("OnGreeksChanges");
}


never called.

And volatility event handlers supplying some strange values, that doesn't look like
an option's Implied Volatility
MErshov1302
Posts: 4
Joined: Aug 05, 2021


Posted: Dec 31, 2021 @ 03:43 PM             Msg. 5 of 6
I'm sorry, I wanted to post my question into another topic
https://apisupport.gainfutures.com/Topic/Index/1357
MErshov1302
Posts: 4
Joined: Aug 05, 2021


Posted: Dec 31, 2021 @ 03:59 PM             Msg. 6 of 6
It seems I should subscribe to price changes of underlying future

Client.Subscriptions.Price.Subscribe(cbSymbol.SelectedContract.ID);

And then I will receive GreeksChanged often because future price often changes.

Or I can subscribe to price changes of the option itself
Client.Subscriptions.Price.Subscribe(cbSymbol.SelectedContract.ID);
but the price usually changes rare, so I will receive updates...sometime.