Author |
Topic: GF COM API Options Help (11 messages, Page 1 of 1) |
||||
---|---|---|---|---|---|
Moderators: VPfau | |||||
RWare2020 Posts: 206 Joined: Feb 11, 2020 |
I am struggling to find examples on getting options information. There is not much for examples on the COM api in the bitbucket repo and I couldn't seem to find very many options items in the c# advanced examples I could reverse engineer.
I need to get the expiration dates and strikes for each expiration date for each option contract given a specific symbol for example YMZ20 (Dow J. IA, Mini - Dec 2020). Right now I am doing a contract load request for the option symbol (in YMZ20, I am using OYMZ20) with a result count of 1000 but even after that I am missing option expirations and strikes for those specific option expirations. It seems like to load strikes, I have to do a contract load with a result count of how many strikes I am wanting? Is there a way I can get the option expiration dates from a symbol lookup request? When I have tried it, I am unable to iterate through the contract's options since the count is 0 because it hasn't been loaded yet is what it seems. If a contract load of result count 1 only returns one strike for that option expiration, how do you propose we handle something like the S&P that has thousands of strikes? If someone could point me in the right direction that would be much appreciated. Thanks. |
||||
JSmith5611 Posts: 187 Joined: |
The trick for this is to do multiple contract load requests.
for all of them, use result count 1000. the first one, use skip count 0. When the ContractLoadReceived event is triggered for that, do another, with skip count of the number of contracts received (most likely 1000) When that one's even is triggered, do another, this time with skip count for the total number of contracts received so far. Continue doing that (ever increasing skip count) until the ContractLoadRecieved event is triggered with zero contracts. At that point, all of them are loaded. BTW, this is the same procedure you'd use for c# Jason Smith
|
||||
RWare2020 Posts: 206 Joined: Feb 11, 2020 |
That is what I am currently doing. It is just much slower than how the OEC API was doing it so that is causing some grief.
Thanks |
||||
RWare2020 Posts: 206 Joined: Feb 11, 2020 |
Is there a way that I can get the available expiration dates for a given options contract?
|
||||
JSmith5611 Posts: 187 Joined: |
btw, for your contract load request what criterion are you using?
And by 'all available expiration dates' do you mean all option series for a givien future contract? like for ESZ20 getting: OEW3X20, OE4AX20, OE4CX20, OEW4X20, OEWX20, OE1CZ20, OEW1Z20, OE1AZ20, OE2CZ20, OEW2Z20, OE2AZ20, OE3CZ20, OESZ20, OE3AZ20 Best way to do that would be the same as before, but limit the strike range of the search to near ATM. Jason Smith
|
||||
RWare2020 Posts: 206 Joined: Feb 11, 2020 |
Thank you I will look into doing that.
This is the contract load request I am using: GF_Api_COM::IContractLoadRequestBuilderPtr builder; builder.CreateInstance(__uuidof(GF_Api_COM::ContractLoadRequestBuilder)); IContractLoadExpressionBuilderPtr exprBuilder; exprBuilder.CreateInstance(__uuidof(GF_Api_COM::ContractLoadExpressionBuilder)); exprBuilder->WithBaseContractID(bc->id); builder->WithResultCount(1000); GFApi()->Contracts->Load->request(builder->Build()); |
||||
RWare2020 Posts: 206 Joined: Feb 11, 2020 |
Sorry I forgot this line:
builder->WithExpression(exprBuilder->Build()); |
||||
JSmith5611 Posts: 187 Joined: |
I do see one thing you can do.
If you want all options on ESZ20, instead of using basecontract ID, and have to iterate through all the different es option base contracts, use WithParentContractID(), with the ID of ESZ20. Parent contract could also be called underlying contract.it is the future contract that an exercised option will get a position in. Jason Smith
|
||||
RWare2020 Posts: 206 Joined: Feb 11, 2020 |
Okay thank you, I will implement that.
One more thing, you say if we want the expiration dates for the available contract you say to limit the strike in our request to around ATM. I know ATM is around the current contract price and I can think of some ways to get a rough strike threshold (taking about 1% of the last price seems to get the a good guess as to where ATM is and a good min/max value for the request), but I'm wondering if there is a better way to do it through the API? Thanks for your help. |
||||
JSmith5611 Posts: 187 Joined: |
ATM = at the money, so the strike that's closest to the current price of the underlying future.
I don't have a good range percentage for this search howerver. Jason Smith
|
||||
RWare2020 Posts: 206 Joined: Feb 11, 2020 |
Right, I know ATM = at the money, but we don't know what strike is closest to the current price without loading the contract first.
|
||||