OK, I'm starting to understand how this works. I need to use an event handler which gets called for each option contract in the chain, and I also need to retrieve the option contract in the handler. So, the contractdetails call is now:
optionChain = contractdetails(ib, optContract,@ibSbtEventHandler);
And my simple event handler for now is:
function ibSbtEventHandler(varargin)
%IBSBTEVENTHANDLER Interactive Brokers' Trader Workstation SBT event handler.
myCD = get(varargin{5}.contractDetails);
disp('myCD:')
disp(myCD)
myCdSummary = get(myCD.summary);
disp('myCdSummary')
disp(myCdSummary)
end
The output from the disp has:
myCD:
           marketName: 'RUTW'
              minTick: 0.0500
       priceMagnifier: 1
           orderTypes: 'ACTIVETIM,ADJUST,ALERT,ALLOC,AON,AVGCOST,BASKET,CON…'
       validExchanges: 'SMART,CBOE,CBOE2'
           underConId: 416888
             longName: 'Russell 2000 Stock Index'
        contractMonth: '201608'
             industry: 'Indices'
             category: 'Broad Range Equity Index'
          subcategory: '*'
           timeZoneId: 'CST'
         tradingHours: '20160705:0830-1515;20160706:0830-1515'
          liquidHours: '20160705:0830-1515;20160706:0830-1515'
              summary: [1x1 Interface.AE6A66F3_8FA9_4076_9C1F_3728B10A4CC7]
            secIdList: []
                cusip: ''
              ratings: ''
           descAppend: ''
             bondType: ''
           couponType: ''
             callable: 0
              putable: 0
               coupon: 0
          convertible: 0
             maturity: ''
            issueDate: ''
       nextOptionDate: ''
       nextOptionType: ''
    nextOptionPartial: 0
                notes: ''
               evRule: ''
         evMultiplier: 0
myCdSummary
               conId: 239011698
              symbol: 'RUT'
             secType: 'OPT'
              expiry: '20160812'
              strike: 990
               right: 'P'
          multiplier: '100'
            exchange: 'CBOE'
     primaryExchange: ''
            currency: 'USD'
         localSymbol: 'RUTW  160812P00990000'
        tradingClass: 'RUTW'
      includeExpired: 0
           comboLegs: []
           underComp: []
    comboLegsDescrip: ''
           secIdType: ''
               secId: ''
The trick was to realize that the contract details contains a field called summary which is an interface to get the actual contract.
So, I made good progress and my next step will be to use some filtering on the contractdetails request to limit the number of contracts returned to something more manageable. After that, I will need to change the event handler to build an array of the filtered option contracts which I can use later to obtain the prices.
