Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get options chain #9

Open
zairgit opened this issue Dec 20, 2013 · 1 comment
Open

Get options chain #9

zairgit opened this issue Dec 20, 2013 · 1 comment

Comments

@zairgit
Copy link

zairgit commented Dec 20, 2013

Is it possible to get a real time options chain on something like NDX?

@eAndy
Copy link

eAndy commented May 11, 2014

here's the basics

            IBClient client = new IBClient();
            try
            {
                client.Connect("127.0.0.1", 4001, 2);
                client..ContractDetails += c_ContractDetails;

                Contract e = new Contract("MSFT", "SMART", SecurityType.Option, "USD");

                client.RequestContractDetails(1001, e);

                Console.WriteLine("Hit [Enter] to quit.");
                while(Console.ReadKey().Key != ConsoleKey.Enter)
                { System.Threading.Thread.Sleep(500); }
                Console.ReadLine();
            }
            finally
            {
                client.Disconnect();
            }

            ...

             void c_ContractDetails(object sender, ContractDetailsEventArgs e)
            {
            string desc = "Security Type Not Supported. See onContractDetails.";
            switch(e.ContractDetails.Summary.SecurityType)
            {
                case SecurityType.Option:
                    Contract o = e.ContractDetails.Summary;
                    desc = string.Format("Option for {0}, Id: {1}, Right{2}, Expiry:{3}, Strike:{4}", e.ContractDetails.Summary.Symbol, o.ContractId, o.Right, o.Expiry, o.Strike);
                    break;
                case SecurityType.Stock:
                    Contract eq = e.ContractDetails.Summary;
                    desc = string.Format("Equity {0}, Id:{1}", eq.Symbol, eq.ContractId);
                    break;

            }
                    Console.WriteLine(desc);

        }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants