Keyboard Shortcuts
Likes
Search
Re: How to pull all strikes for a given expiration?
¿ªÔÆÌåÓý
Thanks for the responses, it looks like the best way is via the link Dmitry posted below.? I agree that the API could be a lot better in terms of pulling options.? It's ok for pulling historical stock data, but could be a lot cleaner.? I wish IB would just
publish a higher-level Java/C/C#/Python interface layer.? How many people trying to use the API have kept running into the same problems that could have been avoided if they simply provided a better API interface.??
By the way, I mostly use the API for pulling data to do my own charting and technical analysis.? I'm mostly pulling historical stock and ETF OHLC bar data on about 500 tickers.? It appears that if I pull the data via 1 thread, it's just as fast as if I pull
the data through 4 threads...in other words, threading will not speed up the data pull, likely because it's throttled.? Has anyone else noticed this?
[A3]?by?dthayer Cut and paste of code I use to get option data. If set strike=0.0 and expiry=0.0, and right="", then you get the entire chain for both puts and calls.
????????Contract *C = new Contract();
????????C->symbol????????= "KMB"; ????????C->currency????????= "USD"; ????????C->secType = "OPT"; ????????C->expiry = "20130621"; ? ? ????????C->strike = 95.0;????????????????????????// Define as 0.0 to get entire option chain ????????C->right = "P";????????????????????????????????// Put no string, 2 double quotes, if want both put and call ????????C->exchange????????= "SMART"; ????????C->multiplier = ""; ????????C->primaryExchange = ""; ????????C->localSymbol = ""; ????????C->includeExpired = 0;
????????m_pClient1->reqMktData(msgID, C,"233",false);????????// false ¨C start stream, get tick types ????????????????????????????????????????????????????????????????????????// Wait in TWS::contractDetails for reply from TWS ????????//m_pClient1->reqMktData( msgID,C,"",true);????????// true ¨C get snapshot, don't specify tick types. From: [email protected] <[email protected]> on behalf of Richard L King <rlking@...>
Sent: Thursday, February 18, 2021 10:28 AM To: [email protected] <[email protected]> Subject: Re: [TWS API] How to pull all strikes for a given expiration? ?
The short answer is "no". ? Longer answer: ? reqSecDefOptParams is one of those API functions that appears to have been designed by a trainee programmer on a Friday afternoon after a liquid lunch (hence the stupid name), coded by another trainee the following Friday based on the beer mat that the first guy sketched it out on, tested to see whether it gives anything back at all but not whether it actually meets the specification, and then lobbed into the build for us poor API users to try and make sense of. ? I've never had anything good to say about it, and I've never heard anyone else say anything good about it. ? Having said that it can be useful, and I do use it in my platform. But the simple fact is that you can't tell whether anything it returns is actually valid unless you go and get the relevant contract details. ? ? From: [email protected] <[email protected]>
On Behalf Of Crow ? How do I pull all strikes for a given expiration?? I found this API: ?
? Which gives me all combinations of expirations and strikes, but the documentation notes:? ? "?returns a list of expiries and a list of strike prices. In some cases it is possible there are combinations of strike and expiry that would not give a valid option contract." ? Instead, I'd simply like the list of strikes available for a particular expiration.? Any way to get that? ? ? ? |