Comments (4)
Only way I know of is to download the option chain for that symbol from IB TWS, then you can store the contract IDs accessible by P/C, expiry, and strike.
My application will download the chain for the selected symbol and store it in a file if it doesn't already exist. That way if I exit the program during the day I still have the chain if I restart the program. Before the market opens the next day I delete the file and start the program. That way I get a fresh chain since the chain is different every day.
Downloading the chain for indexes like SPX and ETFs like SPY can take a minute or so from TWS.
from twsapicpp.
What I'm doing is just automating a few trades per week; I could download the whole chain but all I really need is a maximum 4 contracts per trade; no reasonable way to do that?
If not would you mind sharing a snippet of your code to download the whole chain?
from twsapicpp.
The following will download the whole chain for 1 symbol. I never download the whole chain, just the symbol I'm interested in.
Contract C;
C.symbol = symbol;
C.secType = *SecType::OPT; //"OPT"
C.currency = "USD";
C.exchange = *Exchange::IB_SMART; //"SMART";
if (expiry != "")
{
C.expiry = expiry;
}
// C.right = call or put
// C.strike = desired strike
m_EC->reqContractDetails(m_NextOrderId++, C);
I always just download all the expiries for the symbol I'm trading, once every morning. As you can see you can just download a single expiry too. I haven't done this but if you know you only want calls or puts you could add that to the contract specification, probably the same for strikes.
BTW I only trade SPX and SPY.
from twsapicpp.
Thanks!!
from twsapicpp.
Related Issues (17)
- No support for multileg option spreads? HOT 2
- One other question: futures options with this system?
- Trouble getting SPX trades to work; SPX vs SPXW? HOT 1
- Storing received messages HOT 4
- TagValueListSPtr
- compiling library warnings
- Using TwsApiCpp with a MinGW project HOT 1
- Build error and potential fix on Mac OS HOT 1
- EClient::checkMessage?
- Adding newer client and wrapper functions?
- Visual Studio Linker Error LNK2019: unresolved external symbol public: static class EClientL0 HOT 1
- Support newer TickTypes HOT 1
- LNK1104 HOT 1
- TwsApiC++/Api/CmakeLists.txt PUBLIC -std=gnu++0x compile option
- Do you support latest IB API which is version 9.72? Not Getting account / position updates
- possible performance tweak (linux) HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from twsapicpp.