Giter VIP home page Giter VIP logo

Comments (4)

stevegee58 avatar stevegee58 commented on September 9, 2024

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.

markmcwiggins avatar markmcwiggins commented on September 9, 2024

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.

stevegee58 avatar stevegee58 commented on September 9, 2024

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.

markmcwiggins avatar markmcwiggins commented on September 9, 2024

Thanks!!

from twsapicpp.

Related Issues (17)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.