IB C# API - Price options chain (interactive brokers)

Discussion in 'App Development' started by ladieu, Feb 5, 2015.

  1. ladieu

    ladieu

    I am trying to price an options chain to get the standard things back, such as underlying price, implied volatility etc.

    I'm a programmer by trade and don't know a whole lot about trading. I am making this for someone else to use.

    So I have my main call

    Code:
    ibClient.ClientSocket.reqContractDetails(1, contract);
    This works fine to get the options chain. Now what I want to know is in the EWrapperImpl.cs is there a sane way to price the options without opening up 100+ realtime connections. I just need the prices in a loop, not a realtime connection.

    The goal of this is to filter the options chain down to a few lines that meet our criteria.. so I just need the current information, not a persistent connection.

    Here is what I have in the loop now

    Code:
                Contract contract1 = new Contract();
                contract1.ConId = contractDetails.Summary.ConId;
                contract1.Symbol = contractDetails.Summary.Symbol;
                contract1.SecType = contractDetails.Summary.SecType;
                contract1.Exchange = "SMART";
                contract1.Right = contractDetails.Summary.Right;
                contract1.Strike = contractDetails.Summary.Strike;
                contract1.Expiry = contractDetails.Summary.Expiry;
                clientSocket.reqMktData(i, contract1, "100,101,106", false, null);
    However this errors out, which I assume is due to having too many connections open.

    I'm just not sure I am approaching the problem in the correct way. Viewing the options chain w/ pricing seems to be a pretty common view in trading applications, so what are the best practices here.
     
  2. Butterfly

    Butterfly

    in IB, you can make the quote request (ReqMktData) reply as a loop, which means it will feed every few seconds data to whatever objects you have assigned for the ReqMktData. I am quoting from memory here, so check the IB API Programming Guide for more details.

    However, it would be better to use a different quoting service than IB, and only use IB for trades. IB Quoting service can be "delayed" and not "optimized" according to several sources. Might be ok for some instruments or strategy, but you might be safer to use a different data feed for quotes, even though it would mean integrating a new "data I/O" into your code.

    as for implied volatility, I don't think it's given by default in IB Options quote service, might have to pay extra for it. Not sure, check the IB Market Data service in your account setup with IB, you can subscribe online to all kind of data services for a fee.

    Hope this helps.
     
  3. ladieu

    ladieu

    What feed data source do you recommend. My guys deals with options exclusively

    -Nick
     
  4. ladieu

    ladieu

    Yes you can loop ReqMktData but it starts asynchronous connections to realtime data. Where I just need the snapshot. Once you open too many of these the connection simply gives you errors for having too many open.

    So you have to close them as they open, since they are asynchronous subscriptions they only send out information when it changes... so if you were to wait for each one to close it would take a ton of time to get all of the information required.

    Especially given the fact that his requirement is to scan about 500 symbols to find likely trades that fit his quant strategy

    I tried to post to the official forum but it's having technical issues... so I tried here first.
     
  5. Butterfly

    Butterfly

    in the IB API, you can send a list of objects in one ReqMktData if I am not mistaken, no need to open a "client connection" for each symbol you are trying to feed data from

    as for recommending quote service, I wouldn't know for sure, I am probably not the right person to ask that, above all if it's a sensitive issue for your trading strategy.

    IB TWS let you do scan of SYMBOLS based on prices to build baskets, so your system might be available already in IB TWS.
     
  6. ladieu

    ladieu

    no ReqMktData takes just 1 ticker ID#

    Thanks, I'll keep looking
     
  7. Butterfly

    Butterfly

    also check for the same clientID connection, if you can't you send multiple ReqMktData for different contracts, not as a list, but queued requests. I find it hard to believe that you would need to open a different clientID connection for each ReqMktData, that would be really poor design from IB.

    like I said, your best shot might be with a different data provider with better latency and APIs for I/O requests.
     
  8. ladieu

    ladieu

    Ok, I'll try their official support forum. I don't see any documentation that would indicate that it could reuse a client ID. It's an asynchronous call.. thus you can't queue anything.
     
  9. Butterfly

    Butterfly

    the request is queued as a subscription on their server, the reply is asynchronous

    it might be possible to send ReqMktData for multiple contracts under the same clientID connection, but if that's not the case, then it's poor design and you will need to try a different data provider
     
  10. ladieu

    ladieu

    Butterfly, I'll give it a try today and see. If that's the case I'll feel pretty silly ;)

    I've been looking at IQFeed as a potential alternative
     
    #10     Feb 11, 2015